diff --git a/CMakeLists.txt b/CMakeLists.txt index 4c7b021..a642d38 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,256 +1,256 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ cmake_minimum_required (VERSION 2.8 FATAL_ERROR) #Use the compilers found in the path find_program(CMAKE_C_COMPILER NAMES $ENV{CC} gcc PATHS ENV PATH NO_DEFAULT_PATH) find_program(CMAKE_CXX_COMPILER NAMES $ENV{CXX} g++ PATHS ENV PATH NO_DEFAULT_PATH) project(NUISANCE) include(ExternalProject) enable_language(Fortran) set (NUISANCE_VERSION_MAJOR 2) set (NUISANCE_VERSION_MINOR 7) set (NUISANCE_VERSION_REVISION 0) set (NUISANCE_VERSION_STRING "v${NUISANCE_VERSION_MAJOR}r${NUISANCE_VERSION_MINOR}") if(${NUISANCE_VERSION_REVISION} STRGREATER "0") set (NUISANCE_VERSION_STRING "${NUISANCE_VERSION_STRING}p${NUISANCE_VERSION_REVISION}") endif() #Set this to TRUE to enable build debugging messages set(BUILD_DEBUG_MSGS TRUE) include(${CMAKE_SOURCE_DIR}/cmake/cmessage.cmake) include(${CMAKE_SOURCE_DIR}/cmake/cacheVariables.cmake) cmessage(STATUS "CMAKE_INSTALL_PREFIX: \"${CMAKE_INSTALL_PREFIX}\"") cmessage(STATUS "CMAKE_BUILD_TYPE: \"${CMAKE_BUILD_TYPE}\"") ################################################################################ # Check Dependencies ################################################################################ ################################## ROOT ###################################### include(${CMAKE_SOURCE_DIR}/cmake/ROOTSetup.cmake) ################################# HEPMC ###################################### include(${CMAKE_SOURCE_DIR}/cmake/HepMC.cmake) ############################### HepMCNuEvt ################################### include(${CMAKE_SOURCE_DIR}/cmake/HepMCNuEvtSetup.cmake) ############################ Reweight Engines ################################ include(${CMAKE_SOURCE_DIR}/cmake/ReweightEnginesSetup.cmake) ############################ Other Generators ################################ include(${CMAKE_SOURCE_DIR}/cmake/GiBUUSetup.cmake) if(USE_NUANCE) LIST(APPEND EXTRA_CXX_FLAGS -D__NUANCE_ENABLED__) endif() ################################# Pythia6/8 #################################### include(${CMAKE_SOURCE_DIR}/cmake/pythia6Setup.cmake) include(${CMAKE_SOURCE_DIR}/cmake/pythia8Setup.cmake) ################################# gperftools ################################### include(${CMAKE_SOURCE_DIR}/cmake/gperfSetup.cmake) if(NOT NOTEST) enable_testing() endif() SET(GENERATOR_SUPPORT) foreach(gen NEUT;NuWro;GENIE;GiBUU;NUANCE) if(USE_${gen}) SET(GENERATOR_SUPPORT "${GENERATOR_SUPPORT}${gen} ") endif() endforeach(gen) cmessage(STATUS "Generator Input Support: ${GENERATOR_SUPPORT}") set(MINCODE Routines FCN) set(CORE MCStudies FitBase Config Logger InputHandler Splines Utils Statistical #Devel Smearceptance ) LIST(APPEND ALLEXPERIMENTS ANL ArgoNeuT BEBC BNL Electron FNAL GGM K2K MINERvA MicroBooNE MiniBooNE SciBooNE T2K) foreach(exp ${ALLEXPERIMENTS}) if(NOT NO_${exp}) LIST(APPEND EXPERIMENTS_TO_BUILD ${exp}) else() LIST(REVERSE EXTRA_CXX_FLAGS) LIST(APPEND EXTRA_CXX_FLAGS -D__NO_${exp}__) LIST(REVERSE EXTRA_CXX_FLAGS) endif() endforeach() ################################## COMPILER #################################### include(${CMAKE_SOURCE_DIR}/cmake/c++CompilerSetup.cmake) ################################### doxygen ################################### include(${CMAKE_SOURCE_DIR}/cmake/docsSetup.cmake) ################################################################################ set(MINIMUM_INCLUDE_DIRECTORIES) LIST(APPEND MINIMUM_INCLUDE_DIRECTORIES ${RWENGINE_INCLUDE_DIRECTORIES} ${CMAKE_SOURCE_DIR}/src/FitBase ${CMAKE_SOURCE_DIR}/src/Reweight ${CMAKE_SOURCE_DIR}/src/InputHandler ${CMAKE_SOURCE_DIR}/src/Config ${CMAKE_SOURCE_DIR}/src/Logger ${CMAKE_SOURCE_DIR}/src/Statistical ${CMAKE_SOURCE_DIR}/src/Splines ${CMAKE_SOURCE_DIR}/src/Utils) #Not yet capable of just building without the rwdirs. #if(USE_REWEIGHT) LIST(APPEND MINIMUM_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src/Reweight) LIST(APPEND CORE Reweight) #endif() cmessage(DEBUG "Base include directories: ${MINIMUM_INCLUDE_DIRECTORIES}") set(EXP_INCLUDE_DIRECTORIES) foreach(edir ${EXPERIMENTS_TO_BUILD}) LIST(APPEND EXP_INCLUDE_DIRECTORIES ${CMAKE_SOURCE_DIR}/src/${edir}) endforeach() cmessage(DEBUG "Included experiments: ${EXP_INCLUDE_DIRECTORIES}") foreach(mdir ${MINCODE}) cmessage (DEBUG "Configuring directory: src/${mdir}") add_subdirectory(src/${mdir}) endforeach() foreach(edir ${EXPERIMENTS_TO_BUILD}) cmessage (DEBUG "Configuring directory: src/${edir}") add_subdirectory(src/${edir}) endforeach() foreach(cdir ${CORE}) cmessage (DEBUG "Configuring directory: src/${cdir}") add_subdirectory(src/${cdir}) endforeach() cmessage(DEBUG "Module targets: ${MODULETargets}") LIST(APPEND MODULETargets -Wl,--end-group) LIST(REVERSE MODULETargets) LIST(APPEND MODULETargets -Wl,--start-group) LIST(REVERSE MODULETargets) add_subdirectory(app) add_subdirectory(src/Tests) configure_file(cmake/setup.sh.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" @ONLY) install(FILES "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/setup.sh" DESTINATION ${CMAKE_INSTALL_PREFIX}) configure_file(cmake/MakeBinaryBlob.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/MakeBinaryBlob" @ONLY) install(PROGRAMS "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/MakeBinaryBlob" DESTINATION bin) if(USE_DYNSAMPLES) SET(ALL_INCLUDES ${MINIMUM_INCLUDE_DIRECTORIES}) LIST(APPEND ALL_INCLUDES ${CMAKE_SOURCE_DIR}/src/Smearceptance) LIST(APPEND ALL_INCLUDES ${EXP_INCLUDE_DIRECTORIES}) string(REPLACE ";" " -I" ALL_INCLUDES_STR "${ALL_INCLUDES}") string(REPLACE "${CMAKE_SOURCE_DIR}/src" "${CMAKE_INSTALL_PREFIX}/include" ALL_INCLUDES_STR "${ALL_INCLUDES_STR}") cmessage(DEBUG ${CMAKE_DEPENDLIB_FLAGS}) string(REPLACE "-levent " "" CMAKE_DEPENDLIB_FLAGS_NEW ${CMAKE_DEPENDLIB_FLAGS}) set(CMAKE_DEPENDLIB_FLAGS ${CMAKE_DEPENDLIB_FLAGS_NEW}) cmessage(DEBUG ${CMAKE_DEPENDLIB_FLAGS}) string(REPLACE ";" " -l" ALL_MODULETARGETS_STR "${MODULETargets}") string(REPLACE "-l-" "-" ALL_MODULETARGETS_STR "${ALL_MODULETARGETS_STR}") configure_file(cmake/BuildDynamicSample.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSample" @ONLY) install(PROGRAMS "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSample" DESTINATION bin) configure_file(cmake/BuildDynamicSmearcepter.in "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSmearcepter" @ONLY) install(PROGRAMS "${PROJECT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/BuildDynamicSmearcepter" DESTINATION bin) endif() install(PROGRAMS "${PROJECT_SOURCE_DIR}/scripts/nuiscardgen" DESTINATION bin) install(PROGRAMS "${PROJECT_SOURCE_DIR}/scripts/nuissamples" DESTINATION bin) add_subdirectory(event_gen) install(DIRECTORY ${PROJECT_SOURCE_DIR}/data DESTINATION ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/event_gen DESTINATION ${CMAKE_INSTALL_PREFIX}) install(DIRECTORY ${PROJECT_SOURCE_DIR}/parameters DESTINATION ${CMAKE_INSTALL_PREFIX}) diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 1fdd629..0349363 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,103 +1,103 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(TARGETS_TO_BUILD) if(USE_MINIMIZER) add_executable(nuismin nuismin.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuismin) add_executable(nuissplines nuissplines.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuissplines) endif() include_directories(${RWENGINE_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/Routines) include_directories(${CMAKE_SOURCE_DIR}/src/InputHandler) include_directories(${CMAKE_SOURCE_DIR}/src/Genie) include_directories(${CMAKE_SOURCE_DIR}/src/FitBase) include_directories(${CMAKE_SOURCE_DIR}/src/Statistical) include_directories(${CMAKE_SOURCE_DIR}/src/Utils) include_directories(${CMAKE_SOURCE_DIR}/src/Config) include_directories(${CMAKE_SOURCE_DIR}/src/Logger) include_directories(${CMAKE_SOURCE_DIR}/src/Splines) include_directories(${CMAKE_SOURCE_DIR}/src/Reweight) include_directories(${CMAKE_SOURCE_DIR}/src/FCN) include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies) include_directories(${CMAKE_SOURCE_DIR}/src/Smearceptance) include_directories(${EXP_INCLUDE_DIRECTORIES}) if (USE_NuWro AND NOT NUWRO_BUILT_FROM_FILE) add_executable(nuwro_nuisance nuwro_NUISANCE.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuwro_nuisance) endif() if (USE_GiBUU) add_executable(DumpGiBUUEvents DumpGiBUUEvents.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};DumpGiBUUEvents) endif() add_executable(nuis_flat_tree_combiner nuis_flat_tree_combiner.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuis_flat_tree_combiner) add_executable(nuiscomp nuiscomp.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuiscomp) add_executable(nuisflat nuisflat.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuisflat) add_executable(nuissmear nuissmear.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuissmear) add_executable(nuissyst nuissyst.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuissyst) add_executable(nuisbayes nuisbayes.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuisbayes) if(USE_GENIE) add_executable(PrepareGENIE PrepareGENIE.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};PrepareGENIE) endif() if(USE_NEUT) add_executable(PrepareNEUT PrepareNEUT.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};PrepareNEUT) endif() # PREPARE NUWRO # Commented out for the time being until it is finished.. if(USE_NuWro) add_executable(PrepareNuwro PrepareNuwroEvents.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};PrepareNuwro) endif() add_executable(nuisbac nuisbac.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};nuisbac) foreach(targ ${TARGETS_TO_BUILD}) if(NOT "${CMAKE_LINK_FLAGS} ${NUIS_EXE_FLAGS}" STREQUAL " ") set_target_properties(${targ} PROPERTIES LINK_FLAGS "${CMAKE_LINK_FLAGS} ${NUIS_EXE_FLAGS}") endif() target_link_libraries(${targ} ${MODULETargets}) target_link_libraries(${targ} ${CMAKE_DEPENDLIB_FLAGS}) endforeach() install(TARGETS ${TARGETS_TO_BUILD} DESTINATION bin) \ No newline at end of file diff --git a/app/DumpGiBUUEvents.cxx b/app/DumpGiBUUEvents.cxx index e3e571f..a91d614 100644 --- a/app/DumpGiBUUEvents.cxx +++ b/app/DumpGiBUUEvents.cxx @@ -1,49 +1,49 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include #include "FitLogger.h" #include "StdHepEvt.h" int main(int argv, char const *argc[]) { if (argv != 2) { NUIS_ABORT("[ERROR]: expected a single input GiBUU rootracker file."); } std::string inpf(argc[1]); if (!inpf.length()) { NUIS_ABORT("[ERROR]: expected an input GiBUU rootracker file."); } TChain tn("giRooTracker"); tn.AddFile(inpf.c_str()); GiBUUStdHepReader giRead; bool ok = giRead.SetBranchAddresses(&tn); if (!ok) { NUIS_ABORT("[ERROR]: Could not correctly set branch address for input file."); } for (Long64_t ievt = 0; ievt < tn.GetEntries(); ++ievt) { tn.GetEntry(ievt); NUIS_LOG(EVT, WriteGiBUUEvent(giRead)); } } diff --git a/app/DumpROOTClassesFromVector.cxx b/app/DumpROOTClassesFromVector.cxx index 7c22652..c5692d4 100644 --- a/app/DumpROOTClassesFromVector.cxx +++ b/app/DumpROOTClassesFromVector.cxx @@ -1,128 +1,128 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GeneralUtils.h" #include "TCollection.h" #include "TError.h" #include "TFile.h" #include "TStreamerInfo.h" #include "TString.h" #include "TTree.h" #include #include #include int main(int argc, char const* argv[]) { // shhh ROOT it okay. gErrorIgnoreLevel = kError; if (argc != 4) { std::cout << "[ERROR](DumpROOTClassesFromVector): Recieved " << (argc - 1) << " CLI opts." << std::endl; for (int i = 1; i < argc; ++i) { std::cout << "[" << i << "] \"" << argv[i] << "\"" << std::endl; } std::cout << "Usage: " << argv[0] << " " " " << std::endl; return 1; } char const* ROOTFileName = argv[1]; char const* OutputDirectoryName = argv[2]; char const* CSLClasses = argv[3]; TFile* fl = TFile::Open(ROOTFileName); if (!fl || !fl->IsOpen()) { std::cerr << "[ERROR](DumpROOTClassesFromVector): Failed to open root file: " << fl << std::endl; return 1; } std::cout << "[INFO]: Writing project files to " << OutputDirectoryName << std::endl; fl->MakeProject(OutputDirectoryName); TIter next(fl->GetStreamerInfoList()); TStreamerInfo* inf = 0; std::vector ClassesToFind = GeneralUtils::ParseToStr(CSLClasses, ","); if (!ClassesToFind.size() || !ClassesToFind[0].length()) { std::cerr << "[ERROR](DumpROOTClassesFromVector): No classes to find passed in." << std::endl; return 2; } std::vector ClassesToLink; while ((inf = dynamic_cast(next()))) { std::cout << "[INFO]: Have StreamerInfo for class: " << inf->GetName() << std::endl; for (size_t ClTF_it = 0; ClTF_it < ClassesToFind.size(); ++ClTF_it) { if (std::string(inf->GetName()) == ClassesToFind[ClTF_it]) { ClassesToLink.push_back(inf->GetName()); std::cout << "[INFO]: Including streamer info for: " << inf->GetName() << " in generated LinkDef" << std::endl; } } } if (ClassesToFind.size() > ClassesToLink.size()) { std::cerr << "[ERROR](DumpROOTClassesFromVector): Only found " << ClassesToLink.size() << " classes to include in the ROOT library, expected at least " << ClassesToFind.size() << std::endl; return 1; } std::string OutputDir(OutputDirectoryName); size_t pos = OutputDir.find_last_of('/'); pos = (pos == std::string::npos) ? 0 : pos; std::string LinkDef_loc = OutputDir + "/" + OutputDir.substr(pos) + "LinkDef.h"; std::cout << "[INFO]: Writing LinkDef to: " << LinkDef_loc << std::endl; std::ofstream LinkDefos(LinkDef_loc.c_str()); if (!LinkDefos.is_open()) { std::cerr << "[ERROR] Couldn't open " << LinkDef_loc << " for writing." << std::endl; } LinkDefos << "#ifdef __CINT__" << std::endl; for (size_t ClTL_it = 0; ClTL_it < ClassesToLink.size(); ++ClTL_it) { LinkDefos << "#pragma link C++ class " << ClassesToLink[ClTL_it] << "+;" << std::endl; } LinkDefos << "#endif" << std::endl; LinkDefos.close(); std::string Instances_loc = OutputDir + "/" + OutputDir.substr(pos) + "ProjectInstances.h"; std::ofstream Instancesos(Instances_loc.c_str()); if (!Instancesos.is_open()) { std::cerr << "[ERROR] Couldn't open " << Instances_loc << " for writing." << std::endl; } Instancesos.close(); } diff --git a/app/PrepareGENIE.cxx b/app/PrepareGENIE.cxx index 2a9cb69..299c358 100644 --- a/app/PrepareGENIE.cxx +++ b/app/PrepareGENIE.cxx @@ -1,1009 +1,1037 @@ #include "FitLogger.h" #include "PlotUtils.h" #include "TFile.h" #include "TH1D.h" #include "TTree.h" #include "TFolder.h" #include #include #ifdef __GENIE_ENABLED__ #ifdef GENIE_PRE_R3 #include "Conventions/Units.h" #include "GHEP/GHepParticle.h" #include "PDG/PDGUtils.h" #else #include "Framework/Conventions/Units.h" #include "Framework/GHEP/GHepParticle.h" #include "Framework/ParticleData/PDGUtils.h" #endif #endif std::string gInputFiles = ""; std::string gOutputFile = ""; std::string gFluxFile = ""; std::string gTarget = ""; double MonoEnergy; int gNEvents = -999; bool IsMonoE = false; bool useNOvAWeights = false; void PrintOptions(); void ParseOptions(int argc, char *argv[]); void RunGENIEPrepareMono(std::string input, std::string target, std::string output); void RunGENIEPrepare(std::string input, std::string flux, std::string target, std::string output); bool CheckConfig(std::string filename); int main(int argc, char *argv[]) { ParseOptions(argc, argv); if (IsMonoE) { RunGENIEPrepareMono(gInputFiles, gTarget, gOutputFile); } else { RunGENIEPrepare(gInputFiles, gFluxFile, gTarget, gOutputFile); } } // CWret October 2019 // We have to scale the 2p2h cross-section when the 2p2h generator in GENIE is Nieves // When the 2p2h generator is Empirical no such scaling is needed // This is needed to match the output of PrepareGENIE to GENIE splines from gspl2root // Allow the user to override this for debugging // Search for what model the user ran with bool CheckConfig(std::string filename) { TFile *f = new TFile(filename.c_str()); // Get the config TFolder *first = (TFolder*)f->Get("gconfig"); // Find the GlobalParameterList TFolder *folder = (TFolder*)first->FindObject("GlobalParameterList/Default"); TIter iter(folder->GetListOfFolders()); TKey *key; // Should we scale this? Only if Nieves 2p2h bool ShouldScale = false; while ((key = (TKey*)iter.Next())) { std::string name = key->GetName(); // Look for XSecModel (specifies the interaction model GENIE was run with) // Look for MEC (specifies it's a MEC setting) // Look for Nieves 2p2h from 2016 if (name.find("XSecModel") != std::string::npos && name.find("MEC-CC") != std::string::npos && name.find("NievesSimoVacasMECPXSec2016") != std::string::npos) { ShouldScale = true; } } f->Close(); if (!ShouldScale) { - NUIS_LOG(FIT, "Not scaling 2p2h CC events with Nieves..." << std::endl); + NUIS_LOG(FIT, "Not scaling 2p2h CC events with Nieves..."); } else { - NUIS_LOG(FIT, "Scaling 2p2h CC events with Nieves..." << std::endl); + NUIS_LOG(FIT, "Scaling 2p2h CC events with Nieves..."); } return ShouldScale; } void RunGENIEPrepareMono(std::string input, std::string target, std::string output) { NUIS_LOG(FIT, "Running GENIE Prepare in mono energetic with E = " << MonoEnergy << " GeV"); // Setup TTree TChain *tn = new TChain("gtree"); std::string first_file = ""; if (input.find_first_of(',') != std::string::npos) { std::vector inputvect = GeneralUtils::ParseToStr(input, ","); for (size_t iv_it = 0; iv_it < inputvect.size(); ++iv_it) { tn->AddFile(inputvect[iv_it].c_str()); NUIS_LOG(FIT, "Added input file: " << inputvect[iv_it]); if (!first_file.length()) { first_file = inputvect[iv_it]; } } } else { // The Add form can accept wildcards. tn->Add(input.c_str()); first_file = input; } if (tn->GetFile() == NULL) { tn->Print(); NUIS_ERR(FTL, "gtree not located in GENIE file: " << input); NUIS_ABORT("Check your inputs, they may need to be completely regenerated!"); throw; } int nevt = tn->GetEntries(); if (gNEvents != -999) { NUIS_LOG(FIT, "Overriding number of events by user from " << nevt << " to " << gNEvents); nevt = gNEvents; } if (!nevt) { NUIS_ABORT("Couldn't load any events from input specification: \"" << input.c_str() << "\""); } else { NUIS_LOG(FIT, "Found " << nevt << " input entries in " << input); } StopTalking(); NtpMCEventRecord *genientpl = NULL; tn->SetBranchAddress("gmcrec", &genientpl); StartTalking(); // Have the TH1D go from MonoEnergy/2 to MonoEnergy/2 TH1D *fluxhist = new TH1D("flux", "flux", 1000, MonoEnergy / 2., MonoEnergy * 2.); fluxhist->Fill(MonoEnergy); fluxhist->Scale(1, "width"); // Make Event Hist TH1D *eventhist = (TH1D *)fluxhist->Clone(); eventhist->Reset(); TH1D *xsechist = (TH1D *)eventhist->Clone(); // Create maps std::map modexsec; std::map modecount; std::vector genieids; std::vector targetids; std::vector interids; // Loop over all events for (int i = 0; i < nevt; i++) { tn->GetEntry(i); StopTalking(); EventRecord &event = *(genientpl->event); GHepParticle *neu = event.Probe(); StartTalking(); // Get XSec From Spline GHepRecord genie_record = static_cast(event); double xsec = (genie_record.XSec() / (1E-38 * genie::units::cm2)); // Parse Interaction String std::string mode = genie_record.Summary()->AsString(); std::vector modevec = GeneralUtils::ParseToStr(mode, ";"); std::string targ = (modevec[0] + ";" + modevec[1]); std::string inter = mode; // Fill lists of Unique IDS if (std::find(targetids.begin(), targetids.end(), targ) == targetids.end()) { targetids.push_back(targ); } if (std::find(interids.begin(), interids.end(), inter) == interids.end()) { interids.push_back(inter); } // Create entries Mode Maps if (modexsec.find(mode) == modexsec.end()) { genieids.push_back(mode); modexsec[mode] = (TH1D *)xsechist->Clone(); modecount[mode] = (TH1D *)xsechist->Clone(); modexsec[mode]->GetYaxis()->SetTitle( "d#sigma/dE_{#nu} #times 10^{-38} (events weighted by #sigma)"); modecount[mode]->GetYaxis()->SetTitle("Number of events in file"); } // Fill XSec Histograms modexsec[mode]->Fill(neu->E(), xsec); modecount[mode]->Fill(neu->E()); // Fill total event hist eventhist->Fill(neu->E()); // Clear Event genientpl->Clear(); size_t freq = nevt / 20; if (freq && !(i % freq)) { NUIS_LOG(FIT, "Processed " << i << "/" << nevt << " GENIE events (E: " << neu->E() << " GeV, xsec: " << xsec << " E-38 cm^2/nucleon)"); } } NUIS_LOG(FIT, "Processed all events"); // Check if we need to correct MEC events before possibly deleting the TChain below bool MECcorrect = CheckConfig(std::string(tn->GetFile()->GetName())); TFile *outputfile; // If no output is specified just append to the file if (!gOutputFile.length()) { // Shut the chain; delete tn; outputfile = new TFile(first_file.c_str(), "UPDATE"); } else { outputfile = new TFile(gOutputFile.c_str(), "RECREATE"); outputfile->cd(); NUIS_LOG(FIT, "Cloning input vector to output file: " << gOutputFile); TTree *cloneTree = tn->CloneTree(-1, "fast"); cloneTree->SetDirectory(outputfile); cloneTree->Write(); if (useNOvAWeights){ NUIS_LOG(FIT, "Cloning input nova_wgts to output file: " << gOutputFile); // *********************************** // *********************************** // FUDGE FOR NOVA MINERVA WORKSHOP // Also check for the nova_wgts tree from Jeremy TChain *nova_chain = new TChain("nova_wgts"); nova_chain->AddFile(input.c_str()); TTree *nova_tree = nova_chain->GetTree(); if (!nova_tree) { NUIS_LOG(FIT, "Could not find nova_wgts tree in " << gOutputFile); } else { NUIS_LOG(FIT, "Found nova_wgts tree in " << gOutputFile); } if (nova_tree) { nova_tree->SetDirectory(outputfile); nova_tree->Write(); } } NUIS_LOG(FIT, "Done cloning tree."); } NUIS_LOG(FIT, "Getting splines in mono-energetic..."); // Save each of the reconstructed splines to file std::map modeavg; TDirectory *inddir = (TDirectory *)outputfile->Get("IndividualGENIESplines"); if (!inddir) inddir = (TDirectory *)outputfile->mkdir("IndividualGENIESplines"); // Loop over GENIE ID's and get MEC count int MECcount = 0; // Count up the number of MEC splines for (UInt_t i = 0; i < genieids.size(); i++) { if (genieids[i].find("MEC") != std::string::npos && genieids[i].find("[CC]") != std::string::npos) { MECcount++; } } inddir->cd(); for (UInt_t i = 0; i < genieids.size(); i++) { std::string mode = genieids[i]; modexsec[mode]->Write((mode + "_summed_xsec").c_str(), TObject::kOverwrite); modecount[mode]->Write((mode + "_summed_evt").c_str(), TObject::kOverwrite); // Form extra avg xsec map -> Reconstructed spline modeavg[mode] = (TH1D *)modexsec[mode]->Clone(); modeavg[mode]->GetYaxis()->SetTitle( "#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)"); modeavg[mode]->Divide(modecount[mode]); if (MECcorrect && mode.find("MEC") != std::string::npos && mode.find("[CC]") != std::string::npos) { NUIS_LOG(FIT, "Scaling spline " << mode << " by 1/" << MECcount << " because there are " << MECcount << " repeated Nieves 2p2h instances."); modeavg[mode]->Scale(1.0 / double(MECcount)); } modeavg[mode]->Write((mode + "_rec_spline").c_str(), TObject::kOverwrite); } TDirectory *targdir = (TDirectory *)outputfile->Get("TargetGENIESplines"); if (!targdir) targdir = (TDirectory *)outputfile->mkdir("TargetGENIESplines"); targdir->cd(); NUIS_LOG(FIT, "Getting Target Splines"); // For each target save a total spline std::map targetsplines; for (uint i = 0; i < targetids.size(); i++) { std::string targ = targetids[i]; NUIS_LOG(FIT, "Getting target " << i << ": " << targ); targetsplines[targ] = (TH1D *)xsechist->Clone(); targetsplines[targ]->GetYaxis()->SetTitle( "#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)"); NUIS_LOG(FIT, "Created target spline for " << targ); for (uint j = 0; j < genieids.size(); j++) { std::string mode = genieids[j]; if (mode.find(targ) != std::string::npos) { NUIS_LOG(FIT, " Mode " << mode << " contains " << targ << " target"); targetsplines[targ]->Add(modeavg[mode]); NUIS_LOG(FIT, "Finished with Mode " << mode << " " << modeavg[mode]->Integral()); } } NUIS_LOG(FIT, "Saving target spline:" << targ); targetsplines[targ]->Write(("Total_" + targ).c_str(), TObject::kOverwrite); } NUIS_LOG(FIT, "Getting total splines"); // Now we have each of the targets we need to create a total cross-section. int totalnucl = 0; // Get the targets specified by the user, separated by commas // This has structure target1[fraction1], target2[fraction2] std::vector targprs = GeneralUtils::ParseToStr(target, ","); std::vector targ_list; std::vector frac_list; // Chop up the target string which has format // TARGET1[fraction1],TARGET2[fraction2] // Loop over the vector of strings "TARGET1[fraction1]" "TARGET2[fraction2]" for (std::vector::iterator it = targprs.begin(); it != targprs.end(); ++it) { // Cut into "TARGET1" and "fraction1]" std::vector targind = GeneralUtils::ParseToStr(*it, "["); // Cut into "TARGET1" and "fraction1" for (std::vector::iterator jt = targind.begin(); jt != targind.end(); ++jt) { if ((*jt).find("]") != std::string::npos) { (*jt) = (*jt).substr(0, (*jt).find("]")); frac_list.push_back(*jt); // Won't find bracket for target } else { targ_list.push_back(*jt); } } } targprs = targ_list; std::vector targ_fractions; double minimum = 1.0; for (std::vector::iterator it = frac_list.begin(); it != frac_list.end(); it++) { double frac = std::atof((*it).c_str()); targ_fractions.push_back(frac); if (frac < minimum) minimum = frac; } std::vector::iterator it = targ_fractions.begin(); std::vector::iterator jt = targ_list.begin(); double scaling = 0; for (; it != targ_fractions.end(); it++, jt++) { // First get the mass number from the targ_list int nucl = atoi((*jt).c_str()); nucl = (nucl % 10000) / 10; // Gets the relative portions right *it = (*it) / minimum; // Scale relative the atomic mass double tempscaling = double(nucl) / (*it); if (tempscaling > scaling) scaling = tempscaling; } it = targ_fractions.begin(); for (; it != targ_fractions.end(); it++) { // Round the scaling to nearest integer and multiply *it *= int(scaling + 0.5); // Round to nearest integer *it = int(*it + 0.5); totalnucl += *it; } + // Report on what we've got + it = targ_fractions.begin(); + jt = targ_list.begin(); + for (; it != targ_fractions.end(); it++, jt++){ + NUIS_LOG(FIT, "Found target " << *jt << " with weight " << *it); + } + + if (totalnucl == 0) { NUIS_ABORT("Didn't find any nucleons in input file. Did you really specify the " "target ratios?\ne.g. TARGET1[fraction1],TARGET2[fraction2]"); } TH1D *totalxsec = (TH1D *)xsechist->Clone(); - for (uint i = 0; i < targprs.size(); i++) { + it = targ_fractions.begin(); + for (uint i = 0; i < targprs.size(); i++, it++) { std::string targpdg = targprs[i]; // Check that we found the user requested target in GENIE bool FoundTarget = false; for (std::map::iterator iter = targetsplines.begin(); iter != targetsplines.end(); iter++) { std::string targstr = iter->first; TH1D *xsec = iter->second; // Match the user targets to the targets found in GENIE if (targstr.find(targpdg) != std::string::npos) { FoundTarget = true; + + int nucl = atoi(targpdg.c_str()); + nucl = (nucl % 10000) / 10; + + NUIS_LOG(FIT, "Scaling target " << targstr << " by " << *it << "/" << nucl); + xsec->Scale(*it/double(nucl)); + NUIS_LOG(FIT, "Adding target spline " << targstr << " Integral = " << xsec->Integral("width")); totalxsec->Add(xsec); } } // Check that targets were all found if (!FoundTarget) { NUIS_ERR(WRN, "Didn't find target " << targpdg << " in the list of targets recorded by GENIE"); NUIS_ERR(WRN, " The list of targets you requested is: "); for (uint i = 0; i < targprs.size(); ++i) NUIS_ERR(WRN, " " << targprs[i]); NUIS_ERR(WRN, " The list of targets found in GENIE is: "); for (std::map::iterator iter = targetsplines.begin(); iter != targetsplines.end(); iter++) NUIS_ERR(WRN, " " << iter->first); } } outputfile->cd(); totalxsec->GetYaxis()->SetTitle( "#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/nucleon)"); totalxsec->Write("nuisance_xsec", TObject::kOverwrite); eventhist = (TH1D *)fluxhist->Clone(); eventhist->Multiply(totalxsec); eventhist->GetYaxis()->SetTitle( (std::string("Event rate (N = #sigma #times #Phi) #times 10^{-38} " "(cm^{2}/nucleon) #times ") + eventhist->GetYaxis()->GetTitle()) .c_str()); NUIS_LOG(FIT, "Dividing by Total Nucl = " << totalnucl); eventhist->Scale(1.0 / double(totalnucl)); eventhist->Write("nuisance_events", TObject::kOverwrite); fluxhist->Write("nuisance_flux", TObject::kOverwrite); NUIS_LOG(FIT, "Inclusive XSec Per Nucleon = " << eventhist->Integral("width") * 1E-38 / fluxhist->Integral("width")); NUIS_LOG(FIT, "XSec Hist Integral = " << totalxsec->Integral("width")); outputfile->Close(); return; } void RunGENIEPrepare(std::string input, std::string flux, std::string target, std::string output) { NUIS_LOG(FIT, "Running GENIE Prepare with flux..."); // Get Flux Hist std::vector fluxvect = GeneralUtils::ParseToStr(flux, ","); TH1 *fluxhist = NULL; if (fluxvect.size() == 3) { double from = GeneralUtils::StrToDbl(fluxvect[0]); double to = GeneralUtils::StrToDbl(fluxvect[1]); double step = GeneralUtils::StrToDbl(fluxvect[2]); int nstep = ceil((to - from) / step); to = from + step * nstep; NUIS_LOG(FIT, "Generating flat flux histogram from " << from << " to " << to << " with bins " << step << " wide (NBins = " << nstep << ")."); fluxhist = new TH1D("spectrum", ";E_{#nu} (GeV);Count (A.U.)", nstep, from, to); for (Int_t bi_it = 1; bi_it < fluxhist->GetXaxis()->GetNbins(); ++bi_it) { fluxhist->SetBinContent(bi_it, 1.0 / double(step * nstep)); } fluxhist->SetDirectory(0); } else if (fluxvect.size() == 2) { TFile *fluxfile = new TFile(fluxvect[0].c_str(), "READ"); if (!fluxfile->IsZombie()) { fluxhist = dynamic_cast(fluxfile->Get(fluxvect[1].c_str())); if (!fluxhist) { NUIS_ERR(FTL, "Couldn't find histogram named: \"" << fluxvect[1] << "\" in file: \"" << fluxvect[0]); throw; } fluxhist->SetDirectory(0); } } else if (fluxvect.size() == 1) { MonoEnergy = GeneralUtils::StrToDbl(fluxvect[0]); RunGENIEPrepareMono(input, target, output); return; } else { NUIS_LOG(FTL, "Bad flux specification: \"" << flux << "\"."); throw; } // Setup TTree TChain *tn = new TChain("gtree"); std::string first_file = ""; if (input.find_first_of(',') != std::string::npos) { std::vector inputvect = GeneralUtils::ParseToStr(input, ","); for (size_t iv_it = 0; iv_it < inputvect.size(); ++iv_it) { tn->AddFile(inputvect[iv_it].c_str()); NUIS_LOG(FIT, "Added input file: " << inputvect[iv_it]); if (!first_file.length()) { first_file = inputvect[iv_it]; } } } else { // The Add form can accept wildcards. tn->Add(input.c_str()); first_file = input; } if (tn->GetFile() == NULL) { tn->Print(); NUIS_ERR(FTL, "gtree not located in GENIE file: " << input); NUIS_ABORT("Check your inputs, they may need to be completely regenerated!"); throw; } int nevt = tn->GetEntries(); if (gNEvents != -999) { NUIS_LOG(FIT, "Overriding number of events by user from " << nevt << " to " << gNEvents); nevt = gNEvents; } if (!nevt) { NUIS_ABORT("Couldn't load any events from input specification: \"" << input.c_str() << "\""); } else { NUIS_LOG(FIT, "Found " << nevt << " input entries in " << input); } StopTalking(); NtpMCEventRecord *genientpl = NULL; tn->SetBranchAddress("gmcrec", &genientpl); StartTalking(); // Make Event and xsec Hist TH1D *eventhist = (TH1D *)fluxhist->Clone(); eventhist->SetDirectory(NULL); eventhist->Reset(); TH1D *xsechist = (TH1D *)eventhist->Clone(); xsechist->SetDirectory(NULL); // Create maps std::map modexsec; std::map modecount; std::vector genieids; std::vector targetids; std::vector interids; // Loop over all events for (int i = 0; i < nevt; i++) { tn->GetEntry(i); // Hussssch GENIE StopTalking(); // Get the event EventRecord &event = *(genientpl->event); // Get the neutrino GHepParticle *neu = event.Probe(); StartTalking(); // Get XSec From Spline // Get the GHepRecord GHepRecord genie_record = static_cast(event); double xsec = (genie_record.XSec() / (1E-38 * genie::units::cm2)); // Parse Interaction String std::string mode = genie_record.Summary()->AsString(); std::vector modevec = GeneralUtils::ParseToStr(mode, ";"); std::string targ = (modevec[0] + ";" + modevec[1]); std::string inter = mode; // Get target nucleus // Alternative ways of getting the summaries // GHepParticle *target = genie_record.TargetNucleus(); // int pdg = target->Pdg(); // Fill lists of Unique IDS (neutrino and target) if (std::find(targetids.begin(), targetids.end(), targ) == targetids.end()) { targetids.push_back(targ); } // The full interaction list if (std::find(interids.begin(), interids.end(), inter) == interids.end()) { interids.push_back(inter); } // Create entries Mode Maps if (modexsec.find(mode) == modexsec.end()) { genieids.push_back(mode); modexsec[mode] = (TH1D *)xsechist->Clone(); modecount[mode] = (TH1D *)xsechist->Clone(); modexsec[mode]->SetDirectory(NULL); modecount[mode]->SetDirectory(NULL); modexsec[mode]->GetYaxis()->SetTitle( "d#sigma/dE_{#nu} #times 10^{-38} (events weighted by #sigma)"); modecount[mode]->GetYaxis()->SetTitle("Number of events in file"); } // Fill XSec Histograms modexsec[mode]->Fill(neu->E(), xsec); modecount[mode]->Fill(neu->E()); // Fill total event hist eventhist->Fill(neu->E()); if (i % (nevt / 20) == 0) { NUIS_LOG(FIT, "Processed " << i << "/" << nevt << " GENIE events (E: " << neu->E() << " GeV, xsec: " << xsec << " E-38 cm^2/nucleon)"); } // Clear Event genientpl->Clear(); } NUIS_LOG(FIT, "Processed all events"); // Check if we need to correct MEC events before possibly deleting the TChain below bool MECcorrect = CheckConfig(std::string(tn->GetFile()->GetName())); // Once event loop is done we can start saving stuff into the file TFile *outputfile; if (!gOutputFile.length()) { // Shut the chain; delete tn; outputfile = new TFile(first_file.c_str(), "UPDATE"); } else { outputfile = new TFile(gOutputFile.c_str(), "RECREATE"); outputfile->cd(); NUIS_LOG(FIT, "Cloning input vector to output file: " << gOutputFile); TTree *cloneTree = tn->CloneTree(-1, "fast"); cloneTree->SetDirectory(outputfile); cloneTree->Write(); if (useNOvAWeights){ // ******************************** // CLUDGE KLUDGE KLUDGE FOR NOVA NUIS_LOG(FIT, "Cloning input nova_wgts to output file: " << gOutputFile); // Also check for the nova_wgts tree from Jeremy TChain *nova_chain = new TChain("nova_wgts"); nova_chain->AddFile(input.c_str()); TTree *nova_tree = nova_chain->CloneTree(-1, "fast"); if (!nova_tree) { NUIS_LOG(FIT, "Could not find nova_wgts tree in " << input); } else { NUIS_LOG(FIT, "Found nova_wgts tree in " << input); nova_tree->SetDirectory(outputfile); nova_tree->Write(); } } NUIS_LOG(FIT, "Done cloning tree."); } NUIS_LOG(FIT, "Getting splines..."); // Save each of the reconstructed splines to file std::map modeavg; TDirectory *inddir = (TDirectory *)outputfile->Get("IndividualGENIESplines"); if (!inddir) inddir = (TDirectory *)outputfile->mkdir("IndividualGENIESplines"); // Loop over GENIE ID's and get MEC count int MECcount = 0; for (UInt_t i = 0; i < genieids.size(); i++) { if (genieids[i].find("MEC") != std::string::npos && genieids[i].find("[CC]") != std::string::npos) { MECcount++; } } inddir->cd(); for (UInt_t i = 0; i < genieids.size(); i++) { std::string mode = genieids[i]; modexsec[mode]->Write((mode + "_summed_xsec").c_str(), TObject::kOverwrite); modecount[mode]->Write((mode + "_summed_evt").c_str(), TObject::kOverwrite); // Form extra avg xsec map -> Reconstructed spline modeavg[mode] = (TH1D *)modexsec[mode]->Clone(); modeavg[mode]->GetYaxis()->SetTitle( "#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)"); modeavg[mode]->Divide(modecount[mode]); if (MECcorrect && mode.find("MEC") != std::string::npos && mode.find("[CC]") != std::string::npos) { NUIS_LOG(FIT, "Scaling spline " << mode << " by 1/" << MECcount << " because there are " << MECcount << " repeated Nieves 2p2h instances."); modeavg[mode]->Scale(1.0 / double(MECcount)); } modeavg[mode]->Write((mode + "_rec_spline").c_str(), TObject::kOverwrite); } TDirectory *targdir = (TDirectory *)outputfile->Get("TargetGENIESplines"); if (!targdir) targdir = (TDirectory *)outputfile->mkdir("TargetGENIESplines"); targdir->cd(); NUIS_LOG(FIT, "Getting Target Splines"); // For each target save a total spline std::map targetsplines; for (uint i = 0; i < targetids.size(); i++) { std::string targ = targetids[i]; NUIS_LOG(FIT, "Getting target " << i << ": " << targ); targetsplines[targ] = (TH1D *)xsechist->Clone(); targetsplines[targ]->GetYaxis()->SetTitle( "#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/target)"); NUIS_LOG(FIT, "Created target spline for " << targ); for (uint j = 0; j < genieids.size(); j++) { std::string mode = genieids[j]; // Look at all matching modes/targets if (mode.find(targ) != std::string::npos) { NUIS_LOG(FIT, " Mode " << mode << " contains " << targ << " target"); targetsplines[targ]->Add(modeavg[mode]); NUIS_LOG(FIT, "Finished with Mode " << mode << " " << modeavg[mode]->Integral()); } } NUIS_LOG(FIT, "Saving target spline: " << targ); targetsplines[targ]->Write(("Total_" + targ).c_str(), TObject::kOverwrite); } NUIS_LOG(FIT, "Getting total splines"); // Now we have each of the targets we need to create a total cross-section. int totalnucl = 0; // This has structure target1[fraction1], target2[fraction2] std::vector targprs = GeneralUtils::ParseToStr(target, ","); std::vector targ_list; std::vector frac_list; // Chop up the target string which has format // TARGET1[fraction1],TARGET2[fraction2] // Loop over the vector of strings "TARGET1[fraction1]" "TARGET2[fraction2]" for (std::vector::iterator it = targprs.begin(); it != targprs.end(); ++it) { // Cut into "TARGET1" and "fraction1]" std::vector targind = GeneralUtils::ParseToStr(*it, "["); // Cut into "TARGET1" and "fraction1" for (std::vector::iterator jt = targind.begin(); jt != targind.end(); ++jt) { if ((*jt).find("]") != std::string::npos) { (*jt) = (*jt).substr(0, (*jt).find("]")); frac_list.push_back(*jt); // Won't find bracket for target } else { targ_list.push_back(*jt); } } } targprs = targ_list; std::vector targ_fractions; double minimum = 1.0; for (std::vector::iterator it = frac_list.begin(); it != frac_list.end(); it++) { double frac = std::atof((*it).c_str()); targ_fractions.push_back(frac); if (frac < minimum) minimum = frac; } std::vector::iterator it = targ_fractions.begin(); std::vector::iterator jt = targ_list.begin(); double scaling = 0; for (; it != targ_fractions.end(); it++, jt++) { // First get the mass number from the targ_list int nucl = atoi((*jt).c_str()); nucl = (nucl % 10000) / 10; // Gets the relative portions right *it = (*it) / minimum; // Scale relative the atomic mass //(*it) *= (double(nucl)/(*it)); double tempscaling = double(nucl) / (*it); if (tempscaling > scaling) scaling = tempscaling; } it = targ_fractions.begin(); for (; it != targ_fractions.end(); it++) { // Round the scaling to nearest integer and multiply *it *= int(scaling + 0.5); // Round to nearest integer *it = int(*it + 0.5); totalnucl += *it; } + // Report on what we've got + it = targ_fractions.begin(); + jt = targ_list.begin(); + for (; it != targ_fractions.end(); it++, jt++){ + NUIS_LOG(FIT, "Found target " << *jt << " with weight " << *it); + } + if (totalnucl == 0) { NUIS_ABORT("Didn't find any nucleons in input file. Did you really specify the " "target ratios?\ne.g. TARGET1[fraction1],TARGET2[fraction2]"); } TH1D *totalxsec = (TH1D *)xsechist->Clone(); // Loop over the specified targets by the user - for (uint i = 0; i < targprs.size(); i++) { + it = targ_fractions.begin(); + for (uint i = 0; i < targprs.size(); i++, it++) { std::string targpdg = targprs[i]; // Check that we found the user requested target in GENIE bool FoundTarget = false; for (std::map::iterator iter = targetsplines.begin(); iter != targetsplines.end(); iter++) { std::string targstr = iter->first; TH1D *xsec = iter->second; // Match the user targets to the targets found in GENIE if (targstr.find(targpdg) != std::string::npos) { FoundTarget = true; + + int nucl = atoi(targpdg.c_str()); + nucl = (nucl % 10000) / 10; + + NUIS_LOG(FIT, "Scaling target " << targstr << " by " << *it << "/" << nucl); + xsec->Scale(*it/double(nucl)); + NUIS_LOG(FIT, "Adding target spline " << targstr << " Integral = " << xsec->Integral("width")); totalxsec->Add(xsec); - - // int nucl = atoi(targpdg.c_str()); - // totalnucl += int((nucl % 10000) / 10); } } // Looped over target splines // Check that targets were all found if (!FoundTarget) { NUIS_ERR(WRN, "Didn't find target " << targpdg << " in the list of targets recorded by GENIE"); NUIS_ERR(WRN, " The list of targets you requested is: "); for (uint i = 0; i < targprs.size(); ++i) NUIS_ERR(WRN, " " << targprs[i]); NUIS_ERR(WRN, " The list of targets found in GENIE is: "); for (std::map::iterator iter = targetsplines.begin(); iter != targetsplines.end(); iter++) NUIS_ERR(WRN, " " << iter->first); } } outputfile->cd(); totalxsec->GetYaxis()->SetTitle( "#sigma (E_{#nu}) #times 10^{-38} (cm^{2}/nucleon)"); totalxsec->Write("nuisance_xsec", TObject::kOverwrite); eventhist = (TH1D *)fluxhist->Clone(); eventhist->Multiply(totalxsec); eventhist->GetYaxis()->SetTitle( (std::string("Event rate (N = #sigma #times #Phi) #times 10^{-38} " "(cm^{2}/nucleon) #times ") + eventhist->GetYaxis()->GetTitle()) .c_str()); NUIS_LOG(FIT, "Dividing by Total Nucl = " << totalnucl); eventhist->Scale(1.0 / double(totalnucl)); eventhist->Write("nuisance_events", TObject::kOverwrite); fluxhist->Write("nuisance_flux", TObject::kOverwrite); NUIS_LOG(FIT, "Inclusive XSec Per Nucleon = " << eventhist->Integral("width") * 1E-38 / fluxhist->Integral("width")); NUIS_LOG(FIT, "XSec Hist Integral = " << totalxsec->Integral()); outputfile->Close(); return; }; void PrintOptions() { std::cout << "PrepareGENIE events NUISANCE app. " << std::endl << "Takes GHep Outputs and prepares events for NUISANCE." << std::endl << std::endl << "PrepareGENIE [-h,-help,--h,--help] [-i " "inputfile1.root,inputfile2.root,inputfile3.root,...] " << "[-f flux_root_file.root,flux_hist_name] [-t " "target1[frac1],target2[frac2],...]" << "[-n number_of_events (experimental)]" << std::endl << std::endl; std::cout << "Prepare Mode [Default] : Takes a single GHep file, " "reconstructs the original GENIE splines, " << " and creates a duplicate file that also contains the flux, " "event rate, and xsec predictions that NUISANCE needs. " << std::endl; std::cout << "Following options are required for Prepare Mode:" << std::endl; std::cout << " [ -i inputfile.root ] : Reads in a single GHep input file " "that needs the xsec calculation ran on it. " << std::endl; std::cout << " [ -f flux_file.root,hist_name ] : Path to root file " "containing the flux histogram the GHep records were generated " "with." << " A simple method is to point this to the flux histogram genie " "generatrs '-f /path/to/events/input-flux.root,spectrum'. " << std::endl; std::cout << " [ -f elow,ehigh,estep ] : Energy range specification when no " "flux file was used." << std::endl; std::cout << " [ -t target ] : Target that GHepRecords were generated with. " "Comma separated list with fractions. E.g. for CH2 " "target=1000060120[0.923076],1000010010[0.076924]" << std::endl; std::cout << " [ -o outputfile.root ] : File to write prepared input file to." << std::endl; std::cout << " [ -m Mono_E_nu_GeV ] : Run in mono-energetic mode with m GeV " "neutrino energy." << std::endl; std::cout << " [ -n number_of_evt ] : Run with a reduced number of events " "for debugging purposes" << std::endl; } void ParseOptions(int argc, char *argv[]) { bool flagopt = false; int verbocount = 0; int errorcount = 0; verbocount += Config::GetParI("VERBOSITY"); errorcount += Config::GetParI("ERROR"); bool trace = Config::GetParB("TRACE"); std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; SETVERBOSITY(verbocount); SETTRACE(trace); // If No Arguments print commands for (int i = 1; i < argc; ++i) { if (!std::strcmp(argv[i], "-h")) { flagopt = true; break; } if (i + 1 != argc) { // Cardfile if (!std::strcmp(argv[i], "-h")) { flagopt = true; break; } else if (!std::strcmp(argv[i], "-i")) { gInputFiles = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-o")) { gOutputFile = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-f")) { gFluxFile = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-t")) { gTarget = argv[i + 1]; ++i; } else if (!std::strcmp(argv[i], "-n")) { gNEvents = GeneralUtils::StrToInt(argv[i + 1]); ++i; } else if (!std::strcmp(argv[i], "-m")) { MonoEnergy = GeneralUtils::StrToDbl(argv[i + 1]); IsMonoE = true; ++i; } else { NUIS_ERR(FTL, "ERROR: unknown command line option given! - '" << argv[i] << " " << argv[i + 1] << "'"); PrintOptions(); break; } } } if (gInputFiles == "" && !flagopt) { NUIS_ERR(FTL, "No input file(s) specified!"); flagopt = true; } if (gFluxFile == "" && !flagopt && !IsMonoE) { NUIS_ERR(FTL, "No flux input specified for Prepare Mode"); flagopt = true; } if (gTarget == "" && !flagopt) { NUIS_ERR(FTL, "No target specified for Prepare Mode"); flagopt = true; } if (gTarget.find("[") == std::string::npos || gTarget.find("]") == std::string::npos) { NUIS_ERR(FTL, "Didn't specify target ratios in Prepare Mode"); NUIS_ERR(FTL, "Are you sure you gave it as -t " "\"TARGET1[fraction1],TARGET2[fraction]\"?"); flagopt = true; } if (argc < 1 || flagopt) { PrintOptions(); exit(-1); } return; } diff --git a/app/nuisbayes.cxx b/app/nuisbayes.cxx index 98c9c3f..08429ad 100644 --- a/app/nuisbayes.cxx +++ b/app/nuisbayes.cxx @@ -1,68 +1,68 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // Author: Patrick Stowell 09/2016 /* Usage: ./nuissyst -c card file -o output file, where the results of the throws are stored where: */ #include "BayesianRoutines.h" //******************************* void printInputCommands(){ //******************************* exit(-1); }; //******************************* int main(int argc, char* argv[]){ //******************************* // Program status; int status = 0; // 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; } // Read input arguments such as card file, parameter arguments, and fit routines NUIS_LOG(FIT,"Starting nuissyst"); // Make systematic class and run fit BayesianRoutines* min = new BayesianRoutines(argc, argv); min->Run(); // Show Final Status NUIS_LOG(FIT,"-------------------------------------"); NUIS_LOG(FIT,"FINISHED"); NUIS_LOG(FIT,"-------------------------------------"); return status; } diff --git a/app/nuiscomp.cxx b/app/nuiscomp.cxx index b04cef7..653d464 100644 --- a/app/nuiscomp.cxx +++ b/app/nuiscomp.cxx @@ -1,293 +1,293 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ComparisonRoutines.h" //******************************* void printInputCommands() { //******************************* std::cout << "nuiscomp : NUISANCE Data Comparison App \n" << std::endl; std::cout << "# Running nuiscomp with a card file #\n" << "######################################\n" << "nuiscomp -c cardfile.xml [ -o outputfile.root ] [ -f routines ] [ " "-n maxevents ] \n" << " [ -i 'cardstructure' ] [ -d fakedata ] [ -q config=val ] [ " "+e/-e ] [ +v/-v ] \n" << "\n" << "# Running nuiscomp with structures at cmd line #\n" << "################################################\n" << "nuiscomp -i 'cardstructure' -o outputfile.root [ -c cardfile.xml [ " "-f routines ] [ -n maxevents ] \n" << " [ -d fakedata ] [ -q config=val ] [ +e/-e ] [ +v/-v ] \n" << std::endl; sleep(4); std::cout << "" << "\n" << " \n" << " -c cardfile.xml : NUISANCE format card file defining " "comparisons. \n" << " \n" << " -o outputfile.root : Output file that histograms will be " "saved in. If a card file is \n" << " given but no output file this will " "default to cardfile.xml.root \n" << " \n" << " -f routines : Comma separated list of comparison " "routines to run in order. \n" << " Allowed Routines : " " \n" << " Compare : Fixed comparison at " "nominal dial values. \n" << " \n" << " -n maxevents : Set limit on the number of event " "entries to process. \n" << " \n" << " -i \'cardstructure\' : Define card structure like those " "available in the standard NUISANCE \n" << " card format, but on the command line " "at runtime. MUST be enclosed \n" << " in single quotation marks. See " "examples below for usage. \n" << " \n" << " It is possible to entirely define " "the comparison using \' -i\' commands \n" << " without the need to write a card " "file explicitly. If you do this, \n" << " make sure to also use the \' -o\' " "flag to tell it where to go. \n" << " \n" << " -d fakedata : Define a fake data set to be used. " "All data in NUISANCE will be set \n" << " to the values defined in this fake " "data before comparisons are made. \n" << " \n" << " There are two possible methods. Fake " "data from MC or a previous file.\n" << " fakedata = \'MC\' : Sets the MC to " "the values defined by \'fake_parameters\' \n" << " shown in the " "examples below, and then sets the data \n" << " to be equal to " "this MC prediction. \n" << " fakedata = \'file.root\' : Reads in " "the ROOT file at the specified path \n" << " assuming " "its a standard NUISANCE file. Takes \n" << " MC " "predictions in this file and uses them as \n" << " fake data. " "\n" << " \n" << " -q config=val : Overrides default configurations " "provided in the cardfile and in \n" << " '$NUISANCE/parameters/config.xml\'. " "Any config parameter can be set. \n" << " Examples : \n" << " \'-q VERBOSITY=4\' \n" << " \'-q EventManager=1\' \n" << " \'-q drawOpts=DATA/MC\' \n" << " \n" << " +e/-e : Increase/Decrease the default error " "verbosity by 1. \n" << " \n" << " +v/-v : Increase/Decrease the default " "logging verbosity by 1.\n" << " \n\n" << std::endl; sleep(4); std::cout << "# nuiscomp Running Examples #" << "############################# \n" << " \n" << " 1. Generate cardfile comparisons with increased verbosity and only " "50000 events \n\n" << " nuiscomp -c cardfile.card -o mycomp.root -n 50000 +v +v \n" << " \n\n" << " 2. Generate a comparison to MiniBooNE data using simple structure, " "saving it to outfile.root \n\n" << " nuiscomp -o outfile.root -i \'sample " "MiniBooNE_CCQE_XSec_1DQ2_nu NEUT:neutevents.root\' \n" << " \n\n" << " 3. Generate a comparison to MiniBooNE data using xml structure, " "reweight MaCCQE, and save the prediction to outfile.root \n\n" << " nuiscomp -o outfile.root -i \'sample " "name=\"MiniBooNE_CCQE_XSec_1DQ2_nu\" " "input=\"NEUT:neutevents.root\"\' \\ \n" << " -i \'sample " "name=\"MiniBooNE_CC1pip_XSec_1DQ2_nu\" " "input=\"NEUT:neutevents.root\"\' \\ \n" << " -i \'parameter name=\"MaCCQE\" " "nominal=\"1.0\" type=\"neut_parameter\"\' \n " << " \n\n" << " 4. Generate a comparison, using fake data from the MC predictions " "inside the fakedata.root \n\n" << " nuiscomp -c cardfile.card -o myfakecomp.root -d fakedata.root " "\n" << " \n\n" << " 5. Generate a comparison using fake data defined on the command " "line use fake parameters \n\n" << " nuiscomp -c cardfile.card -d MC -i \'fakeparameter " "name=\"MaCCQE\" nominal=\"1.0\"\' \n " << " -i \'parameter name=\"MaCCQE\" " "nominal=\"1.0\" type=\"neut_parameter\"' " << " \n\n" << std::endl; sleep(4); std::cout << "# NUISANCE Card Format Structure Examples # \n" << "########################################### \n" << "\n" << "The NUISANCE card can be defined as a simple text file, or an " "xml file. \n" << "Examples for both with relevant structures are given below. \n" << std::endl; std::cout << "# XML Card File Example # \n" << "cardfile.xml: \n" << "" << "\n" << " \n" << " \n" << " \n" << "\n" << " \n" << " " "\n" << " \n" << " \n" << " \n" << " \n" << " \n" << "\n" << " \n" << " \n" << "\n" << "\n" << " \n" << " \n" << " \n" << " \n" << " \n" << "\n" << " \n" << "\n" << " \n" << " \n" << " \n" << " \n" << " \n" << "\n" << " \n" << "\n" << " \n\n" << std::endl; std::cout << "# Simple Card File Example # \n" << "cardfile.card: \n" << "\n" << "# CONFIG STRUCTURE \n" << "# config name val \n" << "config VERBOSITY 4 \n" << "\n" << "# Sample Structure \n" << "# ID Corresponds to names given in src/FCN/SampleList.cxx \n" << "# TYPE is the generator type (NEUT,NUWRO,GENIE,GIBUU). \n" << "# FILE is the input generator events file. \n" << "# TYPE is optional and used to define options for a class. e.g. FREE " " \n" << "# NORM is optional and sets sample normalisations. \n" << "# sample ID TYPE:FILE TYPE 1.0 \n" << "\n" << "sample MiniBooNE_CCQE_XSec_1DQ2_nu GENIE:genieevents.root \n" << "sample MiniBooNE_CC1pip_XSec_1DQ2_nu GENIE:genieevents.root SHAPE \n" << "\n" << "\n" << "# Parameter Structure \n" << "# ID is the name of the dial in each generator RW engine \n" << "# TYPE is the dial type (neut,newer,genie,niwg,t2k,custom,norm) \n" << "# VAL is the nominal value in 1-sigma variation for the comparison \n" << "# TYPE_parameter ID VAL \n" << "\n" << "neut_parameter MaCCQE 0.5 \n" << "\n" << "# Fake Parameter Structure \n" << "# Sets values for fake data defined using the ‘MC’ flag. \n" << "# ID is the dial name, it MUST be specified before hand using a " "normal parameter structure \n" << "# VAL is the value to use for the fake data \n" << "# fake_parameter ID VAL \n" << "\n" << "fake_parameter MaCCQE 1.0 \n" << "\n" << std::endl; exit(-1); }; //******************************* int main(int argc, char *argv[]) { //******************************* // Program status; int status = 0; // 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; } // Read input arguments such as card file, parameter arguments, and fit // routines - NUIS_LOG(FIT, "Starting nuiscomp.exe"); + std::cout << "[ NUISANCE ]: Starting nuiscomp.exe" << std::endl; // Make minimizer class and run fit ComparisonRoutines *comp = new ComparisonRoutines(argc, argv); comp->Run(); delete comp; // Show Final Status NUIS_LOG(FIT, "------------------------------------ -"); NUIS_LOG(FIT, "Comparison Complete."); NUIS_LOG(FIT, "------------------------------------ -"); return status; } diff --git a/app/nuisflat.cxx b/app/nuisflat.cxx index 25fa4ed..118da93 100644 --- a/app/nuisflat.cxx +++ b/app/nuisflat.cxx @@ -1,391 +1,401 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ComparisonRoutines.h" #include "GenericFlux_Tester.h" #include "GenericFlux_Vectors.h" #include "InputUtils.h" #include "MeasurementBase.h" #include "Smearceptance_Tester.h" // Global Arguments std::string gOptInputFile = ""; std::string gOptFormat = ""; std::string gOptOutputFile = ""; std::string gOptType = "DEFAULT"; std::string gOptNumberEvents = "NULL"; std::string gOptCardInput = ""; std::string gOptOptions = ""; // Input Dial Vals std::vector fParams; ///< Vector of dial names. std::map fStateVals; ///< Map of dial states std::map fCurVals; ///< Map of dial values std::map fTypeVals; ///< Map of dial type enums. // Fake Dial Vals std::map fFakeVals; ///< Map of fake data settings. void SetupComparisonsFromXML(); void SetupRWEngine(); //******************************* void PrintSyntax() { //******************************* std::cout << "nuisflat -i input [-f format] [-o outfile] [-n nevents] [-t " "options] [-q con=val] \n"; std::cout << "\n Arguments : " << "\n\t -i input : Path to input vector of events to flatten" << "\n\t" << "\n\t This should be given in the same format a normal " "input file" << "\n\t is given to NUISANCE. {e.g. NUWRO:eventsout.root}." << "\n\t" << "\n\t -f format : FlatTree format to output. If none given " "GenericVectors used." << "\n\t\t GenericFlux : Flat event summary format." << "\n\t\t GenericVectors : Standard event summary format with " "particle vectors." << "\n\t " << "\n\t[-c crd.xml]: Input card file to override configs or set dial " "values." << "\n\t " << "\n\t[-o outfile]: Optional output file path. " << "\n\t " << "\n\t If none given, input.format.root is chosen." << "\n\t" << "\n\t[-n nevents]: Optional choice of Nevents to run over. Default is " "all." << "\n\t" << "\n\t[-t options]: Pass OPTION to the FlatTree sample. " << "\n\t Similar to type field in comparison xml configs." << "\n\t" << "\n\t[-q con=val]: Configuration overrides." << std::endl; exit(-1); }; //____________________________________________________________________________ void GetCommandLineArgs(int argc, char **argv) { // Check for -h flag. for (int i = 0; i < argc; i++) { if ((!std::string(argv[i]).compare("-h")) || (!std::string(argv[i]).compare("-?")) || (!std::string(argv[i]).compare("--help"))) PrintSyntax(); } // Format is nuwro -r run_number -n n events std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); // Parse input file ParserUtils::ParseArgument(args, "-i", gOptInputFile, false); if (gOptInputFile == "") { NUIS_ABORT("Need to provide a valid input file to nuisflat using -i flag!"); } else { NUIS_LOG(FIT, "Reading Input File = " << gOptInputFile); } // Get Output Format ParserUtils::ParseArgument(args, "-f", gOptFormat, false); if (gOptFormat == "") { gOptFormat = "GenericVectors"; NUIS_LOG(FIT, "Saving flattree in default format = " << gOptFormat); } else { NUIS_LOG(FIT, "Saving flattree in format = " << gOptFormat); } // Get Output File ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false); if (gOptOutputFile == "") { gOptOutputFile = gOptInputFile + "." + gOptFormat + ".root"; NUIS_LOG(FIT, "No output file given so saving nuisflat output to:" << gOptOutputFile); } else { NUIS_LOG(FIT, "Saving nuisflat output to " << gOptOutputFile); } // Get N Events and Configs nuisconfig configuration = Config::Get(); ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false); if (gOptNumberEvents.compare("NULL")) { configuration.OverrideConfig("MAXEVENTS=" + gOptNumberEvents); } std::vector configargs; ParserUtils::ParseArgument(args, "-q", configargs); for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } ParserUtils::ParseArgument(args, "-c", gOptCardInput, false); if (gOptCardInput != "") { NUIS_LOG(FIT, "Reading cardfile: " << gOptCardInput); configuration.LoadSettings(gOptCardInput, ""); } ParserUtils::ParseArgument(args, "-t", gOptOptions, false); if (gOptOptions != "") { NUIS_LOG(FIT, "Read options: \"" << gOptOptions << "\'"); } return; } //******************************* int main(int argc, char *argv[]) { //******************************* // Parse GetCommandLineArgs(argc, argv); + int verbocount = 0; + int errorcount = 0; + verbocount += Config::GetParI("VERBOSITY"); + errorcount += Config::GetParI("ERROR"); + bool trace = Config::GetParB("TRACE"); + std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; + std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; + SETVERBOSITY(verbocount); + SETTRACE(trace); + // Make output file TFile *f = new TFile(gOptOutputFile.c_str(), "RECREATE"); if (f->IsZombie()) { NUIS_ABORT("Cannot create output file!"); } f->cd(); FitPar::Config().out = f; // Create a new measurementbase class depending on the Format MeasurementBase *flattreecreator = NULL; SetupComparisonsFromXML(); SetupRWEngine(); // SetupFCN(); // Make a new sample key for the format of interest. nuiskey samplekey = Config::CreateKey("sample"); if (!gOptFormat.compare("GenericFlux")) { samplekey.Set("name", "FlatTree"); samplekey.Set("input", gOptInputFile); samplekey.Set("type", gOptType); flattreecreator = new GenericFlux_Tester("FlatTree", gOptInputFile, FitBase::GetRW(), gOptType, ""); } else if (!gOptFormat.compare("GenericVectors")) { samplekey.Set("name", "FlatTree"); samplekey.Set("input", gOptInputFile); samplekey.Set("type", gOptType); flattreecreator = new GenericFlux_Vectors("FlatTree", gOptInputFile, FitBase::GetRW(), gOptType, ""); } else { NUIS_ERR(FTL, "Unknown FlatTree format!"); } // Make the FlatTree reconfigure flattreecreator->Reconfigure(); f->cd(); flattreecreator->Write(); f->Close(); // Show Final Status NUIS_LOG(FIT, "-------------------------------------"); NUIS_LOG(FIT, "Flattree Generation Complete."); NUIS_LOG(FIT, "-------------------------------------"); return 0; } //************************************* void SetupComparisonsFromXML() { //************************************* NUIS_LOG(FIT, "Setting up nuiscomp"); // Setup Parameters ------------------------------------------ std::vector parkeys = Config::QueryKeys("parameter"); if (!parkeys.empty()) { NUIS_LOG(FIT, "Number of parameters : " << parkeys.size()); } for (size_t i = 0; i < parkeys.size(); i++) { nuiskey key = parkeys.at(i); // Check for type,name,nom if (!key.Has("type")) { NUIS_ERR(FTL, "No type given for parameter " << i); NUIS_ERR(FTL, "type='PARAMETER_TYPE'"); throw; } else if (!key.Has("name")) { NUIS_ERR(FTL, "No name given for parameter " << i); NUIS_ERR(FTL, "name='SAMPLE_NAME'"); throw; } else if (!key.Has("nominal")) { NUIS_ERR(FTL, "No nominal given for parameter " << i); NUIS_ERR(FTL, "nominal='NOMINAL_VALUE'"); throw; } // Get Inputs std::string partype = key.GetS("type"); std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); double parlow = parnom - 1; double parhigh = parnom + 1; double parstep = 1; // override if state not given if (!key.Has("state")) { key.SetS("state", "FIX"); } std::string parstate = key.GetS("state"); // Check for incomplete limtis int limdef = ((int)key.Has("low") + (int)key.Has("high") + (int)key.Has("step")); if (limdef > 0 and limdef < 3) { NUIS_ERR(FTL, "Incomplete limit set given for parameter : " << parname); NUIS_ERR( FTL, "Requires: low='LOWER_LIMIT' high='UPPER_LIMIT' step='STEP_SIZE' "); throw; } // Extra limits if (key.Has("low")) { parlow = key.GetD("low"); parhigh = key.GetD("high"); parstep = key.GetD("step"); NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parlow << " < p < " << parhigh << " : " << parstate); } else { NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parstate); } // Convert if required if (parstate.find("ABS") != std::string::npos) { parnom = FitBase::RWAbsToSigma(partype, parname, parnom); parlow = FitBase::RWAbsToSigma(partype, parname, parlow); parhigh = FitBase::RWAbsToSigma(partype, parname, parhigh); parstep = FitBase::RWAbsToSigma(partype, parname, parstep); } else if (parstate.find("FRAC") != std::string::npos) { parnom = FitBase::RWFracToSigma(partype, parname, parnom); parlow = FitBase::RWFracToSigma(partype, parname, parlow); parhigh = FitBase::RWFracToSigma(partype, parname, parhigh); parstep = FitBase::RWFracToSigma(partype, parname, parstep); } // Push into vectors fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); ; fCurVals[parname] = parnom; fStateVals[parname] = parstate; } // Setup Samples ---------------------------------------------- std::vector samplekeys = Config::QueryKeys("sample"); if (!samplekeys.empty()) { NUIS_LOG(FIT,"Number of samples : " << samplekeys.size()); } for (size_t i = 0; i < samplekeys.size(); i++) { nuiskey key = samplekeys.at(i); // Get Sample Options std::string samplename = key.GetS("name"); std::string samplefile = key.GetS("input"); std::string sampletype = key.Has("type") ? key.GetS("type") : "DEFAULT"; double samplenorm = key.Has("norm") ? key.GetD("norm") : 1.0; // Print out NUIS_LOG(FIT, "Read Sample " << i << ". : " << samplename << " (" << sampletype << ") [Norm=" << samplenorm << "]" << std::endl << " -> input='" << samplefile << "'"); // If FREE add to parameters otherwise continue if (sampletype.find("FREE") == std::string::npos) { continue; } // Form norm dial from samplename + sampletype + "_norm"; std::string normname = samplename + "_norm"; // Check normname not already present if (fTypeVals.find("normname") != fTypeVals.end()) { continue; } // Add new norm dial to list if its passed above checks fParams.push_back(normname); fTypeVals[normname] = kNORM; fStateVals[normname] = sampletype; fCurVals[normname] = samplenorm; } // Setup Fake Parameters ----------------------------- std::vector fakekeys = Config::QueryKeys("fakeparameter"); if (!fakekeys.empty()) { NUIS_LOG(FIT,"Number of fake parameters : " << fakekeys.size()); } for (size_t i = 0; i < fakekeys.size(); i++) { nuiskey key = fakekeys.at(i); // Check for type,name,nom if (!key.Has("name")) { NUIS_ERR(FTL, "No name given for fakeparameter " << i); throw; } else if (!key.Has("nominal")) { NUIS_ERR(FTL, "No nominal given for fakeparameter " << i); throw; } // Get Inputs std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); // Push into vectors fFakeVals[parname] = parnom; } } //************************************* void SetupRWEngine() { //************************************* NUIS_LOG(FIT,"Setting up FitWeight Engine"); for (UInt_t i = 0; i < fParams.size(); i++) { std::string name = fParams[i]; FitBase::GetRW()->IncludeDial(name, fTypeVals.at(name)); } for (UInt_t i = 0; i < fParams.size(); i++) { std::string name = fParams[i]; if (fCurVals.find(name) == fCurVals.end()) continue; FitBase::GetRW()->SetDialValue(name, fCurVals.at(name)); } FitBase::GetRW()->Reconfigure(); return; } diff --git a/app/nuismin.cxx b/app/nuismin.cxx index 0d1eb14..ec47e63 100644 --- a/app/nuismin.cxx +++ b/app/nuismin.cxx @@ -1,141 +1,141 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // Author: Callum Wilkinson 01/2014 // Patrick Stowell 09/2015 /** Usage: ./GSLminimizerWithReWeight.exe -c card file, where samples and parameters are defined -o output file, where the results of the fit are stored where: */ #include "MinimizerRoutines.h" //******************************* void printInputCommands() { //******************************* std::cout - << "ExtFit_minimizer.exe -c cardFile -o outFile [-f fitStategy] [-d " + << "nuismin -c cardFile -o outFile [-f fitStategy] [-d " "fakeDataFile] [-i inputFile] [-q config_name=config_val] \n"; std::cout << std::endl; std::cout << "Arguments:" << std::endl; std::cout << " -c cardFile: Path to card file that defines fit " "samples, free parameters, and config overrides \n"; std::cout << " -o outFile: Path to root file that will be created to " "save output file.\n"; std::cout << " To turn automatically overwrite outFile if " "one exists turn off use 'config overwrite_output 1'\n"; std::cout << " To automatically use previous outFile as " "an inputFile if it exists so that the fit can be continued\n"; std::cout << " use the flag 'config use_previous_output " "1'. (A warning will be printed when doing this). \n"; std::cout << " -f fitStategy: Pass a comma separated list of fit " "routines to run in order. Default is Migrad,FixAtLim \n"; std::cout << " Possible Options: \n"; std::cout << " 1. Migrad - Minuit2 Migrad Minimizer \n"; std::cout << " 2. Simplex - Simplex Minimizer \n"; std::cout << " 3. Scan - Brute force scan of parameter " "space \n"; std::cout << " 4. FixAtLim - Takes any free parameters " "close to a limit and fixes them \n"; std::cout << " 5. Scan1D - Make 1D Scans and save them " "in a folder \n"; std::cout << " 6. Contours - Make Contour Scans \n"; std::cout << " 7. Save - Will save the state of the " "fitter (Always done by default at the end) \n"; std::cout << " Extra option LowStatFit will perform " "each of these options with a lower number \n"; std::cout << " of fit events (config lowstat). Example: " "LowStatMigrad, LowStatScan \n"; std::cout << " -d fakeDataFile: Uses the MC generated from a previous " "fit as a fake data set for these fits \n"; std::cout << " Can also specify MC to set the fake-data " "to the Monte-Carlo prediction\n"; std::cout << " In this case, you can specify " "fake_parameter PARAM_NAME PARAM_VALUE in the card\n"; std::cout << " to reweight the MC parameter " "PARAM_NAME to some PARAM_VALUE. The minimiser will start\n"; std::cout << " at whatever neut_parameter or " "genie_parameter is set to in the cardfile.\n"; std::cout << " -i inputFile: Uses the results from a previous fit file " "as starting input for these fits \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"; exit(-1); }; //******************************* int main(int argc, char *argv[]) { //******************************* // Program status; int status = 0; // 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; } // Read input arguments such as card file, parameter arguments, and fit // routines - NUIS_LOG(FIT, "Starting ExtFit_minimizer.exe"); + NUIS_LOG(FIT, "Starting nuismin"); // Make minimizer class and run fit MinimizerRoutines *min = new MinimizerRoutines(argc, argv); // Save Starting States if (FitPar::Config().GetParB("savenominal")) min->SaveNominal(); if (FitPar::Config().GetParB("saveprefit")) min->SavePrefit(); // Run the fit routines min->Run(); // Save by default min->SaveResults(); // Get Status status = min->GetStatus(); // Show Final Status NUIS_LOG(FIT, "-------------------------------------"); if (status == 0) { NUIS_LOG(FIT, "Minimizer Complete."); } else { NUIS_ERR(WRN, "Minimizer Failed (error state = " << status << ")"); } NUIS_LOG(FIT, "-------------------------------------"); return status; } diff --git a/app/nuissmear.cxx b/app/nuissmear.cxx index d085fbe..48a6752 100644 --- a/app/nuissmear.cxx +++ b/app/nuissmear.cxx @@ -1,218 +1,218 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ComparisonRoutines.h" #include "InputUtils.h" #include "Smearceptance_Tester.h" // Global Arguments std::string gOptInputFile = ""; std::string gOptOutputFile = ""; std::string gOptType = "DEFAULT"; std::string gOptNumberEvents = "NULL"; std::string gOptCardInput = ""; std::string gOptOptions = ""; //******************************* void PrintSyntax() { //******************************* std::cout << "nuisflat -i input [-o outfile] [-n nevents] [-t " "options] [-q con=val] \n"; std::cout << "\n Arguments : " << "\n\t -i input : Path to input vector of events to flatten" << "\n\t" << "\n\t This should be given in the same format a normal " "input file" << "\n\t is given to NUISANCE. {e.g. NUWRO:eventsout.root}." << "\n\t" << "\n\t[-c crd.xml]: Input card file to override configs or define " "smearcepters." << "\n\t " << "\n\t[-o outfile]: Optional output file path. " << "\n\t " << "\n\t If none given, input.smear.root is chosen." << "\n\t" << "\n\t[-n nevents]: Optional choice of Nevents to run over. Default is " "all." << "\n\t" << "\n\t[-t options]: Pass OPTION to the smearception sample. " << "\n\t Similar to type field in comparison xml configs." << "\n\t" << "\n\t[-q con=val]: Configuration overrides." << std::endl; exit(-1); }; //____________________________________________________________________________ void GetCommandLineArgs(int argc, char **argv) { // Check for -h flag. for (int i = 0; i < argc; i++) { if ((!std::string(argv[i]).compare("-h")) || (!std::string(argv[i]).compare("-?")) || (!std::string(argv[i]).compare("--help"))) PrintSyntax(); } // Format is nuwro -r run_number -n n events std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); // Parse input file ParserUtils::ParseArgument(args, "-i", gOptInputFile, false); if (gOptInputFile == "") { NUIS_ABORT("Need to provide a valid input file to nuisflat using -i flag!"); } else { NUIS_LOG(FIT, "Reading Input File = " << gOptInputFile); gOptInputFile = InputUtils::PrependGuessedInputTypeToName(gOptInputFile); } // Get Output File ParserUtils::ParseArgument(args, "-o", gOptOutputFile, false); if (gOptOutputFile == "") { gOptOutputFile = gOptInputFile + ".smear.root"; NUIS_LOG(FIT, "No output file given so saving nuisflat output to:" << gOptOutputFile); } else { NUIS_LOG(FIT, "Saving nuisflat output to " << gOptOutputFile); } // Get N Events and Configs nuisconfig configuration = Config::Get(); ParserUtils::ParseArgument(args, "-n", gOptNumberEvents, false); if (gOptNumberEvents.compare("NULL")) { configuration.OverrideConfig("MAXEVENTS=" + gOptNumberEvents); } std::vector configargs; ParserUtils::ParseArgument(args, "-q", configargs); for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } ParserUtils::ParseArgument(args, "-c", gOptCardInput, false); if (gOptCardInput != "") { NUIS_LOG(FIT, "Reading cardfile: " << gOptCardInput); configuration.LoadSettings(gOptCardInput, ""); } ParserUtils::ParseArgument(args, "-t", gOptOptions, false); if (gOptOptions != "") { NUIS_LOG(FIT, "Read options: \"" << gOptOptions << "\'"); } return; } void SetupRW() { std::vector parkeys = Config::QueryKeys("parameter"); if (!parkeys.empty()) { NUIS_LOG(FIT, "Number of parameters : " << parkeys.size()); } std::vector Params; std::map TypeVals; std::map CurrVals; for (size_t i = 0; i < parkeys.size(); i++) { nuiskey key = parkeys.at(i); // Check for type,name,nom if (!key.Has("type")) { NUIS_ERR(FTL, "No type given for parameter " << i); NUIS_ABORT("type='PARAMETER_TYPE'"); } else if (!key.Has("name")) { NUIS_ERR(FTL, "No name given for parameter " << i); NUIS_ABORT("name='SAMPLE_NAME'"); } else if (!key.Has("nominal")) { NUIS_ERR(FTL, "No nominal given for parameter " << i); NUIS_ABORT("nominal='NOMINAL_VALUE'"); } // Get Inputs std::string partype = key.GetS("type"); std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); // Push into vectors Params.push_back(parname); TypeVals[parname] = FitBase::ConvDialType(partype); CurrVals[parname] = parnom; } for (UInt_t i = 0; i < Params.size(); i++) { FitBase::GetRW()->IncludeDial(Params[i], TypeVals[Params[i]]); FitBase::GetRW()->SetDialValue(Params[i], CurrVals[Params[i]]); } FitBase::GetRW()->Reconfigure(); } //******************************* int main(int argc, char *argv[]) { //******************************* // Parse GetCommandLineArgs(argc, argv); // Make output file TFile *f = new TFile(gOptOutputFile.c_str(), "RECREATE"); if (f->IsZombie()) { NUIS_ABORT("Cannot create output file!"); } f->cd(); Config::Get().out = f; // Create a new measurementbase class depending on the Format MeasurementBase *flattreecreator = NULL; // Make a new sample key for the format of interest. nuiskey samplekey = Config::CreateKey("sample"); samplekey.Set("name", "FlatTree"); samplekey.Set("smearceptor", gOptOptions); samplekey.Set("input", gOptInputFile); samplekey.Set("type", gOptType); if (gOptOptions == "") { NUIS_ABORT("Attempting to flatten with Smearceptor, but no Smearceptor given. " "Please supply a -t option."); } if (gOptCardInput == "") { NUIS_ABORT("Attempting to flatten with Smearceptor, but no card passed with " "Smearceptors configured. Please supply a -c option."); } SetupRW(); flattreecreator = new Smearceptance_Tester(samplekey); // Make the FlatTree reconfigure flattreecreator->Reconfigure(); f->cd(); flattreecreator->Write(); f->Close(); // Show Final Status NUIS_LOG(FIT, "-------------------------------------"); NUIS_LOG(FIT, "Flattree Generation Complete."); NUIS_LOG(FIT, "-------------------------------------"); return 0; } diff --git a/app/nuissplines.cxx b/app/nuissplines.cxx index 63ed81e..f5efb45 100644 --- a/app/nuissplines.cxx +++ b/app/nuissplines.cxx @@ -1,105 +1,105 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // Author: Callum Wilkinson 01/2014 // Patrick Stowell 09/2015 /** Usage: ./GSLminimizerWithReWeight.exe -c card file, where samples and parameters are defined -o output file, where the results of the fit are stored where: */ #include "SplineRoutines.h" //******************************* void printInputCommands(){ //******************************* /* - std::cout<<"ExtFit_splines.exe -c cardFile -f [spline_routines] [-q + std::cout<<"nuissplines -c cardFile -f [spline_routines] [-q config_name=config_val] \n"; std::cout<Run(); // Show Final Status NUIS_LOG(FIT, "-------------------------------------"); NUIS_LOG(FIT, "Spline Generation/Validation Finished."); NUIS_LOG(FIT, "-------------------------------------"); return 0; } diff --git a/app/nuissyst.cxx b/app/nuissyst.cxx index 5e66265..4597443 100644 --- a/app/nuissyst.cxx +++ b/app/nuissyst.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // Author: Patrick Stowell 09/2016 /* Usage: ./nuissyst -c card file -o output file, where the results of the throws are stored where: */ #include "SystematicRoutines.h" //******************************* void printInputCommands() { //******************************* std::cout << "nuissyst.exe -c cardFile -o outFile [-f fitStategy] [-d " "fakeDataFile] [-i inputFile] [-q config_name=config_val] \n"; std::cout << std::endl; std::cout << "Arguments:" << std::endl; std::cout << " -c cardFile: Path to card file that defines fit " "samples, free parameters, and config overrides \n"; std::cout << " -o outFile: Path to root file that will be created to " "save output file.\n"; std::cout << " -f Strategy: ErrorBands (default) or PlotLimits\n" << std::endl; exit(-1); }; //******************************* int main(int argc, char *argv[]) { //******************************* // Program status; int status = 0; // 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; } // Read input arguments such as card file, parameter arguments, and fit // routines NUIS_LOG(FIT, "Starting nuissyst"); // Make systematic class and run fit SystematicRoutines *min = new SystematicRoutines(argc, argv); min->Run(); // Show Final Status NUIS_LOG(FIT, "-------------------------------------"); if (status == 0) { NUIS_LOG(FIT, "Systematic Complete."); } else { NUIS_ERR(FTL, "Systematic Failed (error state = " << status << ")"); } NUIS_LOG(FIT, "-------------------------------------"); return status; } diff --git a/cmake/BuildDynamicSample.in b/cmake/BuildDynamicSample.in index 97a340e..64f4a50 100644 --- a/cmake/BuildDynamicSample.in +++ b/cmake/BuildDynamicSample.in @@ -1,87 +1,87 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ #!/bin/bash if [ ! "${1}" ] || [ ! -e ${1} ] || [ ! "${2}" ]; then echo "[USAGE]: ${0} input.cxx outputLibName.so [classname]" exit 1 fi if [ ! "${3}" ]; then CN=$(grep "class .*" $1 | sed "s/^class \([0-9a-zA-Z]\+\).*$/\1/g") else CN=${3} fi if [ ! "${CN}" ]; then echo "[ERROR]: Couldn't find class name -- Expected to find a line like: \"class XXXX : public Measurement1D\" in \"$1\". You can also forcibly specify your classes name by passing a third argument to this script." exit 1 fi if [ ! -e compile.tmp ]; then mkdir compile.tmp fi cat $1 > compile.tmp/$1 echo -e "static char const * SampleNames[] = {\"${CN}\"};\n"\ "static int const NSamples = 1;\n"\ "\n"\ "extern \"C\" {\n"\ "int DSF_NSamples() { return NSamples; }\n"\ "char const* DSF_GetSampleName(int i) {\n"\ " if (i < NSamples) {\n"\ " return SampleNames[i];\n"\ " }\n"\ " return 0;\n"\ "}\n"\ "MeasurementBase* DSF_GetSample(int i, void* samplekey) {\n"\ " nuiskey* sk = reinterpret_cast(samplekey);\n"\ " if (!sk) {\n"\ " return 0;\n"\ " }\n"\ "\n"\ " if (sk->GetS(\"name\") != DSF_GetSampleName(i)) {\n"\ " std::cout\n"\ " << \"[ERROR]: When instantiating dynamic sample. Samplekey named: \"\n"\ " << sk->GetS(\"name\") << \", but requested sample named: \"\n"\ " << DSF_GetSampleName(i)\n"\ " << \". It is possible that the nuiskey object is lost in translation. \"\n"\ " \"Was NUISANCE and this dynamic sample manifest built with the same \"\n"\ " \"environment and compiler?\"\n"\ " << std::endl;\n"\ " }\n"\ "\n"\ " if (i == 0) {\n"\ " return new ${CN}(*sk);\n"\ " }\n"\ " return 0;\n"\ "}\n"\ "void DSF_DestroySample(MeasurementBase* mb) { delete mb; }\n"\ "}" >> compile.tmp/$1 echo "g++ ${DYNSAMPLE_EXTRA_BUILD_FLAGS} compile.tmp/$1 -shared -o $2 -fPIC @CMAKE_CXX_FLAGS@ -I. -I@ALL_INCLUDES_STR@ -L@CMAKE_INSTALL_PREFIX@/lib @ALL_MODULETARGETS_STR@ @CMAKE_LINK_FLAGS@ @CMAKE_DEPENDLIB_FLAGS@" if ! g++ ${DYNSAMPLE_EXTRA_BUILD_FLAGS} compile.tmp/$1 -shared -o $2 -fPIC @CMAKE_CXX_FLAGS@ -I. -I@ALL_INCLUDES_STR@ -L@CMAKE_INSTALL_PREFIX@/lib @ALL_MODULETARGETS_STR@ @CMAKE_LINK_FLAGS@ @CMAKE_DEPENDLIB_FLAGS@; then echo "[ERROR]: Failed to compile $1. Generated code can be found in ./compile.tmp/$1" else rm -r compile.tmp echo "Successfully build: $2." fi diff --git a/cmake/BuildDynamicSmearcepter.in b/cmake/BuildDynamicSmearcepter.in index dce4633..1ae40b5 100644 --- a/cmake/BuildDynamicSmearcepter.in +++ b/cmake/BuildDynamicSmearcepter.in @@ -1,89 +1,89 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ #!/bin/bash if [ ! "${1}" ] || [ ! -e ${1} ] || [ ! "${2}" ]; then echo "[USAGE]: ${0} input.cxx outputLibName.so [classname]" exit 1 fi if [ ! "${3}" ]; then CN=$(grep "class .*" $1 | sed "s/^class \([0-9a-zA-Z]\+\).*$/\1/g") else CN=${3} fi if [ ! "${CN}" ]; then echo "[ERROR]: Couldn't find class name -- Expected to find a line like: \"class XXXX : public ISmearcepter\" in \"$1\". You can also forcibly specify your classes name by passing a third argument to this script." exit 1 fi if [ ! -e compile.tmp ]; then mkdir compile.tmp fi cat $1 > compile.tmp/$1 echo -e "static char const * SmearceptorNames[] = {\"${CN}\"};\n"\ "static int const NSmearceptors = 1;\n"\ "\n"\ "extern \"C\" {\n"\ "int DSF_NSmearceptors() { return NSmearceptors; }\n"\ "char const* DSF_GetSmearceptorName(int i) {\n"\ " if (i < NSmearceptors) {\n"\ " return SmearceptorNames[i];\n"\ " }\n"\ " return 0;\n"\ "}\n"\ "ISmearcepter* DSF_GetSmearceptor(int i, void* smearceptorkey) {\n"\ " nuiskey* sk = reinterpret_cast(smearceptorkey);\n"\ " if (!sk) {\n"\ " return 0;\n"\ " }\n"\ "\n"\ " if (sk->GetElementName() != DSF_GetSmearceptorName(i)) {\n"\ " std::cout\n"\ " << \"[ERROR]: When instantiating dynamic smearceptor. Smearceptorkey named: \"\n"\ " << sk->GetElementName() << \", but requested smearceptor named: \"\n"\ " << DSF_GetSmearceptorName(i)\n"\ " << \". It is possible that the nuiskey object is lost in translation. \"\n"\ " \"Was NUISANCE and this dynamic smearceptor manifest built with the same \"\n"\ " \"environment and compiler?\"\n"\ " << std::endl;\n"\ " }\n"\ "\n"\ " if (i == 0) {\n"\ " ISmearcepter* sm = new ${CN}();\n"\ " sm->Setup(*sk);\n"\ " return sm;\n"\ " }\n"\ " return 0;\n"\ "}\n"\ "void DSF_DestroySmearceptor(ISmearcepter* mb) { delete mb; }\n"\ "}" >> compile.tmp/$1 echo "g++ ${DYNSAMPLE_EXTRA_BUILD_FLAGS} compile.tmp/$1 -shared -o $2 -fPIC @CMAKE_CXX_FLAGS@ -I. -I@ALL_INCLUDES_STR@ -L@CMAKE_INSTALL_PREFIX@/lib -l@ALL_MODULETARGETS_STR@ @CMAKE_LINK_FLAGS@ @CMAKE_DEPENDLIB_FLAGS@" if ! g++ ${DYNSAMPLE_EXTRA_BUILD_FLAGS} compile.tmp/$1 -shared -o $2 -fPIC @CMAKE_CXX_FLAGS@ -I. -I@ALL_INCLUDES_STR@ -L@CMAKE_INSTALL_PREFIX@/lib -l@ALL_MODULETARGETS_STR@ @CMAKE_LINK_FLAGS@ @CMAKE_DEPENDLIB_FLAGS@; then echo "[ERROR]: Failed to compile $1. Generated code can be found in ./compile.tmp/$1" else rm -r compile.tmp echo "Successfully build: $2." fi diff --git a/cmake/GENIESetup.cmake b/cmake/GENIESetup.cmake index 3102253..6801e79 100644 --- a/cmake/GENIESetup.cmake +++ b/cmake/GENIESetup.cmake @@ -1,249 +1,249 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ # TODO # check system for libxml2 # check whether we need the includes # check if we can use a subset of the GENIE libraries include(${CMAKE_SOURCE_DIR}/cmake/parseConfigApp.cmake) ################################################################################ # Check Dependencies ################################################################################ ################################# GENIE ###################################### if(GENIE STREQUAL "") cmessage(FATAL_ERROR "Variable GENIE is not defined. " "The location of a pre-built GENIE install must be defined either as" " $ cmake -DGENIE=/path/to/GENIE or as an environment variable" " $ export GENIE=/path/to/GENIE") endif() execute_process(COMMAND genie-config --version OUTPUT_VARIABLE GENIE_VER OUTPUT_STRIP_TRAILING_WHITESPACE) cmessage(STATUS "genie_ver: ${GENIE_VER}") if(GENIE_VER VERSION_GREATER 3.0.0) set(GENIE_POST_R3 1) string(REPLACE "." "" GENIE_VERSION ${GENIE_VER}) cmessage(STATUS "set genie_post_r3") endif() if(NOT GENIE_POST_R3) LIST(APPEND EXTRA_CXX_FLAGS -DGENIE_PRE_R3) cmessage(STATUS "setting genie_pre_r3 ${EXTRA_CXX_FLAGS}") if(GENIE_EMPMEC_REWEIGHT) cmessage(STATUS "Enable EMPMEC dials") LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_EMP_MECRW_ENABLED) endif() else() cmessage(STATUS "Enable EMPMEC dials") LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_EMP_MECRW_ENABLED) if(USE_GENIE_XSECMEC) LIST(APPEND EXTRA_CXX_FLAGS -DUSE_GENIE_XSECMEC) endif() endif() execute_process (COMMAND genie-config --topsrcdir OUTPUT_VARIABLE GENIE_INCLUDES_DIR OUTPUT_STRIP_TRAILING_WHITESPACE) #Allows for external override in the case where genie-config lies. if(NOT DEFINED GENIE_LIB_DIR OR GENIE_LIB_DIR STREQUAL "") #This looks like it should call libdir, but it strips the argument with -L from the response of --libs GETLIBDIRS(genie-config --libs GENIE_LIB_DIR) endif() GETLIBS(genie-config --libs GENIE_LIBS) cmessage(STATUS "GENIE version : ${GENIE_VERSION}") cmessage(STATUS "GENIE libdir : ${GENIE_LIB_DIR}") cmessage(STATUS "GENIE libs : ${GENIE_LIBS}") string(REGEX MATCH "ReinSeghal" WASMATCHED ${GENIE_LIBS}) if(WASMATCHED AND GENIE_VERSION STREQUAL "210") set(GENIE_SEHGAL ${GENIE_LIBS}) STRING(REPLACE "ReinSeghal" "ReinSehgal" GENIE_LIBS ${GENIE_SEHGAL}) cmessage(DEBUG "Fixed inconsistency in library naming: ${GENIE_LIBS}") endif() if(NOT USE_REWEIGHT) SET(USING_GENIE_RW FALSE) elseif(NOT GENIE_POST_R3) LIST(FIND GENIE_LIBS GReWeight FOUND_GENIE_RW) if(FOUND_GENIE_RW EQUAL -1) cmessage(DEBUG "Did NOT find ReWeight library. Here are libs: ${GENIE_LIBS}") SET(USING_GENIE_RW FALSE) else() SET(USING_GENIE_RW TRUE) endif() elseif(DEFINED GENIE_REWEIGHT AND NOT GENIE_REWEIGHT STREQUAL "") LIST(FIND GENIE_LIBS GRwFwk FOUND_GENIE_RW) if(FOUND_GENIE_RW EQUAL -1) LIST(APPEND GENIE_LIBS GRwClc GRwFwk GRwIO) cmessage(DEBUG "Force added ReWeight library. Here are libs: ${GENIE_LIBS}") SET(USING_GENIE_RW TRUE) else() SET(USING_GENIE_RW FALSE) endif() endif() if(USING_GENIE_RW) cmessage(STATUS "Using GENIE ReWeight library.") else() cmessage(STATUS "Building without GENIE ReWeight support.") endif() LIST(APPEND GENIE_LIBS -Wl,--end-group ) LIST(REVERSE GENIE_LIBS) LIST(APPEND GENIE_LIBS -Wl,--start-group -Wl,--no-as-needed ) LIST(REVERSE GENIE_LIBS) cmessage(DEBUG "GENIE_LIBS: ${GENIE_LIBS}") ################################ LHAPDF ###################################### if(LHAPDF_LIB STREQUAL "") cmessage(FATAL_ERROR "Variable LHAPDF_LIB is not defined. The location of a pre-built lhapdf install must be defined either as $ cmake -DLHAPDF_LIB=/path/to/LHAPDF_libraries or as an environment variable $ export LHAPDF_LIB=/path/to/LHAPDF_libraries") endif() if(LHAPDF_INC STREQUAL "") cmessage(FATAL_ERROR "Variable LHAPDF_INC is not defined. The location of a pre-built lhapdf install must be defined either as $ cmake -DLHAPDF_INC=/path/to/LHAPDF_includes or as an environment variable $ export LHAPDF_INC=/path/to/LHAPDF_includes") endif() if(LHAPATH STREQUAL "") cmessage(FATAL_ERROR "Variable LHAPATH is not defined. The location of a the LHAPATH directory must be defined either as $ cmake -DLHAPATH=/path/to/LHAPATH or as an environment variable $ export LHAPATH=/path/to/LHAPATH") endif() ################################ LIBXML ###################################### if(LIBXML2_LIB STREQUAL "") GETLIBDIR(xml2-config --libs LIBXML2_LIB IGNORE_EMPTY_RESPONSE) if(LIBXML2_LIB STREQUAL "") message(WARNING "Variable LIBXML2_LIB is not defined, as xml2-config was found and didn't report a library include path, it is likely that libxml2.so can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLIBXML2_LIB=/path/to/LIBXML2_libraries or as an environment variable LIBXML2_LIB.") endif() endif() if(LIBXML2_INC STREQUAL "") GETINCDIR(xml2-config --cflags LIBXML2_INC IGNORE_EMPTY_RESPONSE) if(LIBXML2_INC STREQUAL "") message(WARNING "Variable LIBXML2_INC is not defined, as xml2-config was found and didn't report an include path, it is likely that libxml2.so can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLIBXML2_INC=/path/to/LIBXML2_includes or as an environment variable LIBXML2_INC.") endif() endif() ############################### log4cpp ###################################### if(LOG4CPP_LIB STREQUAL "") GETLIBDIR(log4cpp-config --libs LOG4CPP_LIB IGNORE_EMPTY_RESPONSE) if(LOG4CPP_LIB STREQUAL "") message(WARNING "Variable LOG4CPP_LIB is not defined, as xml2-config was found and didn't report a library include path, it is likely that liblog4cpp.so can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLOG4CPP_LIB=/path/to/LOG4CPP_libraries or as an environment variable LOG4CPP_LIB.") endif() endif() if(LOG4CPP_INC STREQUAL "") GETINCDIR(log4cpp-config --cflags LOG4CPP_INC IGNORE_EMPTY_RESPONSE) if(LOG4CPP_INC STREQUAL "") message(WARNING "Variable LOG4CPP_LIB is not defined, as xml2-config was found and didn't report an include path, it is likely that log4cpp headers can be found in the standard system location, lets hope so. Alternativly, a location can be forced by configering with -DLOG4CPP_INC=/path/to/LOG4CPP_includes or as an environment variable LOG4CPP_INC.") endif() endif() ################################################################################ # Set the compiler defines LIST(APPEND EXTRA_CXX_FLAGS -D__GENIE_ENABLED__ -D__GENIE_VERSION__=${GENIE_VERSION}) LIST(APPEND EXTRA_LIBS ${GENIE_LIBS}) ############################### GSL ###################################### if(GENIE_POST_R3) if(GSL_LIB STREQUAL "") GETLIBDIR(gsl-config --libs GSL_LIB) if(GSL_LIB STREQUAL "") message(FATAL_ERROR "Variable GSL_LIB is not defined and could not be found with gsl-config. The location of a pre-built gsl install must be defined either as $ cmake -DGSL_LIB=/path/to/GSL_libraries or as an environment variable $ export GSL_LIB=/path/to/GSL_libraries") endif() endif() if(GSL_INC STREQUAL "") GETINCDIR(gsl-config --cflags GSL_INC) if(GSL_INC STREQUAL "") message(FATAL_ERROR "Variable GSL_INC is not defined and could not be found with gsl-config. The location of a pre-built gsl install must be defined either as $ cmake -DGSL_INC=/path/to/GSL_includes or as an environment variable $ export GSL_INC=/path/to/GSL_includes") endif() endif() GETLIBS(gsl-config --libs GSL_LIB_LIST) if(USING_GENIE_RW AND GENIE_REWEIGHT STREQUAL "") message(FATAL_ERROR "Variable GENIE_REWEIGHT is not defined. When using GENIE v3+, we require the reweight product to be built and accessible via the environment variable GENIE_REWEIGHT") endif() endif() ################################################################################ LIST(APPEND EXTRA_LIBS LHAPDF xml2 log4cpp) LIST(APPEND EXTRA_LINK_DIRS ${GENIE_LIB_DIR} ${LHAPDF_LIB} ${LOG4CPP_LIB}) # Append only if we have found GENIE ReWeight if(NOT GENIE_POST_R3) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_INCLUDES_DIR} ${GENIE_INCLUDES_DIR}/GHEP ${GENIE_INCLUDES_DIR}/Ntuple) if(USING_GENIE_RW) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_INCLUDES_DIR}/ReWeight) endif() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_INCLUDES_DIR}/Apps ${GENIE_INCLUDES_DIR}/FluxDrivers ${GENIE_INCLUDES_DIR}/EVGDrivers ${LHAPDF_INC} ${LIBXML2_INC} ${LOG4CPP_INC}) else() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_INCLUDES_DIR}) if(USING_GENIE_RW) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GENIE_REWEIGHT}/src) endif() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${GSL_INC} ${LHAPDF_INC} ${LIBXML2_INC} ${LOG4CPP_INC}) if(USING_GENIE_RW) LIST(APPEND EXTRA_LINK_DIRS ${GENIE_REWEIGHT}/lib) endif() LIST(APPEND EXTRA_LINK_DIRS ${GSL_LIB} ) LIST(APPEND EXTRA_LIBS ${GSL_LIB_LIST}) endif() if(USE_PYTHIA8) set(NEED_PYTHIA8 TRUE) set(NEED_ROOTPYTHIA8 TRUE) else() set(NEED_PYTHIA6 TRUE) set(NEED_ROOTPYTHIA6 TRUE) endif() set(NEED_ROOTEVEGEN FALSE) SET(USE_GENIE TRUE CACHE BOOL "Whether to enable GENIE (reweight) support. Requires external libraries. " FORCE) diff --git a/cmake/GiBUUSetup.cmake b/cmake/GiBUUSetup.cmake index 6bbe0b0..e7a1eeb 100644 --- a/cmake/GiBUUSetup.cmake +++ b/cmake/GiBUUSetup.cmake @@ -1,45 +1,45 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(USE_GiBUU) LIST(APPEND EXTRA_CXX_FLAGS -D__GiBUU_ENABLED__) if(BUILD_GiBUU) if (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.") endif() 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 -DFORCECPP03=1 -DNO_EXTERNAL_UPDATE=${NO_EXTERNAL_UPDATE}) cmessage(STATUS "Building GiBUU and GiBUUTools") SET(BUILD_GiBUU TRUE CACHE BOOL "Whether to build supporting GiBUU event tools along with a patched version of GiBUU. " FORCE) endif() SET(USE_GiBUU TRUE CACHE BOOL "Whether to enable GiBUU event support. " FORCE) endif() diff --git a/cmake/HepMC.cmake b/cmake/HepMC.cmake index 2ade454..37e8bb3 100644 --- a/cmake/HepMC.cmake +++ b/cmake/HepMC.cmake @@ -1,61 +1,61 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(USE_HEPMC) LIST(APPEND EXTRA_CXX_FLAGS -D__HEPMC_ENABLED__) if(HEPMC STREQUAL "") if (NO_EXTERNAL_UPDATE) set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY EP_UPDATE_DISCONNECTED 1) cmessage(STATUS "Will not attempt to update third party HepMC tools for each build.") endif() ExternalProject_Add(HepMC PREFIX "${PROJECT_BINARY_DIR}/HepMC" GIT_REPOSITORY https://gitlab.cern.ch/hepmc/HepMC.git GIT_TAG HEPMC_02_06_09 CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -Dmomentum=${HEPMC_MOMUNIT} -Dlength=${HEPMC_LENUNIT}) #Have to re-include the doc string here as the whole cache entry will be #overwritten when this happens set(HEPMC "${CMAKE_INSTALL_PREFIX}" CACHE PATH "Path to HEPMC source tree root directory. Overrides environment variable \$HEPMC <>" FORCE) set(HEPMC_USED_EP TRUE CACHE INTERNAL "Whether the we built HepMC or not. " FORCE) cmessage(STATUS "Building HepMC") endif() LIST(APPEND EXTRA_CXX_FLAGS -I${HEPMC}/include/) LIST(APPEND EXTRA_LINK_DIRS ${HEPMC}/lib/) LIST(APPEND EXTRA_LIBS HepMC HepMCfio) endif() diff --git a/cmake/MINERvASetup.cmake b/cmake/MINERvASetup.cmake index 0ccfcd9..cc4f881 100644 --- a/cmake/MINERvASetup.cmake +++ b/cmake/MINERvASetup.cmake @@ -1,19 +1,19 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ LIST(APPEND EXTRA_CXX_FLAGS -D__MINERVA_RW_ENABLED__) diff --git a/cmake/MakeBinaryBlob.in b/cmake/MakeBinaryBlob.in index b6554b9..c545b6e 100644 --- a/cmake/MakeBinaryBlob.in +++ b/cmake/MakeBinaryBlob.in @@ -1,173 +1,173 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ #!/bin/sh if [ ! ${NUISANCE} ]; then echo "[ERROR]; NUISANCE envrionment variable is not defined, please source NUSIANCE before trying to make a binary blob." exit 1 fi mkdir BinBlob cd BinBlob echo "#!/bin/sh" > setup.sh cat @PROJECT_SOURCE_DIR@/cmake/BinBlobSetup.header >> setup.sh mkdir deps exes mkdir root mkdir -p root/lib/root echo "[INFO]: Copying ROOT libraries from @CMAKE_ROOTSYS@/lib/root" cp @CMAKE_ROOTSYS@/lib/root/*.so* root/lib/root/ mkdir root/bin echo "[INFO]: Copying ROOT binary from @CMAKE_ROOTSYS@/bin" cp @CMAKE_ROOTSYS@/bin/* root/bin mkdir -p root/share/man/man1 echo "[INFO]: Copying ROOT man pages from @CMAKE_ROOTSYS@/share/man/man1" cp -r @CMAKE_ROOTSYS@/share/man/man1 root/share/man/man1 cat root/bin/thisroot.sh | sed 's:@CMAKE_ROOTSYS@:__INST_ROOT__:g' > root/bin/thisroot.sh_tmp rm root/bin/thisroot.sh echo "cat \$NUISANCE/root/bin/thisroot.sh_tmp | sed \"s:__INST_ROOT__:\$NUISANCE/root:g\" > \$NUISANCE/root/bin/thisroot.sh" >> setup.sh cat root/bin/thisroot.csh | sed 's:@CMAKE_ROOTSYS@:__INST_ROOT__:g' > root/bin/thisroot.csh_tmp rm root/bin/thisroot.csh echo "cat \$NUISANCE/root/bin/thisroot.csh_tmp | sed \"s:__INST_ROOT__:\$NUISANCE/root:g\" > \$NUISANCE/root/bin/thisroot.csh" >> setup.sh echo "source \$NUISANCE/root/bin/thisroot.sh" >> setup.sh if [ "@USE_T2K@" != "FALSE" ]; then mkdir deps/t2k echo "[INFO]: Copying T2K libraries from @T2KREWEIGHT@" cp @T2KREWEIGHT@/lib/*.so deps/t2k/ echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/t2k" >> setup.sh fi if [ "@USE_NIWG@" != "FALSE" ]; then mkdir deps/niwg echo "[INFO]: Copying NIWG libraries from @NIWG@" cp @NIWG@/lib/*.so deps/niwg/ echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/niwg" >> setup.sh fi if [ "@USE_NEUT@" != "FALSE" ]; then mkdir deps/neut mkdir exes/neut echo "[INFO]: Copying NEUT libraries from @NEUT_ROOT@" cp @NEUT_ROOT@/src/reweight/*.so* deps/neut cp @NEUT_ROOT@/src/neutclass/*.so* deps/neut cp @NEUT_ROOT@/src/neutsmpl/neutroot2 exes/neut echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/neut" >> setup.sh fi if [ "@USE_NuWro@" != "FALSE" ]; then if [ "@NUWRO_BUILT_FROM_FILE@" == "FALSE" ]; then mkdir deps/nuwro mkdir exes/nuwro mkdir data mkdir data/nuwro echo "[INFO]: Copying NuWro libraries from @NUWRO@" cp @NUWRO@/lib/*.so deps/nuwro cp @NUWRO@/bin/nuwro exes/nuwro/ cp -r @NUWRO@/data data/nuwro echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/nuwro" >> setup.sh echo "export NUWRO=\$NUISANCE/data/nuwro" >> setup.sh else echo "[INFO]: NuWro support included from input event file." fi fi if [ "@NEED_PYTHIA6@" != "FALSE" ]; then mkdir deps/pythia echo "[INFO]: Copying PYTHIA libraries from @PYTHIA6@" cp @PYTHIA6@/*.so deps/pythia/ echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/pythia" >> setup.sh fi if [ "@USE_GENIE@" != "FALSE" ]; then mkdir -p deps/genie/{,libxml2,lhapdf,log4cpp} mkdir exes/genie echo "[INFO]: Copying LHAPDF libraries from @LHAPDF_LIB@" cp @LHAPDF_LIB@/libLHAPDF.so* deps/genie/lhapdf echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/genie/lhapdf" >> setup.sh echo "[INFO]: Copying LIBXML2 libraries from @LIBXML2_LIB@" cp @LIBXML2_LIB@/libxml2.so* deps/genie/libxml2 echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/genie/libxml2" >> setup.sh echo "[INFO]: Copying LOG4CPP libraries from @LOG4CPP_LIB@" cp @LOG4CPP_LIB@/liblog4cpp.so* deps/genie/log4cpp echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/genie/log4cpp" >> setup.sh if [ "@LHAPATH@" ]; then mkdir -p data/genie/lhapdf cp @LHAPATH@/*.LHgrid data/genie/lhapdf/ echo "export LHAPATH=\"\$NUISANCE/data/genie/lhapdf\"" >> setup.sh fi echo "[INFO]: Copying GENIE libraries from @GENIE@/lib" cp @GENIE@/lib/*.so* deps/genie/ echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/genie" >> setup.sh echo "[INFO]: Copying GENIE binaries from @GENIE@/bin" cp @GENIE@/bin/* exes/genie/ echo "add_to_PATH \$NUISANCE/exes/genie" >> setup.sh fi mkdir exes/nuisance cp @CMAKE_INSTALL_PREFIX@/bin/* exes/nuisance/ echo "add_to_PATH \$NUISANCE/exes/nuisance" >> setup.sh rm exes/nuisance/BuildDynamic* if [ @CMAKE_BUILD_TYPE@ == "RELEASE" ]; then mkdir deps/nuisance echo "add_to_LD_LIBRARY_PATH \$NUISANCE/deps/nuisance" >> setup.sh cp @CMAKE_INSTALL_PREFIX@/lib/*.so deps/nuisance/ fi if [ -e data ]; then tar -zcvf nuisblob.tar.gz setup.sh exes/* deps/* root/* data/* else tar -zcvf nuisblob.tar.gz setup.sh exes/* deps/* root/* fi cd ../ diff --git a/cmake/NEUTSetup.cmake b/cmake/NEUTSetup.cmake index ab72a32..ac6fc40 100644 --- a/cmake/NEUTSetup.cmake +++ b/cmake/NEUTSetup.cmake @@ -1,252 +1,252 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ include(cmake/parseConfigApp.cmake) find_program(NEUTCONFIG NAMES neut-config) LIST(APPEND EXTRA_CXX_FLAGS -DNEED_FILL_NEUT_COMMONS) SET(HAVENEUTCONFIG FALSE) # We are dealing with shiny NEUT if(NOT "${NEUTCONFIG}" STREQUAL "NEUTCONFIG-NOTFOUND") SET(HAVENEUTCONFIG TRUE) cmessage(STATUS "Found neut-config, using it to determine configuration.") else() cmessage(STATUS "Failed to find neut-config, assuming older NEUT build.") endif() if(HAVENEUTCONFIG) execute_process (COMMAND neut-config --version OUTPUT_VARIABLE NEUT_VER OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND neut-config --incdir OUTPUT_VARIABLE NEUT_INCLUDE_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process (COMMAND neut-config --libdir OUTPUT_VARIABLE NEUT_LINK_DIRS OUTPUT_STRIP_TRAILING_WHITESPACE) GETLIBDIRS(neut-config --cernflags CERN_LIB_DIR) LIST(APPEND NEUT_LINK_DIRS ${CERN_LIB_DIR}) GETLIBS(neut-config --cernflags CERN_LIBS) if(USE_REWEIGHT) execute_process (COMMAND neut-config --rwlibflags OUTPUT_VARIABLE NEUT_RWLIBS OUTPUT_STRIP_TRAILING_WHITESPACE) GETLIBS(neut-config --rwlibflags NEUT_RWLIBS) LIST(APPEND NEUT_LIBS ${NEUT_RWLIBS}) else() GETLIBS(neut-config --libflags NEUT_GENLIBS) GETLIBS(neut-config --iolibflags NEUT_LIBS) LIST(APPEND NEUT_LIBS ${NEUT_IOLIBS}) LIST(APPEND NEUT_LIBS ${NEUT_GENLIBS}) endif() LIST(APPEND NEUT_LIBS ${CERN_LIBS};gfortran) LIST(APPEND EXTRA_LIBS ${NEUT_LIBS}) string(REPLACE "." "" NEUT_VERSION ${NEUT_VER}) PrefixList(NEUT_INCLUDE_DIRS "-I" ${NEUT_INCLUDE_DIRS}) LIST(APPEND EXTRA_CXX_FLAGS ${NEUT_INCLUDE_DIRS} -D__NEUT_ENABLED__ -D__NEUT_VERSION__=${NEUT_VERSION}) LIST(APPEND EXTRA_LINK_DIRS ${NEUT_LINK_DIRS}) include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG(-Wl,--allow-multiple-definition COMPILER_SUPPORTS_ALLOW_MULTIPLE_DEFINITION) IF(COMPILER_SUPPORTS_ALLOW_MULTIPLE_DEFINITION) LIST(APPEND EXTRA_LINK_FLAGS -Wl,--allow-multiple-definition) ENDIF() CHECK_CXX_COMPILER_FLAG(-no-pie COMPILER_SUPPORTS_NO_PIE) CHECK_CXX_COMPILER_FLAG(-fno-pie COMPILER_SUPPORTS_FNO_PIE) CHECK_CXX_COMPILER_FLAG(-fno-PIE COMPILER_SUPPORTS_FNO_PIE_CAP) if(COMPILER_SUPPORTS_NO_PIE) set(PIE_FLAGS "-no-pie") elseif(COMPILER_SUPPORTS_FNO_PIE) set(PIE_FLAGS "-fno-pie") elseif(COMPILER_SUPPOERTS_FNO_PIE_CAP) set(PIE_FLAGS "-fno-PIE") else() message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.") endif() LIST(APPEND EXTRA_EXE_FLAGS ${PIE_FLAGS}) cmessage(STATUS "NEUT") cmessage(STATUS " Version : ${NEUT_VER}") cmessage(STATUS " Flags : ${NEUT_CXX_FLAGS}") cmessage(STATUS " Includes : ${NEUT_INCLUDE_DIRS}") cmessage(STATUS " Link Dirs : ${NEUT_LINK_DIRS}") cmessage(STATUS " Libs : ${NEUT_LIBS}") cmessage(STATUS " Exe Flags : ${EXTRA_EXE_FLAGS}") else() # Everything better be set up already if(NEUT_ROOT STREQUAL "") cmessage(FATAL_ERROR "Variable NEUT_ROOT is not defined. Please export environment variable NEUT_ROOT or configure with -DNEUT_ROOT=/path/to/NEUT. This must be set to point to a prebuilt NEUT instance.") endif() if(CERN STREQUAL "") cmessage(FATAL_ERROR "Variable CERN is not defined. Please export environment variable CERN or configure with -DCERN=/path/to/CERNLIB. This must be set to point to a prebuilt CERNLIB instance.") endif() if(CERN_LEVEL STREQUAL "") cmessage(FATAL_ERROR "Variable CERN_LEVEL is not defined. Please export environment variable CERN_LEVEL or configure with -DCERN_LEVEL=XXXX (likely to be 2005).") endif() if(${NEUT_VERSION} VERSION_LESS 5.4.0) set(NEUT_LIB_DIR ${NEUT_ROOT}/lib/Linux_pc) else() set(NEUT_LIB_DIR ${NEUT_ROOT}/lib) endif() set(NEUT_CLASS ${NEUT_ROOT}/src/neutclass) LIST(APPEND EXTRA_CXX_FLAGS -D__NEUT_ENABLED__ -DNEUT_VERSION=${NEUT_VERSION}) LIST(APPEND EXTRA_CXX_FLAGS -I${NEUT_ROOT}/include -I${NEUT_ROOT}/src/neutclass) LIST(APPEND EXTRA_LINK_DIRS ${NEUT_LIB_DIR} ${CERN}/${CERN_LEVEL}/lib) if(USE_REWEIGHT) LIST(APPEND EXTRA_CXX_FLAGS -I${NEUT_ROOT}/src/reweight) LIST(APPEND EXTRA_LINK_DIRS ${NEUT_ROOT}/src/reweight) endif() if(${NEUT_VERSION} VERSION_EQUAL 5.4.2) LIST(APPEND EXTRA_LIBS -Wl,--as-needed) if(USE_REWEIGHT) LIST(APPEND EXTRA_LIBS NReWeight) endif() LIST(APPEND EXTRA_LIBS -Wl,--start-group neutcore_5.4.2 nuccorspl_5.4.2 #typo in NEUT, may hopefully disappear nuceff_5.4.2 partnuck_5.4.2 skmcsvc_5.4.2 tauola_5.4.2 HT2p2h_5.4.0 N1p1h_5.4.0 -Wl,--end-group jetset74 pdflib804 mathlib packlib pawlib) LIST(APPEND EXTRA_CXX_FLAGS -DNEUT_COMMON_QEAV) elseif(${NEUT_VERSION} VERSION_EQUAL 5.4.0) LIST(APPEND EXTRA_LIBS -Wl,--as-needed) if(USE_REWEIGHT) LIST(APPEND EXTRA_LIBS NReWeight) endif() LIST(APPEND EXTRA_LIBS -Wl,--start-group neutcore_5.4.0 nuccorspl_5.4.0 #typo in NEUT, may hopefully disappear nuceff_5.4.0 partnuck_5.4.0 skmcsvc_5.4.0 tauola_5.4.0 HT2p2h_5.4.0 N1p1h_5.4.0 specfunc_5.4.0 radcorr_5.4.0 gfortran -Wl,--end-group jetset74 pdflib804 mathlib packlib pawlib) else() LIST(APPEND EXTRA_LIBS -Wl,--as-needed) if(USE_REWEIGHT) LIST(APPEND EXTRA_LIBS NReWeight) endif() LIST(APPEND EXTRA_LIBS -Wl,--start-group neutcore nuccorrspl nuceff partnuck skmcsvc tauola -Wl,--end-group jetset74 pdflib804 mathlib packlib pawlib) endif() set(NEUT_ROOT_LIBS) LIST(APPEND NEUT_ROOT_LIBS ${NEUT_CLASS}/neutctrl.so ${NEUT_CLASS}/neutfsivert.so) # Check for new versions of NEUT with NUCLEON FSI if(EXISTS "${NEUT_CLASS}/neutnucfsistep.so") set(NEUT_NUCFSI 1) LIST(APPEND EXTRA_CXX_FLAGS -DNEUT_NUCFSI_ENABLED) LIST(APPEND NEUT_ROOT_LIBS ${NEUT_CLASS}/neutnucfsistep.so ${NEUT_CLASS}/neutnucfsivert.so ) endif() if(${NEUT_VERSION} VERSION_LESS 5.4.0) LIST(APPEND NEUT_ROOT_LIBS ${NEUT_CLASS}/neutrootTreeSingleton.so) endif() LIST(APPEND NEUT_ROOT_LIBS ${NEUT_CLASS}/neutvtx.so ${NEUT_CLASS}/neutfsipart.so ${NEUT_CLASS}/neutpart.so ${NEUT_CLASS}/neutvect.so ) foreach(OBJ ${NEUT_ROOT_LIBS}) LIST(APPEND EXTRA_SHAREDOBJS ${OBJ}) endforeach() endif() diff --git a/cmake/NIWGSetup.cmake b/cmake/NIWGSetup.cmake index 293d296..5b5444f 100644 --- a/cmake/NIWGSetup.cmake +++ b/cmake/NIWGSetup.cmake @@ -1,56 +1,56 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(NIWG_ROOT STREQUAL "") cmessage(FATAL_ERROR "Variable NIWG_ROOT is not defined. Either configure with -DNIWG_ROOT or \"\$ export NIWG=/path/to/NIWGReWeight\". This must be set to point to a prebuilt NIWGReWeight instance.") endif() LIST(APPEND EXTRA_CXX_FLAGS -D__NIWG_ENABLED__) # Look for CCQE low Q2 suppression in NIWG find_file(NIWGRWLOWQE NIWGReWeightEffectiveQELowQ2Suppression.h PATHS ${NIWG_ROOT}) # Look for 2p2h energy dependent parameter in NIWG find_file(NIWG2P2HENU NIWGReWeight2p2hEdep.h PATH ${NIWG_ROOT}) # Look for resonant low Q2 suppression in NIWG find_file(NIWGRESLOWQ2 NIWGReWeightSPPLowQ2Suppression.h PATH ${NIWG_ROOT}) if( NOT "${NIWGRWLOWQE} " STREQUAL "NIWGRWLOWQE-NOTFOUND ") cmessage(STATUS "Found ${NIWGRWLOWQE}") LIST(APPEND EXTRA_CXX_FLAGS -DHAVE_NIWGRW_LOWQ2) endif() if( NOT "${NIWG2P2HENU} " STREQUAL "NIWG2P2HENU-NOTFOUND ") cmessage(STATUS "Found ${NIWG2P2HENU}") LIST(APPEND EXTRA_CXX_FLAGS -DHAVE_NIWGRW_2P2HENU) endif() if( NOT "${NIWGRESLOWQ2} " STREQUAL "NIWGRESLOWQ2-NOTFOUND ") cmessage(STATUS "Found ${NIWGRESLOWQ2}") LIST(APPEND EXTRA_CXX_FLAGS -DHAVE_NIWGRW_RESLOWQ2) endif() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NIWG_ROOT}) LIST(APPEND EXTRA_LINK_DIRS ${NIWG_ROOT}) LIST(APPEND EXTRA_LIBS NIWGReWeight) diff --git a/cmake/NuWroSetup.cmake b/cmake/NuWroSetup.cmake index af9d455..c662c1a 100644 --- a/cmake/NuWroSetup.cmake +++ b/cmake/NuWroSetup.cmake @@ -1,111 +1,111 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(NOT NUWRO_INPUT_FILE STREQUAL "") if(NOT EXISTS ${NUWRO_INPUT_FILE}) cmessage(FATAL_ERROR "Expected -DNUWRO_INPUT_FILE to point to a valid input file. Cannot find: '${NUWRO_INPUT_FILE}'") endif() if(CMAKE_BUILD_TYPE MATCHES DEBUG) BuildROOTProject(NuWro_event1 ${NUWRO_INPUT_FILE} "event,vec,vect,particle,flags,params,line" STATIC) SET(ROOTLIBNAME "libNuWro_event1.a") else(CMAKE_BUILD_TYPE MATCHES RELEASE) BuildROOTProject(NuWro_event1 ${NUWRO_INPUT_FILE} "event,vec,vect,particle,flags,params,line" SHARED) SET(ROOTLIBNAME "libNuWro_event1.so") endif() ADD_CUSTOM_TARGET(NuWro_event1HeaderLink ALL COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/NuWro_event1/event.h ${CMAKE_BINARY_DIR}/NuWro_event1/event1.h DEPENDS NuWro_event1) LIST(APPEND EXTRA_CXX_FLAGS -D__NUWRO_ENABLED__) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/NuWro_event1) LIST(APPEND EXTRA_LINK_DIRS ${CMAKE_BINARY_DIR}) LIST(APPEND EXTRA_LIBS NuWro_event1) LIST(APPEND PROJECTWIDE_EXTRA_DEPENDENCIES NuWro_event1HeaderLink ) install(TARGETS NuWro_event1 DESTINATION lib) SET(NUWRO_BUILT_FROM_FILE TRUE) else() if(NUWRO STREQUAL "") cmessage(FATAL_ERROR "Variable NUWRO is not defined. " "This must be set to point to a prebuilt NuWro instance.") endif() # If you are using a version of NuWro without reweighting use this to compile. if(USE_NuWro_RW) if(NUWRO_INC STREQUAL "") cmessage(FATAL_ERROR "Variable NUWRO_INC is not defined. " "This must be set to point to an installed NuWro instance.") endif() LIST(APPEND EXTRA_CXX_FLAGS -D__NUWRO_ENABLED__ -D__NUWRO_REWEIGHT_ENABLED__) if(USE_NuWro_SRW_Event) LIST(APPEND EXTRA_CXX_FLAGS -D__USE_NUWRO_SRW_EVENTS__) endif() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUWRO}/src ${NUWRO}/src/reweight ${NUWRO_INC}/nuwro) LIST(APPEND EXTRA_LINK_DIRS ${NUWRO}/build/${CMAKE_SYSTEM_NAME}/lib) LIST(APPEND EXTRA_LIBS reweight event) else () LIST(APPEND EXTRA_CXX_FLAGS -D__NUWRO_ENABLED__) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUWRO}/src) if(NOT EXISTS ${NUWRO}/bin/event1.so) if(EXISTS ${NUWRO}/build/${CMAKE_SYSTEM_NAME}/lib) if(NUWRO_INC STREQUAL "") cmessage(FATAL_ERROR "Variable NUWRO_INC is not defined. " "This must be set to point to an installed NuWro instance.") endif() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUWRO_INC}/nuwro) LIST(APPEND EXTRA_LINK_DIRS ${NUWRO}/build/${CMAKE_SYSTEM_NAME}/lib) LIST(APPEND EXTRA_LIBS -Wl,--no-as-needed event -Wl,--as-needed) else() cmessage(FATAL_ERROR "Expected to find the NuWro event library in: ${NUWRO}/bin/event1.so, or if using NuWro with reweight support: ${NUWRO}/build/${CMAKE_SYSTEM_NAME}/lib/libevent.a. Is NuWro built?") endif() else() LIST(APPEND EXTRA_SHAREDOBJS -Wl,--no-as-needed ${NUWRO}/bin/event1.so -Wl,--as-needed) endif() endif() set(NEED_PYTHIA6 TRUE) set(NEED_ROOTPYTHIA6 TRUE) endif() diff --git a/cmake/Prob3++Setup.cmake b/cmake/Prob3++Setup.cmake index 03de820..3cde3fe 100644 --- a/cmake/Prob3++Setup.cmake +++ b/cmake/Prob3++Setup.cmake @@ -1,42 +1,42 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(USE_PROB3PP) LIST(APPEND EXTRA_CXX_FLAGS -D__PROB3PP_ENABLED__) ExternalProject_Add(prob3pp PREFIX "${CMAKE_BINARY_DIR}/Ext" URL "http://webhome.phy.duke.edu/~raw22/public/Prob3++/Prob3++.20121225.tar.gz" CONFIGURE_COMMAND "" BUILD_IN_SOURCE 1 UPDATE_COMMAND "" BUILD_COMMAND CXXFLAGS=-fPIC CFLAGS=-fPIC make INSTALL_COMMAND "" ) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${CMAKE_BINARY_DIR}/Ext/src/prob3pp) LIST(APPEND EXTRA_LINK_DIRS ${CMAKE_BINARY_DIR}/Ext/src/prob3pp) LIST(APPEND EXTRA_LIBS ThreeProb_2.10) cmessage(STATUS "Using Prob3++ 2.10") endif() diff --git a/cmake/ROOTSetup.cmake b/cmake/ROOTSetup.cmake index 151ce2f..00520a2 100644 --- a/cmake/ROOTSetup.cmake +++ b/cmake/ROOTSetup.cmake @@ -1,172 +1,172 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if ( NOT DEFINED ENV{ROOTSYS} ) cmessage (FATAL_ERROR "$ROOTSYS is not defined, please set up ROOT first.") else() cmessage(STATUS "Using ROOT installed at $ENV{ROOTSYS}") set(CMAKE_ROOTSYS $ENV{ROOTSYS}) endif() # Get cflags from ROOT execute_process (COMMAND root-config --cflags OUTPUT_VARIABLE ROOT_CXX_FLAGS_RAW OUTPUT_STRIP_TRAILING_WHITESPACE) string(REPLACE " " ";" ROOT_CXX_FLAGS "${ROOT_CXX_FLAGS_RAW}") # Get libdir from ROOT execute_process (COMMAND root-config --libdir OUTPUT_VARIABLE ROOT_LIBDIR OUTPUT_STRIP_TRAILING_WHITESPACE) # Get version from ROOT execute_process (COMMAND root-config --version OUTPUT_VARIABLE ROOT_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) # Get features from ROOT execute_process (COMMAND root-config --features OUTPUT_VARIABLE ROOT_FEATURES OUTPUT_STRIP_TRAILING_WHITESPACE) LIST(APPEND EXTRA_LINK_DIRS ${ROOT_LIBDIR}) LIST(APPEND ROOT_LIBS Core Cint RIO XMLIO Net Hist Graf Graf3d Gpad Tree Rint Postscript Matrix Physics MathMore MathCore Thread EG Geom GenVector) cmessage(STATUS "Checking ROOT version: ${ROOT_VERSION}") string(REGEX MATCH "^6.*" ROOTVERSIXMATCH ${ROOT_VERSION}) if(ROOTVERSIXMATCH) cmessage(STATUS "Using ROOT6, We are essentially flying blind here.") LIST(REMOVE_ITEM ROOT_LIBS Cint) LIST(APPEND EXTRA_CXX_FLAGS -DROOT6_USE_FIT_FITTER_INTERFACE -DROOT6) set(USE_ROOT6 True) else() string(REGEX MATCH "5.34/([0-9]+)" ROOTVERSMATCH ${ROOT_VERSION}) if(NOT ROOTVERSMATCH OR ${CMAKE_MATCH_1} LESS "19") cmessage(FATAL_ERROR "ROOT Version: ${ROOT_VERSION} has out of date minimizer interface, but minimizer functionality requested. Please configure with -DUSE_MINIMIZER=FALSE or update to 5.34/19 or greater to enable minimization features.") endif() endif() if(USE_MINIMIZER) if("${ROOT_FEATURES}" MATCHES "minuit2") cmessage(STATUS "ROOT built with MINUIT2 support") LIST(APPEND EXTRA_CXX_FLAGS -D__MINUIT2_ENABLED__) else() cmessage(FATAL_ERROR "ROOT built without MINUIT2 support but minimizer functionality requested. Either configure with -DUSE_MINIMIZER=FALSE or use a version of ROOT with MINUIT2 support.") endif() endif() if("${ROOT_FEATURES}" MATCHES "opengl") cmessage(STATUS "ROOT built with OpenGL support") LIST(APPEND ROOT_LIBS RGL) endif() if(DEFINED NEED_ROOTPYTHIA6 AND NEED_ROOTPYTHIA6) LIST(APPEND ROOT_LIBS EGPythia6 Pythia6) endif() cmessage ( STATUS "[ROOT]: root-config --version: ${ROOT_VERSION} ") cmessage ( STATUS "[ROOT]: root-config --cflags : ${ROOT_CXX_FLAGS} ") cmessage ( STATUS "[ROOT]: root-config --libs : ${ROOT_LD_FLAGS} ") LIST(APPEND EXTRA_CXX_FLAGS ${ROOT_CXX_FLAGS}) #Helper functions for building dictionaries function(GenROOTDictionary OutputDictName Header LinkDef) get_directory_property(incdirs INCLUDE_DIRECTORIES) string(REPLACE ";" ";-I" LISTDIRINCLUDES "-I${incdirs}") string(REPLACE " " ";" LISTCPPFLAGS "${EXTRA_CXX_FLAGS}") #ROOT5 CINT cannot handle it. list(REMOVE_ITEM LISTCPPFLAGS "-std=c++11") message(STATUS "LISTCPPFLAGS: ${LISTCPPFLAGS}") message(STATUS "LISTINCLUDES: ${LISTDIRINCLUDES}") #Learn how to generate the Dict.cxx and Dict.hxx add_custom_command( OUTPUT "${OutputDictName}.cxx" "${OutputDictName}.h" COMMAND rootcint ARGS -f ${OutputDictName}.cxx -c -p ${LISTDIRINCLUDES} ${LISTCPPFLAGS} ${Header} ${LinkDef} DEPENDS ${Header};${LinkDef}) endfunction() function(BuildROOTProject ProjectName InputFile CommaSeparatedClassesToDump LIBLINKMODE) string(REPLACE "," ";" HeadersToDump ${CommaSeparatedClassesToDump}) set(OUTPUTFILES ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectSource.cxx ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}LinkDef.h ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectHeaders.h ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectInstances.h) cmessage(STATUS "As part of ROOT project: ${ProjectName}") foreach (header ${HeadersToDump}) LIST(APPEND OUTPUTFILES "${CMAKE_BINARY_DIR}/${ProjectName}/${header}.h") cmessage(STATUS "Will generate: ${CMAKE_BINARY_DIR}/${ProjectName}/${header}.h") endforeach() add_custom_command( OUTPUT ${OUTPUTFILES} COMMAND ${CMAKE_BINARY_DIR}/src/Utils/DumpROOTClassesFromVector ARGS ${InputFile} ${CMAKE_BINARY_DIR}/${ProjectName} ${CommaSeparatedClassesToDump} VERBATIM DEPENDS DumpROOTClassesFromVector) add_custom_target(${ProjectName}_sources DEPENDS ${OUTPUTFILES}) GenROOTDictionary( ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectDict ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectHeaders.h ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}LinkDef.h ) add_custom_target(${ProjectName}ProjectDict DEPENDS ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectDict.cxx ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectDict.h ) # add_dependencies(${ProjectName}ProjectDict ${ProjectName}_sources) #ProjectSource.cxx includes ProjectDict.cxx, so no need to add to compilation. set(ROAA_SOURCEFILES ${CMAKE_BINARY_DIR}/${ProjectName}/${ProjectName}ProjectSource.cxx) add_library(${ProjectName} ${LIBLINKMODE} ${ROAA_SOURCEFILES}) add_dependencies(${ProjectName} ${ProjectName}ProjectDict) endfunction() diff --git a/cmake/ReweightEnginesSetup.cmake b/cmake/ReweightEnginesSetup.cmake index 59f745a..46810fc 100644 --- a/cmake/ReweightEnginesSetup.cmake +++ b/cmake/ReweightEnginesSetup.cmake @@ -1,101 +1,101 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(NOT USE_REWEIGHT) LIST(APPEND EXTRA_CXX_FLAGS -D__NO_REWEIGHT__) endif() ################################## T2K ###################################### if(USE_T2K) include(${CMAKE_SOURCE_DIR}/cmake/T2KSetup.cmake) cmessage(STATUS "Using T2K Reweight engine.") set(USE_T2K TRUE CACHE BOOL "Whether to enable T2KReWeight support. Requires external libraries. " FORCE) endif() ################################## NIWG ###################################### if(USE_NIWG) include(${CMAKE_SOURCE_DIR}/cmake/NIWGSetup.cmake) cmessage(STATUS "Using NIWG Reweight engine.") set(USE_NIWG TRUE CACHE BOOL "Whether to enable (T2K) NIWG ReWeight support. Requires external libraries. " FORCE) endif() ################################## MINERvA ###################################### if(USE_MINERvA_RW) include(${CMAKE_SOURCE_DIR}/cmake/MINERvASetup.cmake) cmessage(STATUS "Using MINERvA Reweight engine.") set(USE_MINERvA_RW TRUE CACHE BOOL "Whether to enable MINERvA ReWeight support. " FORCE) endif() ################################## NEUT ###################################### if(USE_NEUT) include(${CMAKE_SOURCE_DIR}/cmake/NEUTSetup.cmake) cmessage(STATUS "Using NEUT Reweight engine.") set(USE_NEUT TRUE CACHE BOOL "Whether to enable NEUT (reweight) support. Requires external libraries. " FORCE) endif() ################################# NuWro ###################################### if(USE_NuWro) include(${CMAKE_SOURCE_DIR}/cmake/NuWroSetup.cmake) cmessage(STATUS "Using NuWro Reweight engine.") set(USE_NuWro TRUE CACHE BOOL "Whether to enable NuWro support. " FORCE) endif() ################################## GENIE ##################################### if(USE_GENIE) include(${CMAKE_SOURCE_DIR}/cmake/GENIESetup.cmake) cmessage(STATUS "Using GENIE.") set(USE_GENIE TRUE CACHE BOOL "Whether to enable GENIE support. Requires external libraries. " FORCE) endif() ################################################################################ ################################ NOvARwgt #################################### if(USE_NOvARwgt) include(${CMAKE_SOURCE_DIR}/cmake/NOvARwgtSetup.cmake) cmessage(STATUS "Using NOvARwgt Reweight engine.") set(USE_NOvARwgt TRUE CACHE BOOL "Whether to enable NOvARwgt (reweight) support. Requires external libraries. " FORCE) endif() ################################################################################ if(USE_NUSYST) include(${CMAKE_SOURCE_DIR}/cmake/nusystematicsSetup.cmake) cmessage(STATUS "Using NOvARwgt Reweight engine.") set(USE_NUSYST TRUE CACHE BOOL "Whether to enable DUNERwt (reweight) support. Requires external libraries. " FORCE) endif() ################################ Prob3++ #################################### include(${CMAKE_SOURCE_DIR}/cmake/Prob3++Setup.cmake) ################################################################################ cmessage(STATUS "Reweight engine include directories: ${RWENGINE_INCLUDE_DIRECTORIES}") if(NEED_ROOTEVEGEN) cmessage(STATUS "Require ROOT eve generation libraries") LIST(REVERSE ROOT_LIBS) LIST(APPEND ROOT_LIBS Gui Ged Geom TreePlayer EG Eve) LIST(REVERSE ROOT_LIBS) endif() if(NEED_ROOTPYTHIA6) cmessage(STATUS "Require ROOT Pythia6 libraries") LIST(APPEND ROOT_LIBS EGPythia6) endif() LIST(APPEND EXTRA_LIBS ${ROOT_LIBS}) diff --git a/cmake/T2KSetup.cmake b/cmake/T2KSetup.cmake index 5e59737..c67ef53 100644 --- a/cmake/T2KSetup.cmake +++ b/cmake/T2KSetup.cmake @@ -1,40 +1,40 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(T2KREWEIGHT STREQUAL "") cmessage(FATAL_ERROR "Variable T2KREWEIGHT is not defined. Either configure with -DT2KREWEIGHT or \"\$ export T2KREWEIGHT=/path/to/T2KReWeight\". This must be set to point to a prebuilt T2KReWeight instance.") endif() LIST(APPEND EXTRA_CXX_FLAGS -D__T2KREW_ENABLED__ ) # First check the OAANALYSIS libs (need to grab some headers for T2KReWeight linking if compiled with oaAnalysisReader) IF(NOT $ENV{OAANALYSISREADERROOT} STREQUAL "") cmessage(STATUS "Found OAANALYSISREADERROOT $ENV{OAANALYSISREADERROOT}, appending...") LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES $ENV{OAANALYSISREADERROOT}/$ENV{OAANALYSISREADERCONFIG}) LIST(APPEND EXTRA_LINK_DIRS $ENV{OAANALYSISREADERROOT}/$ENV{OAANALYSISREADERCONFIG}) LIST(APPEND EXTRA_LIBS oaAnalysisReader) # Don't have to append this; should be appeneded in ${T2KReWeight/src/T2KBuild.h} #LIST(APPEND EXTRA_CXX_FLAGS -D__T2KRW_OAANALYSIS_ENABLED__) endif() LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${T2KREWEIGHT}/src/) LIST(APPEND EXTRA_LINK_DIRS ${T2KREWEIGHT}/lib) LIST(APPEND EXTRA_LIBS T2KReWeight) diff --git a/cmake/c++CompilerSetup.cmake b/cmake/c++CompilerSetup.cmake index 11f6f33..9ac7ddc 100644 --- a/cmake/c++CompilerSetup.cmake +++ b/cmake/c++CompilerSetup.cmake @@ -1,122 +1,122 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(USE_OMP) LIST(APPEND EXTRA_CXX_FLAGS -fopenmp) endif() if(USE_DYNSAMPLES) LIST(APPEND EXTRA_LIBS dl) LIST(APPEND EXTRA_CXX_FLAGS -D__USE_DYNSAMPLES__) endif() set(CXX_WARNINGS -Wall ) cmessage(DEBUG "EXTRA_CXX_FLAGS: ${EXTRA_CXX_FLAGS}") string(REPLACE ";" " " STR_EXTRA_CXX_FLAGS "${EXTRA_CXX_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${STR_EXTRA_CXX_FLAGS} ${CXX_WARNINGS}") set(CMAKE_Fortran_FLAGS_RELEASE "-fPIC") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0") if(USE_DYNSAMPLES) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fPIC") set(CMAKE_Fortran_FLAGS_DEBUG "-fPIC") endif() set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -fPIC -O3") if(CMAKE_BUILD_TYPE MATCHES DEBUG) set(CURRENT_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_DEBUG}) elseif(CMAKE_BUILD_TYPE MATCHES RELEASE) set(CURRENT_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS_RELEASE}) else() cmessage(FATAL_ERROR "[ERROR]: Unknown CMAKE_BUILD_TYPE (\"${CMAKE_BUILD_TYPE}\"): Should be \"DEBUG\" or \"RELEASE\".") endif() SET(STR_EXTRA_LINK_DIRS) if(NOT EXTRA_LINK_DIRS STREQUAL "") string(REPLACE ";" " -L" STR_EXTRA_LINK_DIRS "-L${EXTRA_LINK_DIRS}") endif() SET(STR_EXTRA_LIBS) if(NOT EXTRA_LIBS STREQUAL "") SET(STR_EXTRA_LIBS_NO_SCRUB_LINKOPTS) string(REPLACE ";" " -l" STR_EXTRA_LIBS_NO_SCRUB_LINKOPTS "-l${EXTRA_LIBS}") string(REPLACE "-l-" "-" STR_EXTRA_LIBS ${STR_EXTRA_LIBS_NO_SCRUB_LINKOPTS}) endif() SET(STR_EXTRA_SHAREDOBJS) if(NOT EXTRA_SHAREDOBJS STREQUAL "") string(REPLACE ";" " " STR_EXTRA_SHAREDOBJS "${EXTRA_SHAREDOBJS}") endif() SET(STR_EXTRA_LINK_FLAGS) if(NOT EXTRA_LINK_FLAGS STREQUAL "") string(REPLACE ";" " " STR_EXTRA_LINK_FLAGS "${EXTRA_LINK_FLAGS}") endif() cmessage(DEBUG "EXTRA_LINK_DIRS: ${STR_EXTRA_LINK_DIRS}") cmessage(DEBUG "EXTRA_LIBS: ${STR_EXTRA_LIBS}") cmessage(DEBUG "EXTRA_SHAREDOBJS: ${STR_EXTRA_SHAREDOBJS}") cmessage(DEBUG "EXTRA_LINK_FLAGS: ${STR_EXTRA_LINK_FLAGS}") if(NOT STR_EXTRA_LINK_DIRS STREQUAL "" AND NOT STR_EXTRA_LIBS STREQUAL "") SET(CMAKE_DEPENDLIB_FLAGS "${STR_EXTRA_LINK_DIRS} ${STR_EXTRA_LIBS}") endif() if(NOT EXTRA_SHAREDOBJS STREQUAL "") if(NOT STR_EXTRA_LINK_FLAGS STREQUAL "") SET(STR_EXTRA_LINK_FLAGS "${STR_EXTRA_SHAREDOBJS} ${STR_EXTRA_LINK_FLAGS}") else() SET(STR_EXTRA_LINK_FLAGS "${STR_EXTRA_SHAREDOBJS}") endif() endif() if(NOT EXTRA_LINK_FLAGS STREQUAL "") if(NOT CMAKE_LINK_FLAGS STREQUAL "") SET(CMAKE_LINK_FLAGS "${CMAKE_LINK_FLAGS} ${STR_EXTRA_LINK_FLAGS}") else() SET(CMAKE_LINK_FLAGS "${STR_EXTRA_LINK_FLAGS}") endif() endif() if(USE_OMP) cmessage(FATAL_ERROR "No OMP features currently enabled so this is a FATAL_ERROR to let you know that you don't gain anything with this declaration.") endif() string(REPLACE ";" " " NUIS_EXE_FLAGS "${EXTRA_EXE_FLAGS}") string(STRIP ${CMAKE_CXX_FLAGS} CMAKE_CXX_FLAGS) string(STRIP ${CMAKE_CXX_FLAGS_RELEASE} CMAKE_CXX_FLAGS_RELEASE) string(STRIP ${CMAKE_CXX_FLAGS_DEBUG} CMAKE_CXX_FLAGS_DEBUG) string(STRIP ${CMAKE_LINK_FLAGS} CMAKE_LINK_FLAGS) string(STRIP ${CMAKE_DEPENDLIB_FLAGS} CMAKE_DEPENDLIB_FLAGS) if (VERBOSE) cmessage (STATUS "C++ Compiler : ${CXX_COMPILER_NAME}") cmessage (STATUS " flags : ${CMAKE_CXX_FLAGS}") cmessage (STATUS " Release flags : ${CMAKE_CXX_FLAGS_RELEASE}") cmessage (STATUS " Debug flags : ${CMAKE_CXX_FLAGS_DEBUG}") cmessage (STATUS " Link Flags : ${CMAKE_LINK_FLAGS}") cmessage (STATUS " Lib Flags : ${CMAKE_DEPENDLIB_FLAGS}") endif() diff --git a/cmake/cacheVariables.cmake b/cmake/cacheVariables.cmake index c23094a..c180ab6 100644 --- a/cmake/cacheVariables.cmake +++ b/cmake/cacheVariables.cmake @@ -1,247 +1,247 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ function(CheckAndSetDefaultEnv VARNAME DEFAULT CACHETYPE DOCSTRING ENVNAME) #cmessage(DEBUG "Trying to assign variable ${VARNAME} into the cache.") if(NOT DEFINED ${VARNAME}) if(DEFINED ENV{${ENVNAME}} AND NOT $ENV{${ENVNAME}} STREQUAL "") set(${VARNAME} $ENV{${ENVNAME}} CACHE ${CACHETYPE} ${DOCSTRING}) cmessage(DEBUG " Read ${VARNAME} from ENVVAR ${ENVNAME} as $ENV{${ENVNAME}}.") else() set(${VARNAME} ${DEFAULT} CACHE ${CACHETYPE} ${DOCSTRING}) endif() else() set(${VARNAME} ${${VARNAME}} CACHE ${CACHETYPE} ${DOCSTRING}) unset(${VARNAME}) endif() cmessage(CACHE "--Set cache variable: \"${VARNAME}\" to \"${${VARNAME}}\", in cache ${CACHETYPE}.") endfunction() function(CheckAndSetDefaultCache VARNAME DEFAULT CACHETYPE DOCSTRING) # cmessage(DEBUG "Trying to assign variable ${VARNAME} into the cache.") if(NOT DEFINED ${VARNAME}) set(${VARNAME} ${DEFAULT} CACHE ${CACHETYPE} ${DOCSTRING}) else() set(${VARNAME} ${${VARNAME}} CACHE ${CACHETYPE} ${DOCSTRING}) unset(${VARNAME}) endif() cmessage(CACHE "--Set cache variable: \"${VARNAME}\" to \"${${VARNAME}}\", in cache ${CACHETYPE}.") endfunction() function(CheckAndSetDefault VARNAME DEFAULT) # cmessage(DEBUG "Trying to assign variable ${VARNAME}.") if(NOT DEFINED ${VARNAME}) set(${VARNAME} ${DEFAULT} PARENT_SCOPE) set(${VARNAME} ${DEFAULT}) endif() cmessage(CACHE "--Set variable: \"${VARNAME}\" to \"${${VARNAME}}\".") endfunction() CheckAndSetDefaultCache(VERBOSE TRUE BOOL "Whether to configure loudly.") set (CMAKE_SKIP_BUILD_RPATH TRUE) #Changes default install path to be a subdirectory of the build dir. #Can set build dir at configure time with -DCMAKE_INSTALL_PREFIX=/install/path if(CMAKE_INSTALL_PREFIX STREQUAL "" OR CMAKE_INSTALL_PREFIX STREQUAL "/usr/local") set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}") elseif(NOT DEFINED CMAKE_INSTALL_PREFIX) set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}") endif() if(CMAKE_BUILD_TYPE STREQUAL "") set(CMAKE_BUILD_TYPE DEBUG) elseif(NOT DEFINED CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE DEBUG) endif() CheckAndSetDefaultCache(EXTRA_SETUP_SCRIPT "" PATH "The path to an extra script to inject into the NUISANCE setup script. <>") CheckAndSetDefaultCache(USE_MINIMIZER TRUE BOOL "Whether we are using the ROOT minimization libraries. ") CheckAndSetDefaultCache(USE_REWEIGHT TRUE BOOL "Whether we are expect to be able to build the reweighting libraries of enabled generators. ") CheckAndSetDefaultCache(USE_ROOT6 FALSE INTERNAL "Whether we are using the ROOT 6. ") CheckAndSetDefaultCache(USE_HEPMCNUEVT FALSE BOOL "Whether to enable HepMC3 input support. ") CheckAndSetDefaultCache(USE_NUSYST FALSE BOOL "Whether to enable DUNE Reweight support. ") CheckAndSetDefaultEnv(NUSYST_ROOT "" PATH "Path to nusystematics install directory <>" NUSYST_ROOT) CheckAndSetDefaultEnv(SYSTTOOLS_ROOT "" PATH "Path to systematicstools install directory <>" SYSTTOOLS_ROOT) CheckAndSetDefaultCache(USE_HEPMC FALSE BOOL "Whether to enable HepMC input support. ") CheckAndSetDefaultEnv(HEPMC "" PATH "Path to HepMC source tree root directory. Overrides environment variable \$HEPMC <>" HEPMC) CheckAndSetDefaultCache(HEPMC_MOMUNIT "GEV" STRING "HepMC momentum units [MEV|GEV]. ") CheckAndSetDefaultCache(HEPMC_LENUNIT "CM" STRING "HepMC momentum units [MM|CM]. ") CheckAndSetDefaultCache(HEPMC_USED_EP FALSE INTERNAL "Whether we built HepMC or not. ") CheckAndSetDefaultCache(USE_NEUT FALSE BOOL "Whether to enable NEUT (reweight) support. Requires external libraries. ") CheckAndSetDefaultEnv(NEUT_VERSION FALSE STRING "NEUT version string, e.g. 5.4.0. <5.4.0>" NEUT_VERSION) CheckAndSetDefaultEnv(NEUT_ROOT "" PATH "Path to NEUT source tree root directory. Overrides environment variable \$NEUT_ROOT <>" NEUT_ROOT) CheckAndSetDefaultEnv(CERN "" PATH "Path to CERNLIB source tree root directory that NEUT was built against. Overrides environment variable \$CERN <>" CERN) CheckAndSetDefaultEnv(CERN_LEVEL "" STRING "CERNLIB Library version. Overrides environment variable \$CERN_LEVEL <>" CERN_LEVEL) CheckAndSetDefaultCache(USE_NuWro FALSE BOOL "Whether to enable NuWro support. ") CheckAndSetDefaultEnv(NUWRO "" PATH "Path to NuWro source tree root directory. Overrides environment variable \$NUWRO <>" NUWRO) CheckAndSetDefaultEnv(NUWRO_INC "" PATH "Path to NuWro installed includes directory, needs to contain \"params_all.h\". Overrides environment variable \$NUWRO_INC <>" NUWRO_INC) CheckAndSetDefaultCache(NUWRO_INPUT_FILE "" FILEPATH "Path to an input NuWro event vector, which can be used to build NuWro i/o libraries. <>") CheckAndSetDefaultCache(NUWRO_BUILT_FROM_FILE FALSE INTERNAL "Whether the NuWro libraries were built by NUISANCE. ") CheckAndSetDefaultCache(USE_NuWro_RW FALSE BOOL "Whether to try and build support for NuWro reweighting. ") CheckAndSetDefaultCache(USE_NuWro_SRW_Event FALSE BOOL "Whether to use cut down NuWro reweight event format. Requires NuWro reweight. ") CheckAndSetDefaultCache(USE_GENIE FALSE BOOL "Whether to enable GENIE support. Requires external libraries. ") CheckAndSetDefaultCache(GENIE_VERSION "AUTO" STRING "GENIE Version ") CheckAndSetDefaultEnv(GENIE "" PATH "Path to GENIE source tree root directory. Overrides environment variable \$GENIE <>" GENIE) CheckAndSetDefaultEnv(GENIE_REWEIGHT "" PATH "Path to GENIE ReWeight directory. Only relevant for GENIE v3+. Overrides environment variable \$GENIE_REWEIGHT <>" GENIE_REWEIGHT) CheckAndSetDefaultCache(GENIE_EMPMEC_REWEIGHT FALSE BOOL "Whether to use GENIE EMP MEC reweight (requires custom GENIE) ") CheckAndSetDefaultCache(USE_GENIE_XSECMEC FALSE BOOL "Whether to use GENIE MEC reweight (requires custom GENIE) ") CheckAndSetDefaultEnv(LHAPDF_LIB "" PATH "Path to pre-built LHAPDF libraries. Overrides environment variable \$LHAPDF_LIB. <>" LHAPDF_LIB) CheckAndSetDefaultEnv(LHAPDF_INC "" PATH "Path to installed LHAPDF headers. Overrides environment variable \$LHAPDF_INC. <>" LHAPDF_INC) CheckAndSetDefaultEnv(LHAPATH "" PATH "Path to LHA PDF inputs. Overrides environment variable \$LHAPATH. <>" LHAPATH) CheckAndSetDefaultEnv(LIBXML2_LIB "" PATH "Path to pre-built LIBXML2 libraries. Overrides environment variable \$LIBXML2_LIB. <>" LIBXML2_LIB) CheckAndSetDefaultEnv(LIBXML2_INC "" PATH "Path to installed LIBXML2 headers. Overrides environment variable \$LIBXML2_INC. <>" LIBXML2_INC) CheckAndSetDefaultEnv(LOG4CPP_LIB "" PATH "Path to pre-built LOG4CPP libraries. Overrides environment variable \$LOG4CPP_LIB. <>" LOG4CPP_LIB) CheckAndSetDefaultEnv(LOG4CPP_INC "" PATH "Path to installed LOG4CPP headers. Overrides environment variable \$LOG4CPP_INC. <>" LOG4CPP_INC) CheckAndSetDefaultEnv(GSL_LIB "" PATH "Path to pre-built gsl libraries. Overrides environment variable \$GSL_LIB. <>" GSL_LIB) CheckAndSetDefaultEnv(GSL_INC "" PATH "Path to installed gsl headers. Overrides environment variable \$GSL_INC. <>" GSL_INC) CheckAndSetDefaultCache(USE_T2K FALSE BOOL "Whether to enable T2KReWeight support. Requires external libraries. ") CheckAndSetDefaultEnv(T2KREWEIGHT "" PATH "Path to installed T2KReWeight. Overrides environment variable \$T2KREWEIGHT. <>" T2KREWEIGHT) CheckAndSetDefaultCache(USE_NIWG FALSE BOOL "Whether to enable (T2K) NIWG ReWeight support. Requires external libraries. ") CheckAndSetDefaultEnv(NIWG_ROOT "" PATH "Path to installed NIWGReWeight. Overrides environment variable \$NIWG. <>" NIWG) CheckAndSetDefaultCache(USE_MINERvA_RW FALSE BOOL "Whether to enable MINERvA ReWeight support. ") CheckAndSetDefaultCache(USE_NOvARwgt FALSE BOOL "Whether to enable NOvA ReWeight support. ") CheckAndSetDefaultEnv(NOVARWGT "" PATH "Path to directory containing libPythia6.so. Overrides environment variable \$NOVARWGT <>" NOVARWGT) CheckAndSetDefaultEnv(PYTHIA6 "" PATH "Path to directory containing libPythia6.so. Overrides environment variable \$PYTHIA6 <>" PYTHIA6) CheckAndSetDefaultEnv(PYTHIA8 "" PATH "Path to directory containing libPythia8.so. Overrides environment variable \$PYTHIA8 <>" PYTHIA8) CheckAndSetDefaultCache(USE_PYTHIA8 FALSE BOOL "Whether to enable PYTHIA8 event support. ") CheckAndSetDefaultCache(USE_GiBUU TRUE BOOL "Whether to enable GiBUU event support. ") CheckAndSetDefaultCache(BUILD_GiBUU FALSE BOOL "Whether to build supporting GiBUU event tools along with a patched version of GiBUU. ") CheckAndSetDefaultCache(USE_NUANCE TRUE BOOL "Whether to enable NUANCE event support. ") CheckAndSetDefaultCache(USE_PROB3PP FALSE BOOL "Whether to download and compile in Prob3++ support. ") CheckAndSetDefaultCache(NO_EXTERNAL_UPDATE FALSE BOOL "Whether to perform the update target for external dependencies. Note this may produce errors for CMake < 3.8 where a bug was fixed for the feature that this option invokes. ") CheckAndSetDefaultCache(USE_GPERFTOOLS FALSE BOOL "Whether to compile in google performance tools. ") CheckAndSetDefault(NEED_PYTHIA6 FALSE) CheckAndSetDefault(NEED_PYTHIA8 FALSE) CheckAndSetDefault(NEED_ROOTEVEGEN FALSE) CheckAndSetDefault(NEED_ROOTPYTHIA6 FALSE) CheckAndSetDefaultCache(USE_OMP FALSE BOOL "Whether to enable multicore features (there currently are none...). ") CheckAndSetDefaultCache(USE_DYNSAMPLES TRUE BOOL "Whether to enable the dynamic sample loader. ") CheckAndSetDefault(NO_EXPERIMENTS FALSE) cmessage(STATUS "NO_EXPERIMENTS: ${NO_EXPERIMENTS}") CheckAndSetDefaultCache(NO_ANL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build ANL samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_ArgoNeuT ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build ArgoNeuT samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_BEBC ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build BEBC samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_BNL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build BNL samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_FNAL ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build FNAL samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_GGM ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build GGM samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_K2K ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build K2K samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_MINERvA ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build MINERvA samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_MiniBooNE ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build MiniBooNE samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_T2K ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build T2K samples. <-DNO_EXPERIMENTS=FALSE>") CheckAndSetDefaultCache(NO_SciBooNE ${NO_EXPERIMENTS} BOOL "Whether to *NOT* build SciBooNE samples. <-DNO_EXPERIMENTS=FALSE>") function(SAYVARS) LIST(APPEND VARS USE_HEPMC HEPMC HEPMC_MOMUNIT HEPMC_LENUNIT HEPMC_USED_EP USE_NEUT NEUT_VERSION NEUT_ROOT CERN CERN_LEVEL USE_NuWro NUWRO NUWRO_INC NUWRO_INPUT_FILE NUWRO_BUILT_FROM_FILE USE_GENIE GENIE_VERSION GENIE GENIE_REWEIGHT LHAPDF_LIB LHAPDF_INC LHAPATH LIBXML2_LIB LIBXML2_INC LOG4CPP_LIB LOG4CPP_INC GSL_LIB GSL_INC PYTHIA6 PYTHIA8 USE_PYTHIA8 USE_T2K T2KREWEIGHT USE_NIWG NIWG_ROOT USE_MINERvA_RW USE_NOvARwgt NOVARWGT USE_GiBUU BUILD_GiBUU USE_NUANCE USE_PROB3PP NO_EXTERNAL_UPDATE USE_GPERFTOOLS NO_EXPERIMENTS NO_ANL NO_ArgoNeuT NO_BEBC NO_BNL NO_FNAL NO_GGM NO_K2K NO_MINERvA NO_MiniBooNE NO_T2K NO_SciBooNE) foreach(v ${VARS}) if(DEFINED ${v}) cmessage(DEBUG "VARIABLE: \"${v}\" = \"${${v}}\"") endif() endforeach(v) endfunction() diff --git a/cmake/docsSetup.cmake b/cmake/docsSetup.cmake index 618a51f..24fd680 100644 --- a/cmake/docsSetup.cmake +++ b/cmake/docsSetup.cmake @@ -1,43 +1,43 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ # add a target to generate API documentation with Doxygen find_package(Doxygen) if(DOXYGEN_FOUND) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc) configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/doc/Doxyfile @ONLY) add_custom_target(doc_generate ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/doc/Doxyfile WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc COMMENT "Generating documentation with Doxygen... (this will take a while)" VERBATIM ) add_custom_target(docs make WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/doc/latex COMMENT "Building latex documentation with Doxygen... (this will also take a while)" VERBATIM ) add_dependencies(docs doc_generate) install(FILES ${CMAKE_BINARY_DIR}/doc/latex/refman.pdf DESTINATION ${CMAKE_BINARY_DIR}/doc RENAME NUISANCE_${NUISANCE_VERSION_STRING}.pdf OPTIONAL) endif(DOXYGEN_FOUND) diff --git a/cmake/gperfSetup.cmake b/cmake/gperfSetup.cmake index dc33da7..ab1cf8e 100644 --- a/cmake/gperfSetup.cmake +++ b/cmake/gperfSetup.cmake @@ -1,59 +1,59 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(USE_GPERFTOOLS) ExternalProject_Add(libunwind PREFIX "${CMAKE_BINARY_DIR}/Ext" GIT_REPOSITORY "git://git.sv.gnu.org/libunwind.git" CONFIGURE_COMMAND ${CMAKE_BINARY_DIR}/Ext/src/libunwind/autogen.sh --prefix=${CMAKE_INSTALL_PREFIX} UPDATE_COMMAND "" BUILD_COMMAND make -j6 INSTALL_COMMAND make install ) ExternalProject_Add(gperftools PREFIX "${CMAKE_BINARY_DIR}/Ext" GIT_REPOSITORY "https://github.com/gperftools/gperftools.git" GIT_TAG "gperftools-2.5" CONFIGURE_COMMAND ./autogen.sh && ./configure --prefix=${CMAKE_INSTALL_PREFIX} CPPFLAGS=-I${CMAKE_INSTALL_PREFIX}/include LDFLAGS=-L${CMAKE_INSTALL_PREFIX}/lib BUILD_IN_SOURCE 1 UPDATE_COMMAND "" BUILD_COMMAND make -j6 INSTALL_COMMAND make install ) add_dependencies(gperftools libunwind) LIST(APPEND EXTRA_CXX_FLAGS -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free) LIST(APPEND EXTRA_LINK_DIRS ${CMAKE_INSTALL_PREFIX}/lib) ##Want to prepend them LIST(REVERSE EXTRA_LIBS) LIST(APPEND EXTRA_LIBS tcmalloc_and_profiler) LIST(REVERSE EXTRA_LIBS) cmessage(STATUS "Using google performance libraries") endif() diff --git a/cmake/nusystematicsSetup.cmake b/cmake/nusystematicsSetup.cmake index a15790c..42cc440 100644 --- a/cmake/nusystematicsSetup.cmake +++ b/cmake/nusystematicsSetup.cmake @@ -1,39 +1,39 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(NUSYST_ROOT STREQUAL "") cmessage(FATAL_ERROR "Variable NUSYST_ROOT is not defined. Either configure with -DNUSYST_ROOT or \"\$ export NUSYST_ROOT=/path/to/nusystematics\". This must be set to point to a prebuilt NuSystematics instance.") endif() if(SYSTTOOLS_ROOT STREQUAL "") cmessage(FATAL_ERROR "Variable SYSTTOOLS_ROOT is not defined. Either configure with -DSYSTTOOLS_ROOT or \"\$ export SYSTTOOLS_ROOT=/path/to/systematicstools\". This must be set to point to a prebuilt ART Systematics Tools instance.") endif() LIST(APPEND EXTRA_CXX_FLAGS -D__NUSYST_ENABLED__ -DNO_ART -std=c++1y -Wno-deprecated-declarations -Wno-deprecated) LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NUSYST_ROOT}/include ${SYSTTOOLS_ROOT}/include) LIST(APPEND EXTRA_LINK_DIRS ${NUSYST_ROOT}/lib ${SYSTTOOLS_ROOT}/lib) LIST(APPEND EXTRA_LIBS nusystematics_systproviders systematicstools_interface systematicstools_interpreters systematicstools_systproviders systematicstools_utility) diff --git a/cmake/pythia6Setup.cmake b/cmake/pythia6Setup.cmake index 3a496e6..97c54c7 100644 --- a/cmake/pythia6Setup.cmake +++ b/cmake/pythia6Setup.cmake @@ -1,36 +1,36 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(NEED_PYTHIA6) if(DEFINED ENV{PYTHIA6_LIBRARY} AND PYTHIA6 STREQUAL "") SET(PYTHIA6 $ENV{PYTHIA6_LIBRARY} CACHE PATH "Path to directory containing libPythia6.so. Overrides environment variable \$PYTHIA6 <>" FORCE) endif() if(PYTHIA6 STREQUAL "") cmessage(FATAL_ERROR "Variable PYTHIA6 is not defined. This must be set to point to a prebuilt PYTHIA6 instance, please set the \$PYTHIA6 environment variable or configure with -DPYTHIA6=/path/to/pythia6.") endif() LIST(APPEND EXTRA_LINK_DIRS ${PYTHIA6}) LIST(APPEND EXTRA_LIBS Pythia6 gfortran) endif() diff --git a/cmake/pythia8Setup.cmake b/cmake/pythia8Setup.cmake index d46002d..0ddd603 100644 --- a/cmake/pythia8Setup.cmake +++ b/cmake/pythia8Setup.cmake @@ -1,30 +1,30 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ if(NEED_PYTHIA8) if(PYTHIA8 STREQUAL "") cmessage(FATAL_ERROR "Variable PYTHIA8 is not defined. This must be set to point to a prebuilt PYTHIA8 instance, please set the \$PYTHIA8 environment variable or configure with -DPYTHIA8=/path/to/pythia8.") endif() LIST(APPEND EXTRA_LINK_DIRS ${PYTHIA8}) LIST(REVERSE EXTRA_LIBS) LIST(APPEND EXTRA_LIBS Pythia8 gfortran) LIST(REVERSE EXTRA_LIBS) endif() diff --git a/cmake/setup.sh.in b/cmake/setup.sh.in index eb10e30..7e55613 100644 --- a/cmake/setup.sh.in +++ b/cmake/setup.sh.in @@ -1,170 +1,170 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ #!/bin/sh ### Adapted from https://unix.stackexchange.com/questions/4965/keep-duplicates-out-of-path-on-source function add_to_PATH () { for d; do d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links if [ -z "$d" ]; then continue; fi # skip nonexistent directory if [ "$d" == "/usr/bin" ] || [ "$d" == "/usr/bin64" ] || [ "$d" == "/usr/local/bin" ] || [ "$d" == "/usr/local/bin64" ]; then case ":$PATH:" in *":$d:"*) :;; *) export PATH=$PATH:$d;; esac else case ":$PATH:" in *":$d:"*) :;; *) export PATH=$d:$PATH;; esac fi done } function add_to_LD_LIBRARY_PATH () { for d; do d=$(cd -- "$d" && { pwd -P || pwd; }) 2>/dev/null # canonicalize symbolic links if [ -z "$d" ]; then continue; fi # skip nonexistent directory if [ "$d" == "/usr/lib" ] || [ "$d" == "/usr/lib64" ] || [ "$d" == "/usr/local/lib" ] || [ "$d" == "/usr/local/lib64" ]; then case ":$LD_LIBRARY_PATH:" in *":$d:"*) :;; *) export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$d;; esac else case ":$LD_LIBRARY_PATH:" in *":$d:"*) :;; *) export LD_LIBRARY_PATH=$d:$LD_LIBRARY_PATH;; esac fi done } if [ "@EXTRA_SETUP_SCRIPT@" ]; then if [ ! -e @EXTRA_SETUP_SCRIPT@ ]; then echo "[WARN]: Extra setup script \"@EXTRA_SETUP_SCRIPT@\" requested, but could not be found. Skipping..." else echo "[INFO]: Sourcing extra setup from \"@EXTRA_SETUP_SCRIPT@\"." . @EXTRA_SETUP_SCRIPT@ fi fi add_to_PATH "@CMAKE_INSTALL_PREFIX@/bin" add_to_LD_LIBRARY_PATH "@CMAKE_INSTALL_PREFIX@/lib" if [ ! "${ROOTSYS}" ]; then echo "[INFO]: Sourcing ROOT from: @CMAKE_ROOTSYS@" source "@CMAKE_ROOTSYS@/bin/thisroot.sh" fi if [ "@USE_T2K@" != "FALSE" ]; then echo "[INFO]: Adding T2K paths to the environment." export T2KREWEIGHT=@T2KREWEIGHT@ add_to_LD_LIBRARY_PATH "@T2KREWEIGHT@/lib" fi if [ "@USE_NIWG@" != "FALSE" ]; then echo "[INFO]: Adding NIWG paths to the environment." export NIWG=@NIWG_ROOT@ export NIWGREWEIGHT_INPUTS=@NIWG_ROOT@/inputs add_to_LD_LIBRARY_PATH "@NIWG_ROOT@" fi if [ "@USE_NEUT@" != "FALSE" ]; then echo "[INFO]: Adding NEUT library paths to the environment." export NEUT_ROOT=@NEUT_ROOT@ export CERN=@CERN@ export CERN_LEVEL=@CERN_LEVEL@ add_to_LD_LIBRARY_PATH "${NEUT_LIB_DIR}" "${NEUT_ROOT}/src/reweight" fi if [ "@USE_NuWro@" != "FALSE" ]; then if [ "@NUWRO_BUILT_FROM_FILE@" == "FALSE" ]; then echo "[INFO]: Adding NuWro library paths to the environment." export NUWRO="@NUWRO@" add_to_PATH "@NUWRO@/bin" add_to_LD_LIBRARY_PATH "@NUWRO@/build/@CMAKE_SYSTEM_NAME@/lib" if [ "@NUWRO_INC@" ]; then export NUWRO_INC=@NUWRO_INC@ fi else echo "[INFO]: NuWro support included from input event file." fi fi if [ "@NEED_PYTHIA6@" != "FALSE" ]; then echo "[INFO]: Adding PYTHIA6 library paths to the environment." export PYTHIA6="@PYTHIA6@" add_to_LD_LIBRARY_PATH "@PYTHIA6@" fi if [ "@USE_GENIE@" != "FALSE" ]; then echo "[INFO]: Adding GENIE paths to the environment." export GENIE="@GENIE@" export LHAPDF_LIB="@LHAPDF_LIB@" export LHAPDF_INC="@LHAPDF_INC@" export LIBXML2_LIB="@LIBXML2_LIB@" export LIBXML2_INC="@LIBXML2_INC@" export LOG4CPP_LIB="@LOG4CPP_LIB@" export LOG4CPP_INC="@LOG4CPP_INC@" if [ "@LHAPATH@" ]; then export LHAPATH="@LHAPATH@" fi add_to_PATH "@GENIE@/bin" add_to_LD_LIBRARY_PATH "@GENIE@/lib" "@LHAPDF_LIB@" "@LIBXML2_LIB@" "@LOG4CPP_LIB@" if [ "@GENIE_REWEIGHT@" ]; then export GENIE_REWEIGHT="@GENIE_REWEIGHT@" add_to_LD_LIBRARY_PATH "@GENIE_REWEIGHT@/lib" fi fi if [ "@BUILD_GiBUU@" != "FALSE" ]; then echo "[INFO]: Sourcing GiBUU tools." source @CMAKE_BINARY_DIR@/GiBUUTools/src/GiBUUTools-build/Linux/setup.sh fi if [ "@USE_NOvARwgt@" != "FALSE" ]; then export NOVARWGT=@NOVARWGT@ add_to_LD_LIBRARY_PATH @NOVARWGT@/lib fi if [ "@USE_HEPMCNUEVT@" == "TRUE" ]; then add_to_LD_LIBRARY_PATH @HEPMC_LIBDIR@ add_to_LD_LIBRARY_PATH @HEPMCNUEVTTOOLSROOT@/lib fi export NUISANCE="@CMAKE_SOURCE_DIR@" diff --git a/data/MINERvA/CC1pi0/2017_nu/data/XSec_Table_Enu_xsec.csv b/data/MINERvA/CC1pi0/2017_nu/data/XSec_Table_Enu_xsec.csv index 929d2a9..a894ccd 100755 --- a/data/MINERvA/CC1pi0/2017_nu/data/XSec_Table_Enu_xsec.csv +++ b/data/MINERvA/CC1pi0/2017_nu/data/XSec_Table_Enu_xsec.csv @@ -1,12 +1,11 @@ -0.00 0.00 0 1.50 11.80 19 3.00 15.47 11 3.50 15.47 13 4.00 15.96 19 5.00 20.77 18 6.00 21.96 20 8.00 31.90 18 10.00 33.46 20 12.00 25.30 23 15.00 25.59 31 20.00 0.00 0.00 diff --git a/data/MINERvA/CC1pip/070717/cc1pip_updated_1DEnu_ratecov.txt b/data/MINERvA/CC1pip/070717/cc1pip_updated_1DEnu_ratecov.txt index f22130e..4806b26 100644 --- a/data/MINERvA/CC1pip/070717/cc1pip_updated_1DEnu_ratecov.txt +++ b/data/MINERvA/CC1pip/070717/cc1pip_updated_1DEnu_ratecov.txt @@ -1,8 +1,8 @@ -.0000 0.5408 0.4099 0.2066 0.1154 0.2021 0.2040 0.1936 +1.0000 0.5408 0.4099 0.2066 0.1154 0.2021 0.2040 0.1936 0.5408 1.0000 0.9010 0.7637 0.6321 0.6400 0.6705 0.5944 0.4099 0.9010 1.0000 0.8451 0.7414 0.7061 0.7173 0.6315 0.2066 0.7637 0.8451 1.0000 0.8775 0.7643 0.7365 0.6491 0.1154 0.6321 0.7414 0.8775 1.0000 0.7774 0.7091 0.6295 0.2021 0.6400 0.7061 0.7643 0.7774 1.0000 0.7719 0.7003 0.2040 0.6705 0.7173 0.7365 0.7091 0.7719 1.0000 0.7850 0.1936 0.5944 0.6315 0.6491 0.6295 0.7003 0.7850 1.0000 diff --git a/data/MINERvA/CCQE/20deg_Q2QE_joint_covar_fluxfix.txt b/data/MINERvA/CCQE/20deg_Q2QE_joint_covar_fluxfix.txt index e1d4bbc..33f0622 100755 --- a/data/MINERvA/CCQE/20deg_Q2QE_joint_covar_fluxfix.txt +++ b/data/MINERvA/CCQE/20deg_Q2QE_joint_covar_fluxfix.txt @@ -1,17 +1,16 @@ -1.00000 0.84420 0.87998 0.86569 0.78476 0.62381 0.24728 0.19878 0.62528 0.63894 0.66536 0.65954 0.61511 0.45521 0.23740 0.16111 -0.84420 1.00000 0.88323 0.87029 0.77574 0.59187 0.22371 0.17721 0.62191 0.64260 0.66813 0.67050 0.61030 0.42813 0.19379 0.11603 -0.87998 0.88323 1.00000 0.91996 0.84521 0.64905 0.22549 0.22917 0.62295 0.64287 0.68272 0.67722 0.62627 0.43831 0.20208 0.12285 -0.86569 0.87029 0.91996 1.00000 0.91825 0.77865 0.31484 0.34392 0.58506 0.61811 0.65356 0.66573 0.65684 0.53413 0.28701 0.22623 -0.78476 0.77574 0.84521 0.91825 1.00000 0.88165 0.43137 0.51379 0.50559 0.53918 0.58565 0.59417 0.64211 0.57702 0.38284 0.33938 -0.62381 0.59187 0.64905 0.77865 0.88165 1.00000 0.57473 0.60981 0.36100 0.39675 0.43615 0.46291 0.58124 0.68305 0.53204 0.52863 -0.24728 0.22371 0.22549 0.31484 0.43137 0.57473 1.00000 0.63099 0.14081 0.15678 0.16848 0.18330 0.29378 0.42692 0.36427 0.38416 -0.19878 0.17721 0.22917 0.34392 0.51379 0.60981 0.63099 1.00000 0.05727 0.06556 0.07932 0.09301 0.18312 0.31164 0.21226 0.25193 -0.62528 0.62191 0.62295 0.58506 0.50559 0.36100 0.14081 0.05727 1.00000 0.86268 0.87173 0.85717 0.78925 0.61255 0.33485 0.26221 -0.63894 0.64260 0.64287 0.61811 0.53918 0.39675 0.15678 0.06556 0.86268 1.00000 0.89943 0.90673 0.84935 0.65496 0.37352 0.28123 -0.66536 0.66813 0.68272 0.65356 0.58565 0.43615 0.16848 0.07932 0.87173 0.89943 1.00000 0.94091 0.89597 0.67705 0.37483 0.28261 -0.65954 0.67050 0.67722 0.66573 0.59417 0.46291 0.18330 0.09301 0.85717 0.90673 0.94091 1.00000 0.92754 0.72891 0.40198 0.30629 -0.61511 0.61030 0.62627 0.65684 0.64211 0.58124 0.29378 0.18312 0.78925 0.84935 0.89597 0.92754 1.00000 0.85614 0.57853 0.49184 -0.45521 0.42813 0.43831 0.53413 0.57702 0.68305 0.42692 0.31164 0.61255 0.65496 0.67705 0.72891 0.85614 1.00000 0.75302 0.72746 -0.23740 0.19379 0.20208 0.28701 0.38284 0.53204 0.36427 0.21226 0.33485 0.37352 0.37483 0.40198 0.57853 0.75302 1.00000 0.89935 -0.16111 0.11603 0.12285 0.22623 0.33938 0.52863 0.38416 0.25193 0.26221 0.28123 0.28261 0.30629 0.49184 0.72746 0.89935 1.00000 - +0.0104330415 0.0123973932 0.0136821977 0.0145256938 0.0093296793 0.0038321515 0.0011020691 0.0002068501 0.005954586 0.0077288382 0.0083716276 0.0070462335 0.0045217793 0.0013718926 0.0002005103 2.25116407182462E-05 +0.0123973932 0.0197946034 0.0194451167 0.0211650108 0.0138295061 0.0056439648 0.0016932865 0.0003055851 0.0083811596 0.0110001001 0.0119000238 0.0102538831 0.0066422217 0.00207681 0.0003075105 3.54972686147115E-05 +0.0136821977 0.0194451167 0.0236124756 0.0239874199 0.0159335811 0.0063721548 0.0018558897 0.0003353919 0.0095323586 0.0124914023 0.0138027359 0.0118413511 0.0078797005 0.0024935518 0.0003609393 4.69047034559794E-05 +0.0145256938 0.0211650108 0.0239874199 0.0275253392 0.0178093493 0.0074068432 0.0021489042 0.0003924658 0.0102018705 0.0135346504 0.014782482 0.0130231318 0.0086314562 0.0028574231 0.0004239705 5.93808778550909E-05 +0.0093296793 0.0138295061 0.0159335811 0.0178093493 0.0133935568 0.0060686071 0.002157357 0.0004396139 0.0066370249 0.0085935315 0.0095359336 0.0089630315 0.0065067148 0.0025027539 0.0004739872 8.15538973159876E-05 +0.0038321515 0.0056439648 0.0063721548 0.0074068432 0.0060686071 0.003751363 0.0014861092 0.0003441108 0.0025994055 0.0031904082 0.0035320515 0.003857352 0.0030944625 0.0015565296 0.0003645399 7.34537131351162E-05 +0.0011020691 0.0016932865 0.0018558897 0.0021489042 0.002157357 0.0014861092 0.0010382349 0.0002238065 0.0007131731 0.0007597266 0.0008567063 0.0010904073 0.0010801037 0.0006378265 0.0001636324 2.63202251320494E-05 +0.0002068501 0.0003055851 0.0003353919 0.0003924658 0.0004396139 0.0003441108 0.0002238065 5.96477613712978E-05 0.00011601 0.0001090294 0.0001248346 0.0002060168 0.0002295017 0.0001519003 4.13628947849761E-05 7.48774138864445E-06 +0.005954586 0.0083811596 0.0095323586 0.0102018705 0.0066370249 0.0025994055 0.0007131731 0.00011601 0.0086924164 0.009576327 0.0107942985 0.0095165412 0.006406317 0.0021638723 0.0003214171 0.000071321 +0.0077288382 0.0110001001 0.0124914023 0.0135346504 0.0085935315 0.0031904082 0.0007597266 0.0001090294 0.009576327 0.0148034156 0.0141385691 0.0124850967 0.0082641634 0.0026792725 0.0003794611 8.29713822752219E-05 +0.0083716276 0.0119000238 0.0138027359 0.014782482 0.0095359336 0.0035320515 0.0008567063 0.0001248346 0.0107942985 0.0141385691 0.017310168 0.0142714315 0.0097368805 0.0031771683 0.0004135937 0.0001160307 +0.0070462335 0.0102538831 0.0118413511 0.0130231318 0.0089630315 0.003857352 0.0010904073 0.0002060168 0.0095165412 0.0124850967 0.0142714315 0.013902582 0.0094800441 0.0034158607 0.0005175328 0.0001560553 +0.0045217793 0.0066422217 0.0078797005 0.0086314562 0.0065067148 0.0030944625 0.0010801037 0.0002295017 0.006406317 0.0082641634 0.0097368805 0.0094800441 0.0076666751 0.0028721732 0.0005265683 0.0001731238 +0.0013718926 0.00207681 0.0024935518 0.0028574231 0.0025027539 0.0015565296 0.0006378265 0.0001519003 0.0021638723 0.0026792725 0.0031771683 0.0034158607 0.0028721732 0.0013842745 0.0002981118 8.7312417134487E-05 +0.0002005103 0.0003075105 0.0003609393 0.0004239705 0.0004739872 0.0003645399 0.0001636324 4.13628947849761E-05 0.0003214171 0.0003794611 0.0004135937 0.0005175328 0.0005265683 0.0002981118 0.0001943598 0.000033853 +2.25116407182462E-05 3.54972686147115E-05 4.69047034559794E-05 5.93808778550909E-05 8.15538973159876E-05 7.34537131351162E-05 2.63202251320494E-05 7.48774138864445E-06 0.000071321 8.29713822752219E-05 0.0001160307 0.0001560553 0.0001731238 8.7312417134487E-05 0.000033853 1.48094226663759E-05 diff --git a/data/MINERvA/CCQE/20deg_Q2QE_joint_data_fluxfix.txt b/data/MINERvA/CCQE/20deg_Q2QE_joint_data_fluxfix.txt index f6e7713..e0fc414 100755 --- a/data/MINERvA/CCQE/20deg_Q2QE_joint_data_fluxfix.txt +++ b/data/MINERvA/CCQE/20deg_Q2QE_joint_data_fluxfix.txt @@ -1,17 +1,18 @@ -0.0 9.95248E-39 9.32331E-40 -0.025 1.29836E-38 1.21669E-39 -0.05 1.45069E-38 1.31568E-39 -0.1 1.34021E-38 1.17909E-39 -0.2 9.20783E-39 8.75596E-40 -0.4 3.44229E-39 3.72058E-40 -0.8 8.80692E-40 1.39413E-40 -1.2 1.79399E-40 3.84830E-41 -2.0 9.33281E-39 1.02142E-39 -2.025 1.40601E-38 1.40693E-39 -2.05 1.65064E-38 1.53664E-39 -2.1 1.82744E-38 1.65908E-39 -2.2 1.24987E-38 1.15731E-39 -2.4 5.52559E-39 6.12484E-40 -2.8 1.52186E-39 3.22217E-40 -3.2 3.07422E-40 7.72320E-41 -4.0 0.0 0.0 +0.0 0.9332809991 0.1021422611 +0.025 1.4060130845 0.1406932955 +0.05 1.6506448977 0.1536635144 +0.1 1.8274369355 0.1659076225 +0.2 1.2498736571 0.1157305354 +0.4 0.5525585931 0.0612483717 +0.8 0.1521861493 0.0322216522 +1.2 0.0307422352 0.0077231963 +2.0 0.9952482173 0.0932331293 +2.025 1.2983599761 0.1216692878 +2.05 1.4506853551 0.1315681118 +2.1 1.3402050761 0.117909211 +2.2 0.9207828367 0.0875595515 +2.4 0.3442289658 0.0372058391 +2.8 0.0880692404 0.0139412973 +3.2 0.017939888 0.0038483013 +4.0 0.0 0.0 + diff --git a/data/MINERvA/CCQE/20deg_Q2QE_numu_covar_fluxfix.txt b/data/MINERvA/CCQE/20deg_Q2QE_numu_covar_fluxfix.txt index 03fd1bd..5eb50a6 100755 --- a/data/MINERvA/CCQE/20deg_Q2QE_numu_covar_fluxfix.txt +++ b/data/MINERvA/CCQE/20deg_Q2QE_numu_covar_fluxfix.txt @@ -1,8 +1,8 @@ -1.00000 0.86268 0.87173 0.85717 0.78925 0.61255 0.33485 0.26221 -0.86268 1.00000 0.89943 0.90673 0.84935 0.65496 0.37352 0.28123 -0.87173 0.89943 1.00000 0.94091 0.89597 0.67705 0.37483 0.28261 -0.85717 0.90673 0.94091 1.00000 0.92754 0.72891 0.40198 0.30629 -0.78925 0.84935 0.89597 0.92754 1.00000 0.85614 0.57853 0.49184 -0.61255 0.65496 0.67705 0.72891 0.85614 1.00000 0.75302 0.72746 -0.33485 0.37352 0.37483 0.40198 0.57853 0.75302 1.00000 0.89935 -0.26221 0.28123 0.28261 0.30629 0.49184 0.72746 0.89935 1.00000 +0.0104330415 0.0123973932 0.0136821977 0.0145256938 0.0093296793 0.0038321515 0.0011020691 0.0002068501 +0.0123973932 0.0197946034 0.0194451167 0.0211650108 0.0138295061 0.0056439648 0.0016932865 0.0003055851 +0.0136821977 0.0194451167 0.0236124756 0.0239874199 0.0159335811 0.0063721548 0.0018558897 0.0003353919 +0.0145256938 0.0211650108 0.0239874199 0.0275253392 0.0178093493 0.0074068432 0.0021489042 0.0003924658 +0.0093296793 0.0138295061 0.0159335811 0.0178093493 0.0133935568 0.0060686071 0.002157357 0.0004396139 +0.0038321515 0.0056439648 0.0063721548 0.0074068432 0.0060686071 0.003751363 0.0014861092 0.0003441108 +0.0011020691 0.0016932865 0.0018558897 0.0021489042 0.002157357 0.0014861092 0.0010382349 0.0002238065 +0.0002068501 0.0003055851 0.0003353919 0.0003924658 0.0004396139 0.0003441108 0.0002238065 5.96477613712978E-05 diff --git a/data/MINERvA/CCQE/20deg_Q2QE_numu_data_fluxfix.txt b/data/MINERvA/CCQE/20deg_Q2QE_numu_data_fluxfix.txt index 3be431d..c8fa732 100755 --- a/data/MINERvA/CCQE/20deg_Q2QE_numu_data_fluxfix.txt +++ b/data/MINERvA/CCQE/20deg_Q2QE_numu_data_fluxfix.txt @@ -1,9 +1,10 @@ -0.0 9.33281E-39 1.02142E-39 -0.025 1.40601E-38 1.40693E-39 -0.05 1.65064E-38 1.53664E-39 -0.1 1.82744E-38 1.65908E-39 -0.2 1.24987E-38 1.15731E-39 -0.4 5.52559E-39 6.12484E-40 -0.8 1.52186E-39 3.22217E-40 -1.2 3.07422E-40 7.72320E-41 -2.0 0.0 0.0 +0.0 0.9332809991 0.1021422611 +0.025 1.4060130845 0.1406932955 +0.05 1.6506448977 0.1536635144 +0.1 1.8274369355 0.1659076225 +0.2 1.2498736571 0.1157305354 +0.4 0.5525585931 0.0612483717 +0.8 0.1521861493 0.0322216522 +1.2 0.0307422352 0.0077231963 +2.0 0.0 0.0 + diff --git a/data/MINERvA/CCQE/20deg_Q2QE_numubar_covar_fluxfix.txt b/data/MINERvA/CCQE/20deg_Q2QE_numubar_covar_fluxfix.txt index 0e4f2ab..823f792 100755 --- a/data/MINERvA/CCQE/20deg_Q2QE_numubar_covar_fluxfix.txt +++ b/data/MINERvA/CCQE/20deg_Q2QE_numubar_covar_fluxfix.txt @@ -1,8 +1,8 @@ -1.00000 0.84420 0.87998 0.86569 0.78476 0.62381 0.24728 0.19878 -0.84420 1.00000 0.88323 0.87029 0.77574 0.59187 0.22371 0.17721 -0.87998 0.88323 1.00000 0.91996 0.84521 0.64905 0.22549 0.22917 -0.86569 0.87029 0.91996 1.00000 0.91825 0.77865 0.31484 0.34392 -0.78476 0.77574 0.84521 0.91825 1.00000 0.88165 0.43137 0.51379 -0.62381 0.59187 0.64905 0.77865 0.88165 1.00000 0.57473 0.60981 -0.24728 0.22371 0.22549 0.31484 0.43137 0.57473 1.00000 0.63099 -0.19878 0.17721 0.22917 0.34392 0.51379 0.60981 0.63099 1.00000 +0.0086924164 0.009576327 0.0107942985 0.0095165412 0.006406317 0.0021638723 0.0003214171 0.000071321 +0.009576327 0.0148034156 0.0141385691 0.0124850967 0.0082641634 0.0026792725 0.0003794611 8.29713822752219E-05 +0.0107942985 0.0141385691 0.017310168 0.0142714315 0.0097368805 0.0031771683 0.0004135937 0.0001160307 +0.0095165412 0.0124850967 0.0142714315 0.013902582 0.0094800441 0.0034158607 0.0005175328 0.0001560553 +0.006406317 0.0082641634 0.0097368805 0.0094800441 0.0076666751 0.0028721732 0.0005265683 0.0001731238 +0.0021638723 0.0026792725 0.0031771683 0.0034158607 0.0028721732 0.0013842745 0.0002981118 8.7312417134487E-05 +0.0003214171 0.0003794611 0.0004135937 0.0005175328 0.0005265683 0.0002981118 0.0001943598 0.000033853 +0.000071321 8.29713822752219E-05 0.0001160307 0.0001560553 0.0001731238 8.7312417134487E-05 0.000033853 1.48094226663759E-05 diff --git a/data/MINERvA/CCQE/20deg_Q2QE_numubar_data_fluxfix.txt b/data/MINERvA/CCQE/20deg_Q2QE_numubar_data_fluxfix.txt index d1c5102..fd6a5bf 100755 --- a/data/MINERvA/CCQE/20deg_Q2QE_numubar_data_fluxfix.txt +++ b/data/MINERvA/CCQE/20deg_Q2QE_numubar_data_fluxfix.txt @@ -1,9 +1,10 @@ -0.0 9.95248E-39 9.32331E-40 -0.025 1.29836E-38 1.21669E-39 -0.05 1.45069E-38 1.31568E-39 -0.1 1.34021E-38 1.17909E-39 -0.2 9.20783E-39 8.75596E-40 -0.4 3.44229E-39 3.72058E-40 -0.8 8.80692E-40 1.39413E-40 -1.2 1.79399E-40 3.84830E-41 -2.0 0.0 0.0 +0.0 0.9952482173 0.0932331293 +0.025 1.2983599761 0.1216692878 +0.05 1.4506853551 0.1315681118 +0.1 1.3402050761 0.117909211 +0.2 0.9207828367 0.0875595515 +0.4 0.3442289658 0.0372058391 +0.8 0.0880692404 0.0139412973 +1.2 0.017939888 0.0038483013 +2.0 0.0 0.0 + diff --git a/data/MINERvA/CCQE/Q2QE_joint_covar_fluxfix.txt b/data/MINERvA/CCQE/Q2QE_joint_covar_fluxfix.txt index f9ec1fd..0aff3c0 100755 --- a/data/MINERvA/CCQE/Q2QE_joint_covar_fluxfix.txt +++ b/data/MINERvA/CCQE/Q2QE_joint_covar_fluxfix.txt @@ -1,16 +1,16 @@ -0.010850693024217059 0.013190744200435017 0.014861923720325191 0.015889891078358833 0.010843787943299682 0.005624107037659058 0.0025710258458044675 0.0009246286420048676 0.008378114641718152 0.01067988363734119 0.011671724037168296 0.011431916393507763 0.0075471933941027415 0.003337914774220062 0.0014762551985362713 0.0004353654993927686 -0.013190744200435013 0.021186385260613207 0.021325301678827638 0.023317896472491724 0.015995395778463838 0.008142232076509406 0.003820676949165565 0.001342344168977523 0.011383354694144905 0.015277579700374168 0.016602514706689588 0.0166790277728349 0.01114454636902864 0.004836926009715195 0.0022763117600187047 0.0006583745056070657 -0.014861923720325191 0.02132530167882763 0.02612909633343725 0.026685112166221082 0.01869227729887766 0.00936112702492297 0.004242783507762443 0.001493691722655789 0.012744957539571802 0.016978636754317572 0.019420931847406217 0.01889459835452953 0.012999056272922806 0.0054797213853813795 0.0024290417320247904 0.0006903759773339679 -0.015889891078358837 0.023317896472491724 0.02668511216622108 0.03044348696552605 0.020557479283651925 0.010557606715164931 0.004816165433252427 0.0017313742322655548 0.01355452765171317 0.018512820512922235 0.020560023709156015 0.02102481933089481 0.014254197614929898 0.006260756975227824 0.00281070492616775 0.0008434210310601616 -0.010843787943299677 0.015995395778463834 0.018692277298877655 0.020557479283651925 0.015594411756460633 0.008520161551433196 0.004474689044173032 0.0017588384894984984 0.009031547360726156 0.01241291600059451 0.014151257204516404 0.014243139013575705 0.010491346278831672 0.00515343955084002 0.0028162564753531362 0.001010219685988915 -0.005624107037659056 0.008142232076509406 0.00936112702492297 0.010557606715164935 0.008520161551433196 0.006366051976845064 0.003724161849033904 0.0016865661669981432 0.004411070223107368 0.005946880071711517 0.006617602657956641 0.006874016482775016 0.005571412982647025 0.003932187259372631 0.0024941113830112332 0.0011138225101299368 -0.0025710258458044666 0.0038206769491655667 0.004242783507762443 0.004816165433252426 0.004474689044173032 0.0037241618490339045 0.0035181427821568347 0.0014757595136650808 0.0019165190628176803 0.002748500263194058 0.0029273785507615796 0.0031345641912810564 0.003016986685834871 0.0025043121828085056 0.0025952761869889604 0.0011307124381884845 -0.0009246286420048678 0.001342344168977523 0.001493691722655789 0.0017313742322655548 0.0017588384894984986 0.0016865661669981432 0.0014757595136650808 0.0007557442312393396 0.0006267246244974173 0.0008752851232593777 0.0009259621021978419 0.00102430329840903 0.0011222333581824024 0.0011347659976868717 0.0011376463706516797 0.0005314493307075546 -0.008378114641718152 0.011383354694144907 0.012744957539571802 0.01355452765171317 0.009031547360726156 0.004411070223107367 0.0019165190628176803 0.0006267246244974175 0.011085113377011332 0.012621627014913907 0.013832714262523093 0.013401259193064174 0.008923750033807087 0.003885418978731057 0.0016291066134889655 0.0004716445929751694 -0.010679883637341188 0.015277579700374168 0.016978636754317565 0.018512820512922232 0.01241291600059451 0.0059468800717115185 0.0027485002631940578 0.0008752851232593775 0.012621627014913907 0.019105115622487668 0.018409058234818636 0.01831649562590485 0.012284115416167968 0.005275820923080161 0.002386362596766497 0.0006793779278293267 -0.011671724037168296 0.01660251470668959 0.019420931847406217 0.020560023709156015 0.014151257204516404 0.006617602657956642 0.0029273785507615796 0.0009259621021978418 0.013832714262523093 0.01840905823481864 0.022176021170818364 0.020322539107765183 0.013987338716624179 0.005845702036277676 0.002507832884304526 0.0006995651114106596 -0.011431916393507763 0.0166790277728349 0.018894598354529536 0.02102481933089481 0.014243139013575705 0.006874016482775016 0.0031345641912810564 0.00102430329840903 0.013401259193064174 0.01831649562590485 0.02032253910776518 0.021554051514934544 0.01404118372663557 0.006103945117658788 0.0027066040836864983 0.000794821074894569 -0.007547193394102741 0.011144546369028643 0.012999056272922808 0.014254197614929898 0.010491346278831672 0.005571412982647023 0.0030169866858348704 0.0011222333581824024 0.008923750033807087 0.01228411541616797 0.01398733871662418 0.014041183726635568 0.010675116970821609 0.004989338359384158 0.0026883620446813143 0.0009466333007327206 -0.003337914774220062 0.004836926009715194 0.005479721385381378 0.006260756975227823 0.0051534395508400195 0.003932187259372631 0.0025043121828085056 0.0011347659976868717 0.003885418978731058 0.005275820923080161 0.0058457020362776765 0.006103945117658788 0.004989338359384159 0.0037426211973084875 0.0022848867020996656 0.0010196253808122193 -0.001476255198536271 0.0022763117600187047 0.0024290417320247904 0.00281070492616775 0.0028162564753531367 0.0024941113830112332 0.0025952761869889604 0.0011376463706516797 0.0016291066134889653 0.002386362596766497 0.0025078328843045265 0.0027066040836864983 0.0026883620446813148 0.0022848867020996656 0.0026553447279390363 0.0010653625389391973 -0.0004353654993927686 0.00065837 +0.0096930415 0.0114894507 0.012845455 0.0136344392 0.0091071066 0.0045260971 0.0020446583 0.0007039216 0.005844586 0.0076058382 0.0081556276 0.0067435159 0.0042994312 0.0014936413 0.0002473258 3.7821293258615E-05 +0.0114894507 0.0186747974 0.0183460918 0.0199892579 0.0134686233 0.0066082656 0.0031109271 0.001050355 0.0082081343 0.0108140536 0.0115539604 0.0097807516 0.0063070236 0.0022561059 0.0004097294 7.22250727970645E-05 +0.012845455 0.0183460918 0.022595752 0.0227365352 0.0156988646 0.007547666 0.0034073543 0.0011508288 0.0093878293 0.0122978045 0.0135096029 0.0113824228 0.0076181033 0.002739018 0.0005020412 0.0001066455 +0.0136344392 0.0199892579 0.0227365352 0.0260338784 0.0172119818 0.0085327539 0.003878305 0.0013451015 0.0100044033 0.0132982522 0.0143876179 0.0124253227 0.0082555006 0.003102352 0.0006126334 0.0001322437 +0.0091071066 0.0134686233 0.0156988646 0.0172119818 0.0129612184 0.0067724393 0.0035876707 0.0013754622 0.0066690577 0.0086333976 0.0095314112 0.0086187151 0.0063190518 0.0027230733 0.0007345664 0.0002078268 +0.0045260971 0.0066082656 0.007547666 0.0085327539 0.0067724393 0.0049806388 0.0029048415 0.0013074482 0.0032001095 0.003919217 0.004344278 0.0045122103 0.0037094384 0.0021232196 0.0007128489 0.000228726 +0.0020446583 0.0031109271 0.0034073543 0.003878305 0.0035876707 0.0029048415 0.0029964681 0.0012279239 0.0012883279 0.0013726179 0.001535455 0.0018866961 0.0019039152 0.001312352 0.0004606773 0.0001302912 +0.0007039216 0.001050355 0.0011508288 0.0013451015 0.0013754622 0.0013074482 0.0012279239 0.0006369953 0.0003846875 0.0003587196 0.0004088789 0.0006770389 0.0007936145 0.0006174815 0.0002379365 7.30561434556777E-05 +0.005844586 0.0082081343 0.0093878293 0.0100044033 0.0066690577 0.0032001095 0.0012883279 0.0003846875 0.0085774164 0.009457327 0.0105692985 0.0092361143 0.0062598002 0.0024641652 0.0004642017 0.0001556402 +0.0076058382 0.0108140536 0.0122978045 0.0132982522 0.0086333976 0.003919217 0.0013726179 0.0003587196 0.009457327 0.0146944156 0.0138695691 0.012148389 0.0080693276 0.0030412996 0.0005348885 0.0001727616 +0.0081556276 0.0115539604 0.0135096029 0.0143876179 0.0095314112 0.004344278 0.001535455 0.0004088789 0.0105692985 0.0138695691 0.016912168 0.0138095926 0.0095121223 0.0036483991 0.0005980594 0.0002476779 +0.0067435159 0.0097807516 0.0113824228 0.0124253227 0.0086187151 0.0045122103 0.0018866961 0.0006770389 0.0092361143 0.012148389 0.0138095926 0.0133556822 0.0092625716 0.0039387367 0.0008117617 0.0003562485 +0.0042994312 0.0063070236 0.0076181033 0.0082555006 0.0063190518 0.0037094384 0.0019039152 0.0007936145 0.0062598002 0.0080693276 0.0095121223 0.0092625716 0.0078015263 0.0034992871 0.0009299144 0.0004441312 +0.0014936413 0.0022561059 0.002739018 0.003102352 0.0027230733 0.0021232196 0.001312352 0.0006174815 0.0024641652 0.0030412996 0.0036483991 0.0039387367 0.0034992871 0.0019954274 0.0006164624 0.0002744646 +0.0002473258 0.0004097294 0.0005020412 0.0006126334 0.0007345664 0.0007128489 0.0004606773 0.0002379365 0.0004642017 0.0005348885 0.0005980594 0.0008117617 0.0009299144 0.0006164624 0.0005799549 0.0001762902 +3.7821293258615E-05 7.22250727970645E-05 0.0001066455 0.0001322437 0.0002078268 0.000228726 0.0001302912 7.30561434556777E-05 0.0001556402 0.0001727616 0.0002476779 0.0003562485 0.0004441312 0.0002744646 0.0001762902 0.0001018105 diff --git a/data/MINERvA/CCQE/Q2QE_joint_data_fluxfix.txt b/data/MINERvA/CCQE/Q2QE_joint_data_fluxfix.txt index ddd7a97..9f7576d 100755 --- a/data/MINERvA/CCQE/Q2QE_joint_data_fluxfix.txt +++ b/data/MINERvA/CCQE/Q2QE_joint_data_fluxfix.txt @@ -1,17 +1,56 @@ -0.0 9.0727046436e-39 1.0416665985e-39 -0.025 1.36713686945e-38 1.4555543707e-39 -0.05 1.60374921161e-38 1.61644970022e-39 -0.1 1.77779397112e-38 1.74480620602e-39 -0.2 1.26437732963e-38 1.24877587086e-39 -0.4 6.86399152713e-39 7.97875427422e-40 -0.8 2.81795050914e-39 5.93139341315e-40 -1.2 1.11818649182e-39 2.74908026663e-40 -2.0 9.74134032934e-39 1.05285865039e-39 -2.025 1.27053453213e-38 1.38221256044e-39 -2.05 1.41936302043e-38 1.48916154835e-39 -2.1 1.31214085033e-38 1.46812981425e-39 -2.2 9.27620248836e-39 1.03320457659e-39 -2.4 4.0394169746e-39 6.11769662317e-40 -2.8 1.44869365053e-39 5.15300371428e-40 -3.2 4.79844766693e-40 2.36519334495e-40 -4.0 0.0 0.0 +0.0 0.9332809991 0.0984532452 +0.025 1.4060183024 0.1366557622 +0.05 1.6494167393 0.1503188345 +0.1 1.8286652702 0.1613501732 +0.2 1.3013376283 0.1138473469 +0.4 0.7072418247 0.0705736411 +0.8 0.2907306883 0.0547400042 +1.2 0.1154299504 0.0252387653 +2.0 0.9952482173 0.0926143423 +2.025 1.2983599761 0.1212205247 +2.05 1.4506853551 0.1300467917 +2.1 1.3414290077 0.1155667869 +2.2 0.9488877949 0.0883262492 +2.4 0.4136671604 0.0446702069 +2.8 0.1485557073 0.0240822527 +3.2 0.0492103402 0.0100901183 +4.0 0.0 0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/MINERvA/CCQE/Q2QE_numu_covar_fluxfix.txt b/data/MINERvA/CCQE/Q2QE_numu_covar_fluxfix.txt index c0b618e..3053567 100755 --- a/data/MINERvA/CCQE/Q2QE_numu_covar_fluxfix.txt +++ b/data/MINERvA/CCQE/Q2QE_numu_covar_fluxfix.txt @@ -1,8 +1,9 @@ -0.010850693024217059 0.013190744200435017 0.014861923720325191 0.015889891078358833 0.010843787943299682 0.005624107037659058 0.0025710258458044675 0.0009246286420048676 -0.013190744200435013 0.021186385260613207 0.021325301678827638 0.023317896472491724 0.015995395778463838 0.008142232076509406 0.003820676949165565 0.001342344168977523 -0.014861923720325191 0.02132530167882763 0.02612909633343725 0.026685112166221082 0.01869227729887766 0.00936112702492297 0.004242783507762443 0.001493691722655789 -0.015889891078358837 0.023317896472491724 0.02668511216622108 0.03044348696552605 0.020557479283651925 0.010557606715164931 0.004816165433252427 0.0017313742322655548 -0.010843787943299677 0.015995395778463834 0.018692277298877655 0.020557479283651925 0.015594411756460633 0.008520161551433196 0.004474689044173032 0.0017588384894984984 -0.005624107037659056 0.008142232076509406 0.00936112702492297 0.010557606715164935 0.008520161551433196 0.006366051976845064 0.003724161849033904 0.0016865661669981432 -0.0025710258458044666 0.0038206769491655667 0.004242783507762443 0.004816165433252426 0.004474689044173032 0.0037241618490339045 0.0035181427821568347 0.0014757595136650808 -0.0009246286420048678 0.001342344168977523 0.001493691722655789 0.0017313742322655548 0.0017588384894984986 0.0016865661669981432 0.0014757595136650808 0.0007557442312393396 +0.0096930415 0.0114894507 0.012845455 0.0136344392 0.0091071066 0.0045260971 0.0020446583 0.0007039216 +0.0114894507 0.0186747974 0.0183460918 0.0199892579 0.0134686233 0.0066082656 0.0031109271 0.001050355 +0.012845455 0.0183460918 0.022595752 0.0227365352 0.0156988646 0.007547666 0.0034073543 0.0011508288 +0.0136344392 0.0199892579 0.0227365352 0.0260338784 0.0172119818 0.0085327539 0.003878305 0.0013451015 +0.0091071066 0.0134686233 0.0156988646 0.0172119818 0.0129612184 0.0067724393 0.0035876707 0.0013754622 +0.0045260971 0.0066082656 0.007547666 0.0085327539 0.0067724393 0.0049806388 0.0029048415 0.0013074482 +0.0020446583 0.0031109271 0.0034073543 0.003878305 0.0035876707 0.0029048415 0.0029964681 0.0012279239 +0.0007039216 0.001050355 0.0011508288 0.0013451015 0.0013754622 0.0013074482 0.0012279239 0.0006369953 + diff --git a/data/MINERvA/CCQE/Q2QE_numu_data_fluxfix.txt b/data/MINERvA/CCQE/Q2QE_numu_data_fluxfix.txt index f000e17..0cde57d 100755 --- a/data/MINERvA/CCQE/Q2QE_numu_data_fluxfix.txt +++ b/data/MINERvA/CCQE/Q2QE_numu_data_fluxfix.txt @@ -1,9 +1,49 @@ -0.0 9.74134032934e-39 1.05285865039e-39 -0.025 1.27053453213e-38 1.38221256044e-39 -0.05 1.41936302043e-38 1.48916154835e-39 -0.1 1.31214085033e-38 1.46812981425e-39 -0.2 9.27620248836e-39 1.03320457659e-39 -0.4 4.0394169746e-39 6.11769662317e-40 -0.8 1.44869365053e-39 5.15300371428e-40 -1.2 4.79844766693e-40 2.36519334495e-40 -2.0 0.0 0.0 +0.0 0.9332809991 0.0984532452 +0.025 1.4060183024 0.1366557622 +0.05 1.6494167393 0.1503188345 +0.1 1.8286652702 0.1613501732 +0.2 1.3013376283 0.1138473469 +0.4 0.7072418247 0.0705736411 +0.8 0.2907306883 0.0547400042 +1.2 0.1154299504 0.0252387653 +2.0 0.0 0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/MINERvA/CCQE/Q2QE_numubar_covar_fluxfix.txt b/data/MINERvA/CCQE/Q2QE_numubar_covar_fluxfix.txt index df6892c..50f54fa 100755 --- a/data/MINERvA/CCQE/Q2QE_numubar_covar_fluxfix.txt +++ b/data/MINERvA/CCQE/Q2QE_numubar_covar_fluxfix.txt @@ -1,8 +1,8 @@ -1 0.842391544 0.877542734 0.862934862 0.765230795 0.595625939 0.208128425 0.166551002 -0.842391544 1 0.879806501 0.867180477 0.753652944 0.561649115 0.183227219 0.141245581 -0.877542734 0.879806501 1 0.918857542 0.828109935 0.628036282 0.19096228 0.188751891 -0.862934862 0.867180477 0.918857542 1 0.907420841 0.762967333 0.291674481 0.305508832 -0.765230795 0.753652944 0.828109935 0.907420841 1 0.886894213 0.437175781 0.49833938 -0.595625939 0.561649115 0.628036282 0.762967333 0.886894213 1 0.573048687 0.608936733 -0.208128425 0.183227219 0.19096228 0.291674481 0.437175781 0.573048687 1 0.725495759 -0.166551002 0.141245581 0.188751891 0.305508832 0.49833938 0.608936733 0.725495759 1 +0.0085774164 0.009457327 0.0105692985 0.0092361143 0.0062598002 0.0024641652 0.0004642017 0.0001556402 +0.009457327 0.0146944156 0.0138695691 0.012148389 0.0080693276 0.0030412996 0.0005348885 0.0001727616 +0.0105692985 0.0138695691 0.016912168 0.0138095926 0.0095121223 0.0036483991 0.0005980594 0.0002476779 +0.0092361143 0.012148389 0.0138095926 0.0133556822 0.0092625716 0.0039387367 0.0008117617 0.0003562485 +0.0062598002 0.0080693276 0.0095121223 0.0092625716 0.0078015263 0.0034992871 0.0009299144 0.0004441312 +0.0024641652 0.0030412996 0.0036483991 0.0039387367 0.0034992871 0.0019954274 0.0006164624 0.0002744646 +0.0004642017 0.0005348885 0.0005980594 0.0008117617 0.0009299144 0.0006164624 0.0005799549 0.0001762902 +0.0001556402 0.0001727616 0.0002476779 0.0003562485 0.0004441312 0.0002744646 0.0001762902 0.0001018105 diff --git a/data/MINERvA/CCQE/Q2QE_numubar_data_fluxfix.txt b/data/MINERvA/CCQE/Q2QE_numubar_data_fluxfix.txt index 88ef834..3dbc115 100755 --- a/data/MINERvA/CCQE/Q2QE_numubar_data_fluxfix.txt +++ b/data/MINERvA/CCQE/Q2QE_numubar_data_fluxfix.txt @@ -1,9 +1,48 @@ -0 0.995248217E-38 0.092614342E-38 -0.025 1.298359976E-38 0.121220525E-38 -0.05 1.450685355E-38 0.130046792E-38 -0.1 1.341429008E-38 0.115566787E-38 -0.2 0.948887795E-38 0.088326249E-38 -0.4 0.41366716E-38 0.044670207E-38 -0.8 0.148555707E-38 0.024082253E-38 -1.2 0.04921034E-38 0.010090118E-38 -2 0.0 0.0 +0.0 0.9952482173 0.0926143423 +0.025 1.2983599761 0.1212205247 +0.05 1.4506853551 0.1300467917 +0.1 1.3414290077 0.1155667869 +0.2 0.9488877949 0.0883262492 +0.4 0.4136671604 0.0446702069 +0.8 0.1485557073 0.0240822527 +1.2 0.0492103402 0.0100901183 +2.0 0.0 0.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_flux.csv b/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_flux.csv deleted file mode 100755 index 8a37377..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_flux.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.0030 0.0131 0.0065 -0.0044 0.0083 0.0343 0.0521 0.0787 0.0342 -0.0131 0.0761 0.0580 0.0073 0.0859 0.2405 0.3736 0.6081 0.3101 -0.0065 0.0580 0.0721 0.0565 0.1320 0.2336 0.3659 0.6337 0.3403 --0.0044 0.0073 0.0565 0.1085 0.1740 0.1277 0.1769 0.3409 0.1411 -0.0083 0.0859 0.1320 0.1740 0.4139 0.4506 0.6153 1.0507 0.4100 -0.0343 0.2405 0.2336 0.1277 0.4506 0.9108 1.3782 2.2888 1.1480 -0.0521 0.3736 0.3659 0.1769 0.6153 1.3782 2.1542 3.6281 1.9565 -0.0787 0.6081 0.6337 0.3409 1.0507 2.2888 3.6281 6.2100 3.4856 -0.0342 0.3101 0.3403 0.1411 0.4100 1.1480 1.9565 3.4856 2.3443 diff --git a/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_stat.csv b/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_stat.csv deleted file mode 100755 index 9564da9..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_stat.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.2440 0.0194 -0.0495 -0.0014 0.0044 -0.0004 -0.0000 -0.0000 0.0000 -0.0194 0.0838 0.0015 -0.0059 -0.0009 -0.0000 0.0000 0.0000 -0.0000 --0.0495 0.0015 0.0590 0.0059 -0.0026 -0.0005 -0.0000 -0.0000 0.0000 --0.0014 -0.0059 0.0059 0.0967 0.0159 -0.0041 -0.0010 -0.0001 -0.0000 -0.0044 -0.0009 -0.0026 0.0159 0.4430 0.0274 -0.0202 -0.0057 -0.0000 --0.0004 -0.0000 -0.0005 -0.0041 0.0274 1.6737 0.3357 -0.1557 -0.0181 --0.0000 0.0000 -0.0000 -0.0010 -0.0202 0.3357 3.4695 0.5463 -0.1972 --0.0000 0.0000 -0.0000 -0.0001 -0.0057 -0.1557 0.5463 5.0386 0.1996 -0.0000 -0.0000 0.0000 -0.0000 -0.0000 -0.0181 -0.1972 0.1996 12.0922 diff --git a/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_sys.csv b/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_sys.csv deleted file mode 100755 index 4bbcad2..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_antinu_Covar_sys.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.0290 0.0236 0.0235 0.0204 0.0269 0.0299 0.0323 0.0330 0.0518 -0.0236 0.1172 0.0995 0.0951 0.1161 0.1354 0.1505 0.1069 0.2238 -0.0235 0.0995 0.1021 0.0900 0.1115 0.1298 0.1450 0.1098 0.2149 -0.0204 0.0951 0.0900 0.1001 0.1077 0.1253 0.1438 0.1059 0.2070 -0.0269 0.1161 0.1115 0.1077 0.1689 0.1719 0.1970 0.1474 0.2863 -0.0299 0.1354 0.1298 0.1253 0.1719 0.2637 0.2278 0.1709 0.3551 -0.0323 0.1505 0.1450 0.1438 0.1970 0.2278 0.4093 0.1736 0.3761 -0.0330 0.1069 0.1098 0.1059 0.1474 0.1709 0.1736 0.2298 0.2809 -0.0518 0.2238 0.2149 0.2070 0.2863 0.3551 0.3761 0.2809 0.7830 diff --git a/data/MINERvA/CCcoh/callums/Enu_antinu_XSec.csv b/data/MINERvA/CCcoh/callums/Enu_antinu_XSec.csv deleted file mode 100755 index b5debcd..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_antinu_XSec.csv +++ /dev/null @@ -1,10 +0,0 @@ -1.5 0.254 0.494 0.179 -2.0 2.049 0.290 0.440 -3.0 2.673 0.243 0.417 -4.0 1.725 0.311 0.457 -5.0 3.928 0.666 0.763 -7.0 6.840 1.294 1.084 -9.0 9.917 1.863 1.601 -11.0 15.896 2.245 2.538 -15.0 9.931 3.477 1.768 -20.0 0.000 0.0000 0.000 diff --git a/data/MINERvA/CCcoh/callums/Enu_nu_Covar_flux.csv b/data/MINERvA/CCcoh/callums/Enu_nu_Covar_flux.csv deleted file mode 100755 index 90a4947..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_nu_Covar_flux.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.1607 0.1059 0.0963 0.1011 0.2184 0.3017 0.3280 0.4243 0.6208 -0.1059 0.0721 0.0614 0.0512 0.1267 0.1993 0.2206 0.2857 0.4143 -0.0963 0.0614 0.0727 0.1065 0.1662 0.1811 0.1884 0.2465 0.3571 -0.1011 0.0512 0.1065 0.2545 0.3247 0.1929 0.1667 0.2216 0.3363 -0.2184 0.1267 0.1662 0.3247 0.5415 0.4320 0.4100 0.5299 0.7969 -0.3017 0.1993 0.1811 0.1929 0.4320 0.5928 0.6354 0.8159 1.1904 -0.3280 0.2206 0.1884 0.1667 0.4100 0.6354 0.6998 0.9011 1.3109 -0.4243 0.2857 0.2465 0.2216 0.5299 0.8159 0.9011 1.1661 1.6954 -0.6208 0.4143 0.3571 0.3363 0.7969 1.1904 1.3109 1.6954 2.4803 diff --git a/data/MINERvA/CCcoh/callums/Enu_nu_Covar_stat.csv b/data/MINERvA/CCcoh/callums/Enu_nu_Covar_stat.csv deleted file mode 100755 index f3786dd..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_nu_Covar_stat.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.8354 -0.0235 -0.1095 -0.0082 -0.0004 0.0000 0.0000 -0.0000 -0.0000 --0.0235 0.0460 -0.0003 -0.0029 -0.0004 -0.0000 -0.0000 -0.0000 -0.0000 --0.1095 -0.0003 0.0334 0.0018 -0.0016 -0.0002 -0.0000 -0.0000 -0.0000 --0.0082 -0.0029 0.0018 0.0762 0.0054 -0.0029 -0.0004 -0.0001 -0.0000 --0.0004 -0.0004 -0.0016 0.0054 0.2284 0.0100 -0.0079 -0.0031 -0.0003 -0.0000 -0.0000 -0.0002 -0.0029 0.0100 0.6263 0.0793 -0.0416 -0.0109 -0.0000 -0.0000 -0.0000 -0.0004 -0.0079 0.0793 1.0676 0.2118 -0.0724 --0.0000 -0.0000 -0.0000 -0.0001 -0.0031 -0.0416 0.2118 1.2436 0.0420 --0.0000 -0.0000 -0.0000 -0.0000 -0.0003 -0.0109 -0.0724 0.0420 2.8417 diff --git a/data/MINERvA/CCcoh/callums/Enu_nu_Covar_sys.csv b/data/MINERvA/CCcoh/callums/Enu_nu_Covar_sys.csv deleted file mode 100755 index 21c806c..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_nu_Covar_sys.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.0454 0.0315 0.0316 0.0320 0.0366 0.0440 0.0506 0.0439 0.0410 -0.0315 0.0401 0.0312 0.0320 0.0374 0.0444 0.0510 0.0469 0.0425 -0.0316 0.0312 0.0489 0.0339 0.0404 0.0486 0.0566 0.0514 0.0448 -0.0320 0.0320 0.0339 0.0577 0.0420 0.0503 0.0592 0.0545 0.0479 -0.0366 0.0374 0.0404 0.0420 0.0961 0.0620 0.0735 0.0710 0.0627 -0.0440 0.0444 0.0486 0.0503 0.0620 0.1203 0.0906 0.0830 0.0720 -0.0506 0.0510 0.0566 0.0592 0.0735 0.0906 0.1689 0.1005 0.0847 -0.0439 0.0469 0.0514 0.0545 0.0710 0.0830 0.1005 0.1551 0.0942 -0.0410 0.0425 0.0448 0.0479 0.0627 0.0720 0.0847 0.0942 0.1494 diff --git a/data/MINERvA/CCcoh/callums/Enu_nu_XSec.csv b/data/MINERvA/CCcoh/callums/Enu_nu_XSec.csv deleted file mode 100755 index f5a5041..0000000 --- a/data/MINERvA/CCcoh/callums/Enu_nu_XSec.csv +++ /dev/null @@ -1,10 +0,0 @@ -1.5 3.952 0.914 0.454 -2.0 2.485 0.214 0.335 -3.0 2.736 0.183 0.349 -4.0 3.096 0.276 0.559 -5.0 5.037 0.478 0.798 -7.0 6.540 0.791 0.844 -9.0 6.321 1.033 0.932 -11.0 8.205 1.115 1.149 -15.0 12.330 1.686 1.622 -20.0 0.000 0.000 0.000 diff --git a/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_flux.csv b/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_flux.csv deleted file mode 100755 index 9c2aae6..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_flux.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.0420 0.1947 0.1071 0.1179 0.0825 0.0341 0.0122 0.0019 0.0012 -0.1947 0.9108 0.4947 0.5428 0.3779 0.1540 0.0537 0.0074 0.0049 -0.1071 0.4947 0.2756 0.3041 0.2131 0.0886 0.0319 0.0052 0.0032 -0.1179 0.5428 0.3041 0.3361 0.2360 0.0987 0.0358 0.0060 0.0036 -0.0825 0.3779 0.2131 0.2360 0.1663 0.0703 0.0259 0.0046 0.0026 -0.0341 0.1540 0.0886 0.0987 0.0703 0.0306 0.0118 0.0025 0.0013 -0.0122 0.0537 0.0319 0.0358 0.0259 0.0118 0.0048 0.0012 0.0006 -0.0019 0.0074 0.0052 0.0060 0.0046 0.0025 0.0012 0.0005 0.0002 -0.0012 0.0049 0.0032 0.0036 0.0026 0.0013 0.0006 0.0002 0.0001 diff --git a/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_stat.csv b/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_stat.csv deleted file mode 100755 index d3bf3ea..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_stat.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.2141 0.5504 -0.1078 -0.0621 -0.0139 -0.0004 0.0001 0.0001 -0.0000 -0.5504 0.9801 0.1167 -0.0276 -0.0291 -0.0081 -0.0018 -0.0003 -0.0001 --0.1078 0.1167 0.2017 0.1025 0.0074 -0.0087 -0.0034 -0.0008 -0.0001 --0.0621 -0.0276 0.1025 0.1607 0.0591 0.0004 -0.0052 -0.0021 -0.0005 --0.0139 -0.0291 0.0074 0.0591 0.0875 0.0295 0.0034 -0.0016 -0.0010 --0.0004 -0.0081 -0.0087 0.0004 0.0295 0.0535 0.0241 0.0040 -0.0005 -0.0001 -0.0018 -0.0034 -0.0052 0.0034 0.0241 0.0345 0.0125 0.0018 -0.0001 -0.0003 -0.0008 -0.0021 -0.0016 0.0040 0.0125 0.0126 0.0047 --0.0000 -0.0001 -0.0001 -0.0005 -0.0010 -0.0005 0.0018 0.0047 0.0028 diff --git a/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_sys.csv b/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_sys.csv deleted file mode 100755 index 7abdbf5..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_antinu_Covar_sys.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.5242 0.6582 0.1663 0.0840 0.0262 0.0080 0.0058 0.0020 0.0002 -0.6582 5.8193 1.0820 0.5440 0.1697 0.0509 0.0383 0.0153 0.0027 -0.1663 1.0820 0.7139 0.2271 0.0783 0.0256 0.0199 0.0094 0.0026 -0.0840 0.5440 0.2271 0.4017 0.0557 0.0196 0.0145 0.0070 0.0021 -0.0262 0.1697 0.0783 0.0557 0.1649 0.0106 0.0072 0.0036 0.0012 -0.0080 0.0509 0.0256 0.0196 0.0106 0.0903 0.0051 0.0025 0.0008 -0.0058 0.0383 0.0199 0.0145 0.0072 0.0051 0.0505 0.0023 0.0007 -0.0020 0.0153 0.0094 0.0070 0.0036 0.0025 0.0023 0.0195 0.0005 -0.0002 0.0027 0.0026 0.0021 0.0012 0.0008 0.0007 0.0005 0.0041 diff --git a/data/MINERvA/CCcoh/callums/Epi_antinu_XSec.csv b/data/MINERvA/CCcoh/callums/Epi_antinu_XSec.csv deleted file mode 100755 index 28e8693..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_antinu_XSec.csv +++ /dev/null @@ -1,10 +0,0 @@ -0 0.423 0.146 0.238 -0.25 2.245 0.313 0.820 -0.5 1.342 0.142 0.315 -0.75 1.467 0.127 0.272 -1.0 1.129 0.094 0.182 -1.5 0.659 0.073 0.110 -2.0 0.393 0.059 0.074 -2.5 0.182 0.035 0.045 -3.5 0.073 0.017 0.020 -4.0 0.000 0.000 0.000 diff --git a/data/MINERvA/CCcoh/callums/Epi_nu_Covar_flux.csv b/data/MINERvA/CCcoh/callums/Epi_nu_Covar_flux.csv deleted file mode 100755 index 40bcb7b..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_nu_Covar_flux.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.0469 0.2898 0.1137 0.1111 0.0805 0.0392 0.0194 0.0092 0.0046 -0.2898 1.7901 0.7017 0.6859 0.4970 0.2426 0.1203 0.0570 0.0283 -0.1137 0.7017 0.2757 0.2696 0.1950 0.0946 0.0466 0.0221 0.0111 -0.1111 0.6859 0.2696 0.2636 0.1907 0.0925 0.0455 0.0216 0.0108 -0.0805 0.4970 0.1950 0.1907 0.1381 0.0673 0.0333 0.0158 0.0079 -0.0392 0.2426 0.0946 0.0925 0.0673 0.0334 0.0169 0.0080 0.0039 -0.0194 0.1203 0.0466 0.0455 0.0333 0.0169 0.0086 0.0041 0.0020 -0.0092 0.0570 0.0221 0.0216 0.0158 0.0080 0.0041 0.0019 0.0009 -0.0046 0.0283 0.0111 0.0108 0.0079 0.0039 0.0020 0.0009 0.0005 diff --git a/data/MINERvA/CCcoh/callums/Epi_nu_Covar_stat.csv b/data/MINERvA/CCcoh/callums/Epi_nu_Covar_stat.csv deleted file mode 100755 index 3e95cef..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_nu_Covar_stat.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.1356 0.9767 -0.1924 -0.0664 -0.0140 -0.0009 -0.0001 -0.0000 0.0000 -0.9767 0.4979 0.0279 -0.0191 -0.0128 -0.0031 -0.0007 -0.0001 -0.0000 --0.1924 0.0279 0.1102 0.0496 0.0026 -0.0041 -0.0017 -0.0004 -0.0001 --0.0664 -0.0191 0.0496 0.0920 0.0353 0.0005 -0.0029 -0.0011 -0.0003 --0.0140 -0.0128 0.0026 0.0353 0.0603 0.0174 0.0016 -0.0011 -0.0008 --0.0009 -0.0031 -0.0041 0.0005 0.0174 0.0372 0.0174 0.0025 -0.0007 --0.0001 -0.0007 -0.0017 -0.0029 0.0016 0.0174 0.0225 0.0076 0.0013 --0.0000 -0.0001 -0.0004 -0.0011 -0.0011 0.0025 0.0076 0.0088 0.0037 -0.0000 -0.0000 -0.0001 -0.0003 -0.0008 -0.0007 0.0013 0.0037 0.0037 diff --git a/data/MINERvA/CCcoh/callums/Epi_nu_Covar_sys.csv b/data/MINERvA/CCcoh/callums/Epi_nu_Covar_sys.csv deleted file mode 100755 index 2157a6f..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_nu_Covar_sys.csv +++ /dev/null @@ -1,9 +0,0 @@ -0.7835 0.1193 0.0369 0.0302 0.0170 0.0085 0.0056 0.0029 0.0012 -0.1193 1.4417 0.2816 0.1973 0.0913 0.0386 0.0276 0.0152 0.0064 -0.0369 0.2816 0.2735 0.1186 0.0631 0.0243 0.0129 0.0062 0.0030 -0.0302 0.1973 0.1186 0.2271 0.0666 0.0278 0.0142 0.0065 0.0031 -0.0170 0.0913 0.0631 0.0666 0.1210 0.0205 0.0107 0.0047 0.0021 -0.0085 0.0386 0.0243 0.0278 0.0205 0.0550 0.0068 0.0030 0.0012 -0.0056 0.0276 0.0129 0.0142 0.0107 0.0068 0.0277 0.0021 0.0008 -0.0029 0.0152 0.0062 0.0065 0.0047 0.0030 0.0021 0.0100 0.0005 -0.0012 0.0064 0.0030 0.0031 0.0021 0.0012 0.0008 0.0005 0.0037 diff --git a/data/MINERvA/CCcoh/callums/Epi_nu_XSec.csv b/data/MINERvA/CCcoh/callums/Epi_nu_XSec.csv deleted file mode 100755 index 7cffb8f..0000000 --- a/data/MINERvA/CCcoh/callums/Epi_nu_XSec.csv +++ /dev/null @@ -1,10 +0,0 @@ -0.00 0.567 0.116 0.288 -0.25 3.473 0.223 0.568 -0.50 1.426 0.105 0.234 -0.75 1.508 0.096 0.222 -1.00 1.213 0.078 0.161 -1.50 0.714 0.061 0.094 -2.00 0.429 0.047 0.060 -2.50 0.227 0.030 0.034 -3.50 0.116 0.019 0.020 -4.00 0.000 0.000 0.000 diff --git a/data/MINERvA/CCcoh/callums/th_antinu_Covar_flux.csv b/data/MINERvA/CCcoh/callums/th_antinu_Covar_flux.csv deleted file mode 100755 index 7e7219d..0000000 --- a/data/MINERvA/CCcoh/callums/th_antinu_Covar_flux.csv +++ /dev/null @@ -1,12 +0,0 @@ -0.0552 0.0801 0.0547 0.0661 0.0640 0.0369 0.0322 0.0227 0.0184 0.0014 -0.0006 0.0042 -0.0801 0.1166 0.0797 0.0961 0.0932 0.0540 0.0470 0.0333 0.0269 0.0022 -0.0008 0.0061 -0.0547 0.0797 0.0547 0.0659 0.0641 0.0370 0.0323 0.0229 0.0187 0.0016 -0.0004 0.0043 -0.0661 0.0961 0.0659 0.0796 0.0774 0.0446 0.0390 0.0277 0.0226 0.0019 -0.0005 0.0052 -0.0640 0.0932 0.0641 0.0774 0.0760 0.0438 0.0385 0.0276 0.0228 0.0022 -0.0003 0.0052 -0.0369 0.0540 0.0370 0.0446 0.0438 0.0255 0.0223 0.0160 0.0132 0.0013 -0.0001 0.0030 -0.0322 0.0470 0.0323 0.0390 0.0385 0.0223 0.0196 0.0141 0.0117 0.0012 -0.0001 0.0027 -0.0227 0.0333 0.0229 0.0277 0.0276 0.0160 0.0141 0.0102 0.0086 0.0010 0.0000 0.0019 -0.0184 0.0269 0.0187 0.0226 0.0228 0.0132 0.0117 0.0086 0.0074 0.0009 0.0002 0.0017 -0.0014 0.0022 0.0016 0.0019 0.0022 0.0013 0.0012 0.0010 0.0009 0.0002 0.0001 0.0002 --0.0006 -0.0008 -0.0004 -0.0005 -0.0003 -0.0001 -0.0001 0.0000 0.0002 0.0001 0.0001 0.0001 -0.0042 0.0061 0.0043 0.0052 0.0052 0.0030 0.0027 0.0019 0.0017 0.0002 0.0001 0.0004 diff --git a/data/MINERvA/CCcoh/callums/th_antinu_Covar_stat.csv b/data/MINERvA/CCcoh/callums/th_antinu_Covar_stat.csv deleted file mode 100755 index 15af9a9..0000000 --- a/data/MINERvA/CCcoh/callums/th_antinu_Covar_stat.csv +++ /dev/null @@ -1,12 +0,0 @@ -0.1863 0.0072 -0.0147 -0.0066 -0.0021 -0.0017 -0.0015 -0.0007 -0.0004 -0.0004 -0.0002 -0.0000 -0.0072 0.2111 0.0400 0.0327 0.0796 0.0851 0.1135 0.0819 -0.0005 -0.0002 -0.0001 -0.0000 -0.0400 0.1386 0.0409 0.0420 0.0489 0.0665 0.0484 -0.0007 -0.0003 -0.0000 0.0000 --0.0066 0.0327 0.0409 0.1249 0.0720 0.0580 0.0802 0.0588 -0.0002 -0.0004 -0.0001 -0.0000 --0.0021 0.0796 0.0420 0.0720 0.1741 0.1116 0.1304 0.0950 0.0001 0.0003 -0.0001 -0.0001 --0.0017 0.0851 0.0489 0.0580 0.1116 0.1365 0.1258 0.0823 -0.0050 -0.0008 0.0000 0.0000 --0.0015 0.1135 0.0665 0.0802 0.1304 0.1258 0.1785 0.1090 -0.0053 -0.0047 -0.0006 0.0001 --0.0007 0.0819 0.0484 0.0588 0.0950 0.0823 0.1090 0.1135 0.0152 -0.0014 -0.0024 -0.0004 --0.0004 -0.0005 -0.0007 -0.0002 0.0001 -0.0050 -0.0053 0.0152 0.0314 0.0137 -0.0018 -0.0013 --0.0004 -0.0002 -0.0003 -0.0004 0.0003 -0.0008 -0.0047 -0.0014 0.0137 0.0198 0.0042 -0.0005 --0.0002 -0.0001 -0.0000 -0.0001 -0.0001 0.0000 -0.0006 -0.0024 -0.0018 0.0042 0.0123 0.0028 --0.0000 -0.0000 0.0000 -0.0000 -0.0001 0.0000 0.0001 -0.0004 -0.0013 -0.0005 0.0028 0.0119 diff --git a/data/MINERvA/CCcoh/callums/th_antinu_Covar_sys.csv b/data/MINERvA/CCcoh/callums/th_antinu_Covar_sys.csv deleted file mode 100755 index 8672ca3..0000000 --- a/data/MINERvA/CCcoh/callums/th_antinu_Covar_sys.csv +++ /dev/null @@ -1,12 +0,0 @@ -0.0931 0.0923 0.0859 0.0256 0.0682 0.0426 0.0683 0.0556 0.0543 0.0173 0.0259 0.0859 -0.0923 0.1068 0.0968 0.0311 0.0804 0.0525 0.0815 0.0675 0.0671 0.0246 0.0319 0.0988 -0.0859 0.0968 0.1070 0.0336 0.0804 0.0567 0.0837 0.0692 0.0696 0.0300 0.0353 0.0917 -0.0256 0.0311 0.0336 0.0280 0.0347 0.0295 0.0354 0.0330 0.0334 0.0220 0.0182 0.0305 -0.0682 0.0804 0.0804 0.0347 0.0848 0.0550 0.0756 0.0663 0.0659 0.0331 0.0341 0.0807 -0.0426 0.0525 0.0567 0.0295 0.0550 0.0545 0.0566 0.0514 0.0519 0.0313 0.0280 0.0524 -0.0683 0.0815 0.0837 0.0354 0.0756 0.0566 0.0856 0.0678 0.0682 0.0349 0.0352 0.0803 -0.0556 0.0675 0.0692 0.0330 0.0663 0.0514 0.0678 0.0690 0.0612 0.0339 0.0321 0.0674 -0.0543 0.0671 0.0696 0.0334 0.0659 0.0519 0.0682 0.0612 0.0693 0.0349 0.0326 0.0664 -0.0173 0.0246 0.0300 0.0220 0.0331 0.0313 0.0349 0.0339 0.0349 0.0310 0.0197 0.0248 -0.0259 0.0319 0.0353 0.0182 0.0341 0.0280 0.0352 0.0321 0.0326 0.0197 0.0216 0.0321 -0.0859 0.0988 0.0917 0.0305 0.0807 0.0524 0.0803 0.0674 0.0664 0.0248 0.0321 0.1003 diff --git a/data/MINERvA/CCcoh/callums/th_antinu_XSec.csv b/data/MINERvA/CCcoh/callums/th_antinu_XSec.csv deleted file mode 100755 index a463a43..0000000 --- a/data/MINERvA/CCcoh/callums/th_antinu_XSec.csv +++ /dev/null @@ -1,13 +0,0 @@ -0 0.068 0.014 0.012 -5 0.120 0.015 0.015 -10 0.088 0.012 0.013 -15 0.091 0.011 0.010 -20 0.072 0.013 0.013 -25 0.039 0.012 0.009 -30 0.031 0.013 0.010 -35 0.019 0.011 0.009 -40 0.011 0.006 0.009 -45 -0.000 0.004 0.006 -50 -0.004 0.004 0.005 -60 -0.005 0.003 0.010 -70 0.000 0.000 0.000 diff --git a/data/MINERvA/CCcoh/callums/th_nu_Covar_flux.csv b/data/MINERvA/CCcoh/callums/th_nu_Covar_flux.csv deleted file mode 100755 index 12ecaf1..0000000 --- a/data/MINERvA/CCcoh/callums/th_nu_Covar_flux.csv +++ /dev/null @@ -1,12 +0,0 @@ -0.0844 0.0923 0.0849 0.0911 0.0671 0.0540 0.0479 0.0365 0.0290 0.0150 0.0086 0.0016 -0.0923 0.1013 0.0931 0.0998 0.0735 0.0592 0.0524 0.0400 0.0318 0.0165 0.0095 0.0018 -0.0849 0.0931 0.0856 0.0918 0.0676 0.0544 0.0482 0.0368 0.0292 0.0152 0.0087 0.0016 -0.0911 0.0998 0.0918 0.0985 0.0725 0.0584 0.0517 0.0394 0.0313 0.0163 0.0093 0.0017 -0.0671 0.0735 0.0676 0.0725 0.0534 0.0430 0.0381 0.0290 0.0231 0.0120 0.0069 0.0013 -0.0540 0.0592 0.0544 0.0584 0.0430 0.0346 0.0307 0.0234 0.0186 0.0096 0.0055 0.0010 -0.0479 0.0524 0.0482 0.0517 0.0381 0.0307 0.0272 0.0207 0.0165 0.0085 0.0049 0.0009 -0.0365 0.0400 0.0368 0.0394 0.0290 0.0234 0.0207 0.0158 0.0126 0.0065 0.0038 0.0007 -0.0290 0.0318 0.0292 0.0313 0.0231 0.0186 0.0165 0.0126 0.0100 0.0052 0.0030 0.0006 -0.0150 0.0165 0.0152 0.0163 0.0120 0.0096 0.0085 0.0065 0.0052 0.0027 0.0016 0.0003 -0.0086 0.0095 0.0087 0.0093 0.0069 0.0055 0.0049 0.0038 0.0030 0.0016 0.0009 0.0002 -0.0016 0.0018 0.0016 0.0017 0.0013 0.0010 0.0009 0.0007 0.0006 0.0003 0.0002 0.0001 diff --git a/data/MINERvA/CCcoh/callums/th_nu_Covar_stat.csv b/data/MINERvA/CCcoh/callums/th_nu_Covar_stat.csv deleted file mode 100755 index bc75227..0000000 --- a/data/MINERvA/CCcoh/callums/th_nu_Covar_stat.csv +++ /dev/null @@ -1,12 +0,0 @@ -0.1518 0.0052 -0.0114 -0.0053 -0.0016 -0.0015 -0.0012 -0.0008 -0.0003 -0.0001 0.0000 0.0000 -0.0052 0.1256 0.0078 -0.0083 -0.0031 -0.0012 -0.0005 -0.0003 -0.0004 -0.0001 -0.0000 -0.0000 --0.0114 0.0078 0.0731 0.0085 -0.0045 -0.0018 -0.0009 -0.0004 -0.0002 -0.0001 -0.0000 -0.0000 --0.0053 -0.0083 0.0085 0.0569 0.0067 -0.0030 -0.0015 -0.0006 0.0002 -0.0001 -0.0001 -0.0000 --0.0016 -0.0031 -0.0045 0.0067 0.0374 0.0056 -0.0015 -0.0005 -0.0001 0.0002 -0.0000 -0.0000 --0.0015 -0.0012 -0.0018 -0.0030 0.0056 0.0289 0.0050 -0.0012 -0.0028 -0.0005 0.0000 0.0000 --0.0012 -0.0005 -0.0009 -0.0015 -0.0015 0.0050 0.0241 0.0054 -0.0023 -0.0024 -0.0004 0.0000 --0.0008 -0.0003 -0.0004 -0.0006 -0.0005 -0.0012 0.0054 0.0186 0.0072 -0.0007 -0.0011 -0.0002 --0.0003 -0.0004 -0.0002 0.0002 -0.0001 -0.0028 -0.0023 0.0072 0.0139 0.0058 -0.0005 -0.0005 --0.0001 -0.0001 -0.0001 -0.0001 0.0002 -0.0005 -0.0024 -0.0007 0.0058 0.0092 0.0024 -0.0001 -0.0000 -0.0000 -0.0000 -0.0001 -0.0000 0.0000 -0.0004 -0.0011 -0.0005 0.0024 0.0057 0.0014 -0.0000 -0.0000 -0.0000 -0.0000 -0.0000 0.0000 0.0000 -0.0002 -0.0005 -0.0001 0.0014 0.0053 diff --git a/data/MINERvA/CCcoh/callums/th_nu_Covar_sys.csv b/data/MINERvA/CCcoh/callums/th_nu_Covar_sys.csv deleted file mode 100755 index 7b0d2ae..0000000 --- a/data/MINERvA/CCcoh/callums/th_nu_Covar_sys.csv +++ /dev/null @@ -1,12 +0,0 @@ -0.1420 0.1742 0.1132 0.0416 0.0509 0.0353 0.0573 0.0565 0.0422 0.0258 0.0460 0.0530 -0.1742 0.2246 0.1452 0.0569 0.0686 0.0492 0.0748 0.0740 0.0559 0.0351 0.0603 0.0682 -0.1132 0.1452 0.1047 0.0389 0.0476 0.0350 0.0532 0.0524 0.0399 0.0254 0.0420 0.0466 -0.0416 0.0569 0.0389 0.0289 0.0235 0.0192 0.0218 0.0208 0.0157 0.0099 0.0147 0.0155 -0.0509 0.0686 0.0476 0.0235 0.0380 0.0223 0.0277 0.0267 0.0204 0.0131 0.0194 0.0203 -0.0353 0.0492 0.0350 0.0192 0.0223 0.0299 0.0218 0.0210 0.0163 0.0109 0.0149 0.0146 -0.0573 0.0748 0.0532 0.0218 0.0277 0.0218 0.0433 0.0332 0.0261 0.0179 0.0262 0.0267 -0.0565 0.0740 0.0524 0.0208 0.0267 0.0210 0.0332 0.0425 0.0265 0.0185 0.0271 0.0273 -0.0422 0.0559 0.0399 0.0157 0.0204 0.0163 0.0261 0.0265 0.0279 0.0155 0.0224 0.0220 -0.0258 0.0351 0.0254 0.0099 0.0131 0.0109 0.0179 0.0185 0.0155 0.0171 0.0167 0.0157 -0.0460 0.0603 0.0420 0.0147 0.0194 0.0149 0.0262 0.0271 0.0224 0.0167 0.0298 0.0250 -0.0530 0.0682 0.0466 0.0155 0.0203 0.0146 0.0267 0.0273 0.0220 0.0157 0.0250 0.0275 diff --git a/data/MINERvA/CCcoh/callums/th_nu_XSec.csv b/data/MINERvA/CCcoh/callums/th_nu_XSec.csv deleted file mode 100755 index 0fe75a9..0000000 --- a/data/MINERvA/CCcoh/callums/th_nu_XSec.csv +++ /dev/null @@ -1,13 +0,0 @@ -0 0.114 0.012 0.015 -5 0.133 0.011 0.018 -10 0.115 0.009 0.014 -15 0.109 0.008 0.011 -20 0.073 0.006 0.010 -25 0.054 0.005 0.008 -30 0.042 0.005 0.008 -35 0.027 0.004 0.008 -40 0.018 0.004 0.006 -45 0.005 0.003 0.004 -50 -0.005 0.002 0.006 -60 -0.008 0.002 0.005 -70 0.000 0.000 0.000 diff --git a/doc/tutorial_dialtuning.dox b/doc/tutorial_dialtuning.dox index 100637c..f783388 100644 --- a/doc/tutorial_dialtuning.dox +++ b/doc/tutorial_dialtuning.dox @@ -1,108 +1,108 @@ /*! \page tutorial_dialtuning Dial Tuning The main purpose of the fitter is to allow ReWeight dials to be quickly tuned to datasets. In this tutorial we go through how to include dials in a simple fit and define their state. \section tutorial_dialtuning_parcard Extending the Fit Card First, copy the fit card from the previous tutorial using the sample definition given there. Now we want to add in a NEUT ReWeight dials, so a quick grep of the NEUT systematics file will return what the dial names are. Below is a shortened output. Some dials (especially ones that are discontinous) cannot be used with the fitter so check what little notes there are inside the RW functions themselves when including new dials. \code $ grep case $NEUT_REWEIGHT/NSyst.h case ( kXSecTwkDial_NormNCEL ) : return "NormNCEL"; break; //case ( kXSecTwkDial_NormNCELenu ) : return "NormNCELenu"; break; case ( kXSecTwkDial_MaNCEL ) : return "MaNCEL"; break; case ( kXSecTwkDial_MaNCELshape ) : return "MaNCELshape"; break; case ( kXSecTwkDial_1overMaNCEL2 ) : return "1overMaNCEL2"; break; case ( kXSecTwkDial_AxlFFNCEL ) : return "AxlFFNCEL"; break; case ( kXSecTwkDial_VecFFNCEL ) : return "VecFFNCEL"; break; //case ( kXSecTwkDial_VecFFNCELshape ) : return "VecFFNCELshape"; break; //case ( kXSecTwkDial_EtaNCEL ) : return "EtaNCEL"; break; case ( kXSecTwkDial_NormCCQE ) : return "NormCCQE"; break; //case ( kXSecTwkDial_NormCCQEenu ) : return "NormCCQEenu"; break; case ( kXSecTwkDial_MaCCQE ) : return "MaCCQE"; break; \endcode So lets say we want to include two modifications to the MC. Firstly, we want to scale down the CCQE normalisation by a fixed 10%. Then we want to vary the axial mass freely in the fit between 0.8 and 1.4 GeV and try to converge on a best fit for this dial. To figure out what values we need to include in the card file we must determine the 1-sigma uncertainty on these parameters. Again a grep will do the trick for the 1-sigma uncertainty: \code $ grep NormCCQE $NEUT_REWEIGHT/NSystUncertainty.cc this->SetUncertainty( kXSecTwkDial_NormCCQE, 0.15, 0.15); $ grep NormCCQE $NEUT_REWEIGHT/NSystUncertainty.cc this->SetUncertainty( kXSecTwkDial_MaCCQE, 0.165289256, 0.165289256); \endcode Unfortunately the default values for these parameters is a bit more akward to find. These are given in each of the RW objects in the NEUT_REWEIGHT folder. For the purpose of this excerices we just explicitly state them here. \code Nominal MaCCQE = 1.21 GeV/c^2 Nominal NormCCQE = 1.0 \endcode We must then convert the true values we have for the nominal and limits into 1-sigma dial values using the following equation. \code true.value = nominal.value * ( 1.0 + sig.err * dial.value) dial.value = ( (true.value / nominal.value) - 1.0 ) / sig.err \endcode To finally include these dials the following lines should be added to the fit card with the neut_parameter identifier. \code # ident --------- Parameter --- Nom. ---- Low. ---- Upp. --- Stp. --- State ---- neut_parameter NormCCQE -0.10 -1.00 1.00 1.0 FIX neut_parameter MaCCQE 0.00 -2.11 0.98 1.0 FREE \endcode Alternative parameter types can be supplied for each of the different generators. These are: - neut_parameter -> NEUT - nuwro_parameter -> NuWro (Make sure you have built with NuWro AND NuWroReWeight) - genie_parameter -> GENIE - niwg_parameter -> NIWG - custom_parameter -> Custom dials that can be added to FitWeight if required. Currently a placeholder. The nominal value should always be within the lower and upper limits otherwise ROOT's minimizer libraries will complain. The step size seems to currently be ignored by most of the libraries but it is used by the PlotLimits and GridScan function so it is best to choose something reasonable just to be safe. \section tutorial_dialtuning_absolute Using absolute dial values There has recently been a modification to FitBase to allow dials to be shown in the fit card in terms of true values provided a conversion function is given in the card file contained in FitBase. If you want to use this method, you should also provide the state "ABS" in the card file. So for example the MaCCQE dial line would become. \code # ident --------- Parameter --- Nom. ---- Low. ---- Upp. --- Stp. --- State ---- neut_parameter MaCCQE 0.0 0.8 1.4 0.4 FREE/ABS \endcode Alternative parameter types can be supplied for each of the different generators. These are: - neut_parameter -> NEUT - nuwro_parameter -> NuWro (Make sure you have built with NuWro AND NuWroReWeight) - genie_parameter -> GENIE - niwg_parameter -> NIWG - custom_parameter -> Custom dials that can be added to FitWeight if required. Currently a placeholder. \section tutorial_dialtuning_runfit Running the Fit Once you have written the fit card it should be as simple as running the minimizer again. \code -ExtFit_minimizer.exe -c fittertutorial2.card -o fittertutorial2.root +nuismin -c fittertutorial2.card -o fittertutorial2.root \endcode The finished fit should produce the following output table for each parameter involved. The specified output root file should also contain MC histograms for the best fit point. There are cases where strong parameter correlations and bumpy chi2 spaces will mean the fit has problems converging. As a general guide fitting 4 parameters will usually take around 400 reconfigures. If it takes significantly longer than this (3x) then you may be having trouble. Alternative fit routines are available to try and fix problems like this. See \ref tutorial_fitroutines for more information. */ \ No newline at end of file diff --git a/doc/tutorial_inputs.dox b/doc/tutorial_inputs.dox index 4a95fd1..afcb575 100644 --- a/doc/tutorial_inputs.dox +++ b/doc/tutorial_inputs.dox @@ -1,149 +1,149 @@ /*! \page tutorial_inputs Fitting Input Card To determine what samples need to be loaded and the location of the event files to be read the fitter parses a premade input fit card which contains everything piece of information for the fit. This tutorial details how to load a simple sample of events from each of the generators and compare them against each other. \section fitcards The Fit Card For this very simple case so all that is required in the fit card is a single line to read in which sample we want to plot. For a list of samples see \ref samplelist. We want a set of Monte Carlo events to make the data/MC comparison so first you will need to generate this in Neut and NuWro separately. No explicit tutorial is given for this, but please see \ref generators for tips on what generator output format the events need to be in. Once we have a set of events create a fit card "fittertutorial1.card" in the current directory and include the "MiniBooNE_CCQE_XSec_1DQ2_nu" sample as follows. \code # Identifier - Sample Name ----------------- Type - Events File Name ------------------- Normalisation sample MiniBooNE_CCQE_XSec_1DQ2_nu FIX /path/to/miniboone_ccqe_events.root 1.0 \endcode - The "sample" argument lets the fitter know we want to include a new sample in this fit. Multiple samples can be included if required assuming they are uncorrelated by creating multiple sample lines in the fit card. - The Sample Name is a simple string identifier that lets the fitter know which dataset comparison should be performed, for a list of samples see \ref samplelist. - The sample Type is used to specify any other options required to describe how this sample is handled. Common examples are "FIX - fix this samples overall normalisation", "SHAPE - normalise MC to data before doing calculations", "DIAG - use only uncorrelated bin errors", "NORM - Add a normalisation penalty term to the fit". Some samples have extra possible fit types so it is worth checking the doxygen documentation for a sample before using it. - The events file name is just simply the directory to the MC events you want to use for this fit. In the case of joint datasets that require multiple input MC files, the path to each can be provided in this field by passing a semi-colon separated list, e.g. "/path/to/miniboone_ccqe_events1.root;/path/to/miniboone_ccqe_events2.root". - The normalisation term is used to float the overall normalisation of this sample. The fitter will complain and scale the samples to 0.0 if you forget to include this! \section fittingrun Running a Fit Once we have a sample card produced it is possible to run a default Migrad fit by passing this fit card to the minimizer. \code -ExtFit_minimizer.exe -c fittertutorial1.card -o fittertutorial1_output.root +nuismin -c fittertutorial1.card -o fittertutorial1_output.root \endcode Since we have not included any MC ReWeight dials to be minimized yet this should run relatively quickly, requiring only a single reconfigure. The final output should look as follows: \code [LOG Fitter]: Making the minimizerFCN [LOG Minmzr]: Initializing Samples [LOG Minmzr]: MINERvA_CCQE_XSec_1DQ2_nu [LOG Fitter]: Running Routine: Migrad [LOG Fitter]: Fixed Param: MINERvA_CCQE_XSec_1DQ2_nu_norm [LOG Fitter]: Setup Minimizer: 1(NDim) 0(NFree) [LOG Minmzr]: Reconfiguring all samples in series [LOG Minmzr]: Iteration = 1 [LOG Minmzr]: Time taken for this reconfigure: 40 [LOG Fitter]: Current Stat = 47.8123 [LOG Fitter]: Minimizer State: [LOG Fitter]: # Parameter = Value +- Error Units (Sigma Variation) [LOG Fitter]: 0 . MINERvA_CCQE_XSec_1DQ2_nu_norm = 1 Frac. (Fixed) [LOG Fitter]: Running Routine: FixAtLim [LOG Fitter]: Minimizer State: [LOG Fitter]: # Parameter = Value +- Error Units (Sigma Variation) [LOG Fitter]: 0 . MINERvA_CCQE_XSec_1DQ2_nu_norm = 1 Frac. (Fixed) Error in : matrix not positive definite Error in : matrix not positive definite [LOG Fitter]: Saving current FCN predictions [LOG Minmzr]: Reconfiguring all samples in series [LOG Minmzr]: Iteration = 1 [LOG Minmzr]: Time taken for this reconfigure: 39 [LOG Minmzr]: Writing each of the data classes: ------------------------------------- Minimizer Complete. ------------------------------------- \endcode - Note: The error messages about TDecompChol correspond to problems where teh minimizer didn't actually produce a good covariance matrix. This can happen if the fit fails, but also if you are fitting with 1 or 0 free parameters. If that is the case don't worry too much about it. \section analysing Analysing the Output The root file produced then contains the results from the fit. To list the contents run: \code root -l fittertutorial1_output.root root[1]: _file0->ls(); TFile** fittertutorial1_output.root TFile* fittertutorial1_output.root KEY: TTree fit_result;1 fit_result KEY: TH1D fit_dials;1 fit_dials KEY: TH1D start_dials;1 start_dials KEY: TH1D min_dials;1 min_dials KEY: TH1D max_dials;1 max_dials KEY: TH1D fit_status;1 fit_status KEY: TH2D covariance;1 covariance KEY: TH2D correlation;1 correlation KEY: TH2D decomposition;1 decomposition KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_data;1 MINERvA_CCQE_XSec_1DQ2_nu_data KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_MC;1 47.812 KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_MC_FINE;1 MINERvA_CCQE_XSec_1DQ2_nu_MC_FINE KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_FLUX;1 MINERvA_CCQE_XSec_1DQ2_nu KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_EVT;1 MINERvA_CCQE_XSec_1DQ2_nu_EVT KEY: THStack MINERvA_CCQE_XSec_1DQ2_nu_MC_PDG;1 MINERvA_CCQE_XSec_1DQ2_nu_MC_PDG KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_MC_RATIO;1 47.812 KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_data_RATIO;1 MINERvA_CCQE_XSec_1DQ2_nu_data KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_MC_SHAPE;1 47.812 KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_MC_SHAPE_RATIO;1 47.812 KEY: TH1D MINERvA_CCQE_XSec_1DQ2_nu_data_SHAPE_RATIO;1 MINERvA_CCQE_XSec_1DQ2_nu_data KEY: TH1D sample_xsecs_MC;1 sample_xsecs_MC KEY: TH1D sample_xsecs_data;1 sample_xsecs_data root[2]: fit_result->Show(0); ======> EVENT:0 parameter_names = (vector*)0x1aa80e0 parameter_values = (vector*)0x1aa93b0 parameter_errors = (vector*)0x1aa9b40 parameter_min = (vector*)0x1aa9f30 parameter_max = (vector*)0x1aaa2f0 parameter_start = (vector*)0x1aaa6b0 parameter_fix = (vector*)0x1aaacb0 parameter_startfix = (vector*)0x1aab690 CHI2 = 47.8123 NDOF = 8 NBINS = 8 NDIM = 1 NFREE = 0 \endcode Each of the following plots are added to every output file following a minimization fit. - fit_results -> A TTree containing each of the dial names, values, limits, etc. The best fit chi2 point and number of fit degrees of freedom is given in this tree. - fit_dials -> Best fit results and fit errors for each dial in units of 1-sigam variation. Dials with 0.0 bin errors are fixed. - start_dials -> Nominal values for these fit parameters in units of 1-sigma variation. - min_dials -> Mnimium limit for each dial in units of 1-sigma variation. (If a dial is fit very close to the limit within fit error... worry) - max_dials -> Maximum limit for each dial in units of 1-sigma variation. (If a dial is fit very close to the limit within fit error... worry) - fit_status -> Plot of some variables from the fit, mostly unimportant. - covariance -> Fit result covariance that the ROOT minimizer gives out. - correlation -> Correlation matrix form the fit - decomposition -> Decomposed covariance matrix from the fit, useful for fake data studies and producing error bands for correlated parameters.. The following plots are specific to a given fit depending on what samples where included. The structure is generally the same, and the sample identifier used in the fit card will correspond to which sample made these plots. By default the following distributions should be created, but whether they are saved is determined by the configuration option "drawOpts" given in the config file. - MiniBooNE_CCQE_XSec_1DQ2_data -> Data distribution for the sample that was loaded in the fit. - MiniBooNE_CCQE_XSec_1DQ2_MC -> Best fit MC distribution after the fit has been ran. Titles on these plots give the best fit Chi2 for that single sample which is useful when running joint fits. Error bands show the statistical errors only for the MC prediction. - MiniBooNE_CCQE_XSec_1DQ2_MC_Fine -> Finely binned MC distribution at best fit (Can sometimes disagree with coarse MC histogram because of scaling factors..) - MiniBooNE_CCQE_XSec_1DQ2_MC_Shape -> MC plot normalised to match the data normalisation - MiniBooNE_CCQE_XSec_1DQ2_data_Ratio -> Data/MC Ratio Plot - MiniBooNE_CCQE_XSec_1DQ2_MC_Ratio -> Baseline for Data/MC Ratio (Unity) - MiniBooNE_CCQE_XSec_1DQ2_data_Shape_Ratio -> Data/MC Ratio where the MC is normalised to match the dataset before the ratio is calculated. */ diff --git a/myenv.sh b/myenv.sh deleted file mode 100644 index c089872..0000000 --- a/myenv.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash - -############# -## ROOT RELATED BUSINESS -source /vols/t2k/users/cvw09/software/root/bin/thisroot.sh - - - -############# -## NEUT RELATED BUSINESS -#export NEUT_ROOT=/vols/t2k/users/cvw09/software/neut-devel/trunk -#export NEUT_ROOT=~/ssd/neut-devel/branches/neut_5.4.0.1 -#export NEUT_VERSION=5.4.0.1 -#export NEUT_VERSION=5.4.0.1 - -#export NEUT_ROOT=/vols/build/t2k/cvw09/neut-devel/branches/neut_5.4.1_alpha -#export NEUT_VERSION=5.4.1 -#export NEUT_ROOT=~/ssd/neut_5.3.6_minoo -#export CERN=~/ssd/CERNLIB -#export CERN_LEVEL=2005 -#export LD_LIBRARY_PATH=${NEUT_ROOT}/src/reweight:${LD_LIBRARY_PATH} - -############# -## GENIE RELATED BUSINESS -#source ~/ssd/lamp/environment_setup.sh -#source ~/ssd/lamp/environment_setup_2.8.4.sh -#source ~/ssd/lamp/environment_setup_2.10.10.sh - -export NUISANCE=$(pwd -P) diff --git a/parameters/config.xml b/parameters/config.xml index ff5c579..627db54 100644 --- a/parameters/config.xml +++ b/parameters/config.xml @@ -1,235 +1,231 @@ - + - - - - + - diff --git a/parameters/fitter.config.dat b/parameters/fitter.config.dat deleted file mode 100644 index a0c71d0..0000000 --- a/parameters/fitter.config.dat +++ /dev/null @@ -1,158 +0,0 @@ -# ###################################################### -# NUISANCE CONFIGURATION OPTIONS -# This file is read in by default at runtime -# If you want to override on a case by case bases use -q at runtime -# ###################################################### - -# MAIN Configs -# ###################################################### - -# Logger goes from -# 1 Quiet -# 2 Fitter -# 3 Samples -# 4 Reconfigure Loops -# 5 Every Event print out (SHOUT) -# -1 DEBUGGING -config verbosity 2 -config VERBOSITY 2 - -# ERROR goes from -# 0 NONE -# 1 FATAL -# 2 WARN -config ERROR 2 - -# Input Configs -# ###################################################### - -# Default Requirements file for the externalDataFitter Package -# MAX Events : -1 is no cut. Events will be scaled automatically to give good xsec predictions. -config input.maxevents -1 -config MAXEVENTS -1 -config input.MAXEVENTS -1 - -# Turn on/off event manager -# EventManager enables us to only loop number of events once for multiple projections of the same measurements -# e.g. MiniBooNE CC1pi+ Q2 and MiniBooNE CC1pi+ Tmu would ordinarily require 2 reconfigures, but with this enabled it requires only one -config input.eventmanager 0 -config EventManager 0 - -# Event Directories -# Can setup default directories and use @EVENT_DIR/path to link to it -config EVENT_DIR /data2/stowell/NIWG/ -config NEUT_EVENT_DIR /data2/stowell/NIWG/neut/fit_samples_neut5.3.3/ -config GENIE_EVENT_DIR /data2/stowell/NIWG/genie/fit_samples_R.2.10.0/ -config NUWRO_EVENT_DIR /data2/stowell/NIWG/nuwro/fit_samples/ -config GIBUU_EVENT_DIR /data/GIBUU/DIR/ - -# In PrepareGENIE the reconstructed splines can be saved into the file -config save_genie_splines 1 - -# In InputHandler the option to regenerate NuWro flux/xsec plots is available -# Going to move this to its own app soon -config input.regen_nuwro_plots 0 - -# DEVEL CONFIG OPTION, don't touch! -config cachesize 0 - -# ReWeighting Configuration Options -# ###################################################### - -# Set absolute twkdial for parameters -config params.setabstwk 0 - -# Convert Dials in output statements using dial conversion card -config convert_dials 0 - -# Make RW Calculations be quiet -condif params.silentweighting 0 - -# Vetos can be used to specify RW dials NOT to be loaded in -# Useful if one specific one has an issue -config FitWeight.fNIWGRW_veto '' -config FitWeight.fNuwroRW_veto '' -config FitWeight.fNeutRW_veto '' -config FitWeight.fGenieRW_veto '' - - -# Output Options -# ###################################################### - -# Save Nominal prediction with all rw engines at default -config savenominal 0 - -# Save prefit with values at starting values -config saveprefit 0 - -# Here's the full list of drawing options -# See src/FitBase/Measurement1D::Write for more info -#config drawopts DATA/MC/EVT/FINE/RATIO/MODES/SHAPE/RESIDUAL/MATRIX/FLUX/MASK/MAP -#config drawopts DATA/MC -config drawopts DATA/MC/EVT/FINE/RATIO/MODES/SHAPE/FLUX/XSEC/MASK/COV/INVCOV/DECOMP/CANVPDG/CANVMC - -# Save the shape scaling applied with option SHAPE into the main MC hist -config saveshapescaling 0 - -# Set style of 1D output histograms -config linecolour 1 -config linestyle 1 -config linewidth 1 - -# For GenericFlux -config isLiteMode 0 - -# Statistical Options -# ###################################################### - -# Add MC Statistical error to likelihoods -config statutils.addmcerror 0 - -# NUISMIN Configurations -# ###################################################### - -config minimizer.maxcalls 1000000 -config minimizer.maxiterations 1000000 -config minimizer.tolerance 0.001 - -# Number of events required in low stats routines -config minimizer.lowstatevents 25000 - - -# Error band generator configs -# ###################################################### - -# For -f ErrorBands creates error bands for given measurements -# How many throws do we want (The higher the better precision) -config error_throws 250 - -# Are we throwing uniform or according to Gaussian? -# Only use uniform if wanting to study the limits of a dial. -config error_uniform 0 - - -# Other Individual Case Configs -# ###################################################### - -# Covariance throw options for fake data studies with MiniBooNE data. -config thrown_covariance FULL -config throw_mc_stat 0.0 -config throw_diag_syst 0 -config throw_corr_syst 0 -config throw_mc_stat 0 - -# Apply a shift to the muon momentum before calculation of Q2 -config muon_momentum_shift 0.0 -config muon_momentum_throw 0 - -# MINERvA Specific Configs -config MINERvA_XSec_CCinc_2DEavq3_nu.hadron_cut 0 -config MINERvA_CCinc_XSec_2DEavq3_nu.useq3true 0 -config Modes.split_PN_NN 0 - -# SciBooNE specific -config SciBarDensity 1.04 -#config SciBarDensity 2.00 -config SciBarRecoDist 10.0 -config PenetratingMuonEnergy 1.4 -config NumRangeSteps 50 diff --git a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx index bf5b664..88c5b5b 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.cxx @@ -1,106 +1,106 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1npip_Evt_1DQ2_nu.h" //******************************************************************** ANL_CC1npip_Evt_1DQ2_nu::ANL_CC1npip_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DQ2 nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 1.5); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.DefineAllowedSpecies("numu"); // Hadronic Cut Info HadCut = fSettings.Found("name", "W14Cut") ? 1.4 : 10.0; if (HadCut == 1.4) { fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_CC1pip_on_n_noEvents_Q2_W14GeV_rebin_firstQ2rem.txt" ); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_CC1pip_on_n_noEvents_Q2_noWcut_HighQ2Gone.txt" ); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral() / double(fNEvents)); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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 < HadCut * 1000.) { q2CCpip = -1.0 * (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_1DQ2_nu.h b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.h index e99fc2b..786ce2d 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.h +++ b/src/ANL/ANL_CC1npip_Evt_1DQ2_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1NPIP_EVT_1DQ2_NU_H_SEEN #define ANL_CC1NPIP_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" //******************************************************************** class ANL_CC1npip_Evt_1DQ2_nu : public Measurement1D { //******************************************************************** // public: ANL_CC1npip_Evt_1DQ2_nu(nuiskey samplekey); virtual ~ANL_CC1npip_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double HadCut; }; #endif diff --git a/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.cxx index aa304a2..49ec81e 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1npip_Evt_1DWNmu_nu.h" //******************************************************************** ANL_CC1npip_Evt_1DWNmu_nu::ANL_CC1npip_Evt_1DWNmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1D W(N mu) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetXTitle("W(N#mu) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_CC1npip_WNmu_per_0.04GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1npip_Evt_1DWNmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = (Pn+Pmu).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1npip_Evt_1DWNmu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.h b/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.h index 2d8620f..9df6234 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.h +++ b/src/ANL/ANL_CC1npip_Evt_1DWNmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1NPIP_EVT_1DWNMU_NU_H_SEEN #define ANL_CC1NPIP_EVT_1DWNMU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1npip_Evt_1DWNmu_nu : public Measurement1D { public: ANL_CC1npip_Evt_1DWNmu_nu(nuiskey samplekey); virtual ~ANL_CC1npip_Evt_1DWNmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.cxx index 198e1e2..72c007c 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1npip_Evt_1DWNpi_nu.h" //******************************************************************** ANL_CC1npip_Evt_1DWNpi_nu::ANL_CC1npip_Evt_1DWNpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1D W(N pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetXTitle("W(N#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_CC1npip_WNpi_per_0.02GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1npip_Evt_1DWNpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pn+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1npip_Evt_1DWNpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.h b/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.h index d8e620c..433b3f7 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.h +++ b/src/ANL/ANL_CC1npip_Evt_1DWNpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1NPIP_EVT_1DWNPI_NU_H_SEEN #define ANL_CC1NPIP_EVT_1DWNPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1npip_Evt_1DWNpi_nu : public Measurement1D { public: ANL_CC1npip_Evt_1DWNpi_nu(nuiskey samplekey); virtual ~ANL_CC1npip_Evt_1DWNpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.cxx index 025880e..639dd5b 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1npip_Evt_1DWmupi_nu.h" //******************************************************************** ANL_CC1npip_Evt_1DWmupi_nu::ANL_CC1npip_Evt_1DWmupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1D W(mu pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetXTitle("W(#mu#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_CC1npip_Wmupi_per_0.04GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1npip_Evt_1DWmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pmu+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1npip_Evt_1DWmupi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.h b/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.h index db3730b..30ce401 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.h +++ b/src/ANL/ANL_CC1npip_Evt_1DWmupi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1NPIP_EVT_1DWMUPI_NU_H_SEEN #define ANL_CC1NPIP_EVT_1DWMUPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1npip_Evt_1DWmupi_nu : public Measurement1D { public: ANL_CC1npip_Evt_1DWmupi_nu(nuiskey samplekey); virtual ~ANL_CC1npip_Evt_1DWmupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx index 7e7f5ab..18b3178 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.cxx @@ -1,97 +1,97 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1npip_Evt_1DcosmuStar_nu.h" //******************************************************************** ANL_CC1npip_Evt_1DcosmuStar_nu::ANL_CC1npip_Evt_1DcosmuStar_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: ANL fhc numu \n" \ "Signal: CC1pi 3 Prong (SignalDef::isCC1pi3Prong) \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos(#theta*)"); fSettings.SetYTitle("Number of events"); fSettings.SetEnuRange(0.0, 1.5); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_CC1npip_cosmuStar.csv" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DcosmuStar_nu.h b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.h index b963bf3..127feef 100644 --- a/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.h +++ b/src/ANL/ANL_CC1npip_Evt_1DcosmuStar_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1NPIP_EVT_1DCOSMUSTAR_NU_H_SEEN #define ANL_CC1NPIP_EVT_1DCOSMUSTAR_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1npip_Evt_1DcosmuStar_nu : public Measurement1D { public: ANL_CC1npip_Evt_1DcosmuStar_nu(nuiskey samplekey); virtual ~ANL_CC1npip_Evt_1DcosmuStar_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx index cb561db..ffa2c2e 100644 --- a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx +++ b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.cxx @@ -1,85 +1,85 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1npip_Evt_1Dppi_nu.h" //******************************************************************** ANL_CC1npip_Evt_1Dppi_nu::ANL_CC1npip_Evt_1Dppi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC1npip_Evt_1Dppi_nu sample. \n" \ "Dist : Pion Momentum : p_{#pi} \n" \ "Signal : numuCC1pi+1p : #nu_{#mu}-CC-1#pi^{+}-1p \n" \ "Target : Deuterium : D2 \n" \ "Flux : ANL FHC numu \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("p_{#pi} (MeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 1.5); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( FitPar::GetDataBase() + "/ANL/CC1pip_on_n/ANL_ppi_CC1npip.csv" ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_Evt_1Dppi_nu.h b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.h index a3adb06..8707d69 100644 --- a/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.h +++ b/src/ANL/ANL_CC1npip_Evt_1Dppi_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1NPIP_EVT_1DPPI_NU_H_SEEN #define ANL_CC1NPIP_EVT_1DPPI_NU_H_SEEN // Fit Includes #include "Measurement1D.h" class ANL_CC1npip_Evt_1Dppi_nu : public Measurement1D { public: ANL_CC1npip_Evt_1Dppi_nu(nuiskey samplekey); virtual ~ANL_CC1npip_Evt_1Dppi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx index 070d4dc..4b9feaa 100644 --- a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.cxx @@ -1,142 +1,142 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1npip_XSec_1DEnu_nu::ANL_CC1npip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DQ2 nu sample. \n" "Target: D2 \n" "Flux: \n" "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 1.5); fSettings.SetS("norm_error", "0.20"); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.DefineAllowedSpecies("numu"); // User can specifiy to use uncorrected data UseCorrectedData = !fSettings.Found("name", "Uncorr"); // User can specify "W14" for W < 1.4 GeV cut // "W16" for W < 1.6 GeV cut // The default is W < 2.0 if (fSettings.Found("name", "W14Cut")) wTrueCut = 1.4; else if (fSettings.Found("name", "W16Cut")) wTrueCut = 1.6; else wTrueCut = 10.0; // Flag for bad combo if (UseCorrectedData && wTrueCut == 1.6) { NUIS_ERR(WRN, "Can not run ANL CC1pi+1n W < 1.6 GeV with CORRECTION, because " "the data DOES NOT EXIST"); NUIS_ERR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY"); NUIS_ERR(WRN, "Reverting to using uncorrected data!"); UseCorrectedData = false; } // 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"; // No W cut } else { DataLocation += "anl82corr-numu-n-to-mu-n-piplus-noW_edges.txt"; } // 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"; } } fSettings.SetDataInput(DataLocation); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 2.0 / 1.0 / (fNEvents + 0.)); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1npip_XSec_1DEnu_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 Enu = -1.0; // 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 < wTrueCut * 1000.) { Enu = Pnu.E() / 1.E3; } fXVar = Enu; return; }; bool ANL_CC1npip_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h index 26336aa..8a5bcaf 100644 --- a/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC1npip_XSec_1DEnu_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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(nuiskey samplekey); virtual ~ANL_CC1npip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); 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 1cbb60d..9dcbd72 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.cxx @@ -1,121 +1,97 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DQ2_nu.h" //******************************************************************** ANL_CC1pi0_Evt_1DQ2_nu::ANL_CC1pi0_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pi0 Event Rate 1DQ2 nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 1.5); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1#pi^{0}"); fSettings.DefineAllowedSpecies("numu"); // Hadronic Cut Info HadCut = fSettings.Found("name", "W14Cut") ? 1.4 : 10.0; if (HadCut == 1.4) { fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pi0_on_n/ANL_CC1pi0_on_n_noEvents_Q2_W14GeV_rebin_firstQ2rem.txt" ); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pi0_on_n/ANL_CC1pi0_on_n_noEvents_Q2_noWcut_HighQ2Gone.txt" ); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral() / double(fNEvents)); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 < HadCut * 1000.) { q2CCpi0 = -1.0 * (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, GetFluxHistogram()); - //PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); - - fMCHist->Scale(fScaleFactor); - fMCFine->Scale(fScaleFactor); - - return; -} -*/ diff --git a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.h b/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.h index d318924..3fdaca3 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.h +++ b/src/ANL/ANL_CC1pi0_Evt_1DQ2_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PI0_EVT_1DQ2_NU_H_SEEN #define ANL_CC1PI0_EVT_1DQ2_NU_H_SEEN // Fit Includes #include "Measurement1D.h" class ANL_CC1pi0_Evt_1DQ2_nu : public Measurement1D { public: ANL_CC1pi0_Evt_1DQ2_nu(nuiskey samplekey); virtual ~ANL_CC1pi0_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double HadCut; }; #endif diff --git a/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.cxx index 1b1c968..5a74500 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DWNmu_nu.h" //******************************************************************** ANL_CC1pi0_Evt_1DWNmu_nu::ANL_CC1pi0_Evt_1DWNmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pi0 Event Rate 1D W(N mu) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{0}"); fSettings.SetXTitle("W(N#mu) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pi0_on_n/ANL_CC1pi0_WNmu_per_0.04GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1pi0_Evt_1DWNmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double hadMass = (Pmu+Pp).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1pi0_Evt_1DWNmu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.h b/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.h index 6b970e3..5e07524 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.h +++ b/src/ANL/ANL_CC1pi0_Evt_1DWNmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPI0_EVT_1DWNMU_NU_H_SEEN #define ANL_CC1PPI0_EVT_1DWNMU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1pi0_Evt_1DWNmu_nu : public Measurement1D { public: ANL_CC1pi0_Evt_1DWNmu_nu(nuiskey samplekey); virtual ~ANL_CC1pi0_Evt_1DWNmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.cxx index f914b48..ebac262 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DWNpi_nu.h" //******************************************************************** ANL_CC1pi0_Evt_1DWNpi_nu::ANL_CC1pi0_Evt_1DWNpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pi0 Event Rate 1D W(N pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{0}"); fSettings.SetXTitle("W(N#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pi0_on_n/ANL_CC1pi0_WNpi_per_0.03GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1pi0_Evt_1DWNpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(111)->fP; double hadMass = (Pp+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1pi0_Evt_1DWNpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.h b/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.h index d5fc9bc..f913372 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.h +++ b/src/ANL/ANL_CC1pi0_Evt_1DWNpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPI0_EVT_1DWNPI_NU_H_SEEN #define ANL_CC1PPI0_EVT_1DWNPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1pi0_Evt_1DWNpi_nu : public Measurement1D { public: ANL_CC1pi0_Evt_1DWNpi_nu(nuiskey samplekey); virtual ~ANL_CC1pi0_Evt_1DWNpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.cxx index 52e62c9..d32ece4 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DWmupi_nu.h" //******************************************************************** ANL_CC1pi0_Evt_1DWmupi_nu::ANL_CC1pi0_Evt_1DWmupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pi0 Event Rate 1D W(mu pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{0}"); fSettings.SetXTitle("W(#mu#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pi0_on_n/ANL_CC1pi0_Wmupi_per_0.04GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1pi0_Evt_1DWmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(111)->fP; double hadMass = (Pmu+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1pi0_Evt_1DWmupi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.h b/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.h index 02a5f99..e1aaf57 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.h +++ b/src/ANL/ANL_CC1pi0_Evt_1DWmupi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPI0_EVT_1DWMUPI_NU_H_SEEN #define ANL_CC1PPI0_EVT_1DWMUPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1pi0_Evt_1DWmupi_nu : public Measurement1D { public: ANL_CC1pi0_Evt_1DWmupi_nu(nuiskey samplekey); virtual ~ANL_CC1pi0_Evt_1DWmupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx index 919263e..8177b45 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx @@ -1,97 +1,97 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1pi0_Evt_1DcosmuStar_nu.h" //******************************************************************** ANL_CC1pi0_Evt_1DcosmuStar_nu::ANL_CC1pi0_Evt_1DcosmuStar_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pi0 Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos(#theta*)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 1.5); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1#pi^{0}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pi0_on_n/ANL_CC1pi0_cosmuStar.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_Evt_1DcosmuStar_nu.h b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.h index c2bc2fa..1ca1ba6 100644 --- a/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.h +++ b/src/ANL/ANL_CC1pi0_Evt_1DcosmuStar_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PI0_EVT_1DCOSMUSTAR_NU_H_SEEN #define ANL_CC1PI0_EVT_1DCOSMUSTAR_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1pi0_Evt_1DcosmuStar_nu : public Measurement1D { public: ANL_CC1pi0_Evt_1DcosmuStar_nu(nuiskey samplekey); virtual ~ANL_CC1pi0_Evt_1DcosmuStar_nu() {}; void FillEventVariables(FitEvent *event); //void ScaleEvents(); bool isSignal(FitEvent *event); //void FillHistograms(); private: }; #endif diff --git a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx index fe39e89..c2cae37 100644 --- a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,137 +1,137 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1pi0_XSec_1DEnu_nu::ANL_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pi0 Event Rate 1DQ2 nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 1.5); fSettings.SetS("norm_error", "0.20"); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1#pi^{0}"); fSettings.DefineAllowedSpecies("numu"); // User can specifiy to use uncorrected data UseCorrectedData = !fSettings.Found("name", "Uncorr"); // User can specify "W14" for W < 1.4 GeV cut // "W16" for W < 1.6 GeV cut // The default is W < 2.0 if (fSettings.Found("name", "W14Cut")) wTrueCut = 1.4; else if (fSettings.Found("name", "W16Cut")) wTrueCut = 1.6; else wTrueCut = 10.0; // Flag for bad combo if (UseCorrectedData && wTrueCut == 1.6) { NUIS_ERR(WRN, "Can not run ANL CC1pi0 W < 1.6 GeV with CORRECTION, because " "the data DOES NOT EXIST"); NUIS_ERR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY"); NUIS_ERR(WRN, "Reverting to using uncorrected data!"); UseCorrectedData = false; } // 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"; } // 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"; } } fSettings.SetDataInput(DataLocation); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 2.0 / 1.0 / (fNEvents + 0.)); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1pi0_XSec_1DEnu_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 Enu = -1.0; 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); } diff --git a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h index 4a9d65a..b8f3c58 100644 --- a/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC1pi0_XSec_1DEnu_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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(nuiskey samplekey); virtual ~ANL_CC1pi0_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); 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 4b7b236..8ea4ed3 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 +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1ppip_Evt_1DQ2_nu::ANL_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1ppip Event Rate 1DQ2 nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.DefineAllowedSpecies("numu"); // Hadronic Cut Info HadCut = fSettings.Found("name", "W14Cut") ? 1.4 : 10.0; if (HadCut == 1.4) { fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_Q2_W14GeV_rebin_firstQ2rem.txt" ); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_Q2_noW_HighQ2Gone.txt" ); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral() / double(fNEvents)); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 or no W cut if (hadMass < HadCut * 1000.) { 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); } diff --git a/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.h b/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.h index b6f2464..140f979 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1DQ2_nu.h @@ -1,39 +1,39 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DQ2_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1DQ2_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double HadCut; }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.cxx index 1a51a1b..1e14a21 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1ppip_Evt_1DWNmu_nu.h" //******************************************************************** ANL_CC1ppip_Evt_1DWNmu_nu::ANL_CC1ppip_Evt_1DWNmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1ppip Event Rate 1D W(N mu) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("W(N#mu) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1ppip_WNmu_per_0.04GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1ppip_Evt_1DWNmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double hadMass = (Pmu+Pp).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1ppip_Evt_1DWNmu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.h b/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.h index 9c59117..5afc2a3 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1DWNmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DWNMU_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DWNMU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1DWNmu_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1DWNmu_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1DWNmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.cxx index fd92a6b..66f5c5a 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1ppip_Evt_1DWNpi_nu.h" //******************************************************************** ANL_CC1ppip_Evt_1DWNpi_nu::ANL_CC1ppip_Evt_1DWNpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1ppip Event Rate 1D W(N pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("W(N#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1ppip_WNpi_per_0.02GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1ppip_Evt_1DWNpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pp+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1ppip_Evt_1DWNpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.h b/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.h index 51c114b..86e0692 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1DWNpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DWNPI_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DWNPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1DWNpi_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1DWNpi_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1DWNpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.cxx index 8842303..9ddd4e2 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CC1ppip_Evt_1DWmupi_nu.h" //******************************************************************** ANL_CC1ppip_Evt_1DWmupi_nu::ANL_CC1ppip_Evt_1DWmupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1ppip Event Rate 1D W(mu pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("W(#mu#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1ppip_Wmupi_per_0.02GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1ppip_Evt_1DWmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pmu+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool ANL_CC1ppip_Evt_1DWmupi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.h b/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.h index 98501e1..526171d 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1DWmupi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DWMUPI_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DWMUPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1DWmupi_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1DWmupi_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1DWmupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx index 4f08b57..074885a 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx @@ -1,105 +1,105 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1ppip_Evt_1DcosmuStar_nu::ANL_CC1ppip_Evt_1DcosmuStar_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos(#theta*)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_cosmuStar_1982.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DcosmuStar_nu.h b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.h index 1823533..07e02db 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1DcosmuStar_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DCOSMUSTAR_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DCOSMUSTAR_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1DcosmuStar_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1DcosmuStar_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1DcosmuStar_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx index 6e52217..429f8f7 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx @@ -1,118 +1,118 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1ppip_Evt_1DcosthAdler_nu::ANL_CC1ppip_Evt_1DcosthAdler_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1ppip Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{Adler}"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_costhAdler_1982.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1ppip_Evt_1DcosthAdler_nu::FillEventVariables(FitEvent *event) { fXVar = -999.99; 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); if (hadMass > 1400) return; // Get Adler cos theta double cosThAdler = FitUtils::CosThAdler(Pnu, Pmu, Ppip, Pp); fXVar = cosThAdler; }; 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, GetFluxHistogram()); PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.h b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.h index 100af15..1953086 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1DcosthAdler_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DCOSTHADLER_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DCOSTHADLER_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1DcosthAdler_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1DcosthAdler_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1DcosthAdler_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx index c4a27c7..05f6f52 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.cxx @@ -1,117 +1,117 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1ppip_Evt_1Dphi_nu::ANL_CC1ppip_Evt_1Dphi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle(" #phi_{Adler}"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_phiAdler_1982.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_CC1ppip_Evt_1Dphi_nu::FillEventVariables(FitEvent *event) { fXVar = -999.99; 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); if (hadMass > 1400) return; // Get phi Adler double phi = FitUtils::PhiAdler(Pnu, Pmu, Ppip, Pp); fXVar = phi; }; 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, GetFluxHistogram()); PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.h b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.h index 80a304e..b7d7317 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1Dphi_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DPHI_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DPHI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1Dphi_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1Dphi_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1Dphi_nu() {}; void FillEventVariables(FitEvent *event); //void ScaleEvents(); bool isSignal(FitEvent *event); //void FillHistograms(); private: TRandom3 rand; }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx index 044b181..8e410aa 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.cxx @@ -1,96 +1,96 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * Derrick et al. Phys Rev D, Vol 23, Number 3, 1 Feb 1981, p 569-575 */ #include "ANL_CC1ppip_Evt_1Dppi_nu.h" //******************************************************************** ANL_CC1ppip_Evt_1Dppi_nu::ANL_CC1ppip_Evt_1Dppi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("ANL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("p_{#pi} (MeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 1.5); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_ppi.csv" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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; // std::cout << "MASS NU P PIP MU = " << Pnu.Mag() << " " << Pp.Mag() << " " << Ppip.Mag() << " " << Pmu.Mag() << std::endl; 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_1Dppi_nu.h b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.h index 01e1fe0..e546be7 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1Dppi_nu.h @@ -1,39 +1,39 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DPPI_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DPPI_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1Dppi_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1Dppi_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1Dppi_nu() {}; void FillEventVariables(FitEvent *event); //void ScaleEvents(); bool isSignal(FitEvent *event); //void FillHistograms(); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx index 696f074..9f2afa3 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx +++ b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.cxx @@ -1,94 +1,94 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * Derrick et al. Phys Rev D, Vol 23, Number 3, 1 Feb 1981, p 569-575 */ #include "ANL_CC1ppip_Evt_1Dthpr_nu.h" //******************************************************************** ANL_CC1ppip_Evt_1Dthpr_nu::ANL_CC1ppip_Evt_1Dthpr_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1npip Event Rate 1DcosmuStar nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos #theta_{p}"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 1.5); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_noEvents_thProt.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_Evt_1Dthpr_nu.h b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.h index 488a52c..95ca73c 100644 --- a/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.h +++ b/src/ANL/ANL_CC1ppip_Evt_1Dthpr_nu.h @@ -1,39 +1,39 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_EVT_1DTHPR_NU_H_SEEN #define ANL_CC1PPIP_EVT_1DTHPR_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_Evt_1Dthpr_nu : public Measurement1D { public: ANL_CC1ppip_Evt_1Dthpr_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_Evt_1Dthpr_nu() {}; void FillEventVariables(FitEvent *event); // void ScaleEvents(); bool isSignal(FitEvent *event); //void FillHistograms(); private: }; #endif diff --git a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx index fa5af57..fa96289 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,139 +1,139 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1ppip_XSec_1DEnu_nu::ANL_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1pip XSec Enu nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.SetS("norm_error", "0.20"); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1#pi^{0}"); fSettings.DefineAllowedSpecies("numu"); // User can specifiy to use uncorrected data UseCorrectedData = !fSettings.Found("name", "Uncorr"); // User can specify "W14" for W < 1.4 GeV cut // "W16" for W < 1.6 GeV cut // The default is no W cut if (fSettings.Found("name", "W14Cut")) wTrueCut = 1.4; else if (fSettings.Found("name", "W16Cut")) wTrueCut = 1.6; else wTrueCut = 10.0; // Flag for bad combo if (UseCorrectedData && wTrueCut == 1.6) { NUIS_ERR(WRN, "Can not run ANL CC1pi+1p W < 1.6 GeV with CORRECTION, because " "the data DOES NOT EXIST"); NUIS_ERR(WRN, "Correction exists for W < 1.4 GeV and no W cut data ONLY"); NUIS_ERR(WRN, "Reverting to using uncorrected data!"); UseCorrectedData = false; } // 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"; } // 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"; } } fSettings.SetDataInput(DataLocation); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 2.0 / 1.0 / (fNEvents + 0.)); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ANL_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; // 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); } diff --git a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h index 367d07a..dfd1e9f 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC1ppip_XSec_1DEnu_nu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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(nuiskey samplekey); virtual ~ANL_CC1ppip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); 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 d73714b..b96b5d6 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx +++ b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.cxx @@ -1,121 +1,92 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC1ppip_XSec_1DQ2_nu::ANL_CC1ppip_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CC1ppip XSec 1DQ2 nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); - fSettings.SetYTitle("d#sigma/dQ^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); + fSettings.SetYTitle("d#sigma/dQ^{2} (GeV^{2})"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.5, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC1pip_on_p/ANL_CC1pip_on_p_dSigdQ2_W14_1982.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon - // this->fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*16./8.; fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / ((fNEvents + 0.) * TotalIntegratedFlux("width")) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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) { - // std::cout << "CC1ppip Enu " << EnuMin << " " << EnuMax << std::endl; return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } -// void ANL_CC1ppip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { -// 46 -// 47 if (event->NumFSParticle(2212) == 0 || -// 48 event->NumFSParticle(211) == 0 || -// 49 event->NumFSParticle(13) == 0) -// 50 return; -// 51 -// 52 TLorentzVector Pnu = event->GetNeutrinoIn()->fP; -// 53 TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; -// 54 TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; -// 55 TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; -// 56 -// 57 double hadMass = FitUtils::MpPi(Pp, Ppip); -// 58 double q2CCpip = -1.0; -// 59 -// 60 // I use the W < 1.4GeV cut ANL data to isolate single pion -// 61 // there is also a W < 1.6 GeV and an uncut spectrum ANL 1982 -// 62 if (hadMass < 1400) q2CCpip = -1*(Pnu-Pmu).Mag2()/1.E6; -// 63 -// 64 fXVar = q2CCpip; -// 65 -// 66 return; -// 67 }; -// 68 -// 69 bool ANL_CC1ppip_XSec_1DQ2_nu::isSignal(FitEvent *event) { -// 70 return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); -// 71 } diff --git a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.h b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.h index d9cd6a0..17dfd36 100644 --- a/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.h +++ b/src/ANL/ANL_CC1ppip_XSec_1DQ2_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC1PPIP_XSEC_1DQ2_NU_H_SEEN #define ANL_CC1PPIP_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class ANL_CC1ppip_XSec_1DQ2_nu : public Measurement1D { public: ANL_CC1ppip_XSec_1DQ2_nu(nuiskey samplekey); virtual ~ANL_CC1ppip_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx index 70bc38a..12f2917 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx @@ -1,114 +1,114 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu::ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_pMu_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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, GetFluxHistogram()); PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); mcHist->Scale(fScaleFactor); mcFine->Scale(fScaleFactor); return; } */ diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h index a75a153..65f293e 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIM1PIP_EVT_1DPMU_NU_H_SEEN #define ANL_CC2PI_1PIM1PIP_EVT_1DPMU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu : public Measurement1D { public: ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); //void ScaleEvents(); //void FillHistograms(); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx index 78b7e6d..d30f2bb 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pim1pip_Evt_1Dppim_nu::ANL_CC2pi_1pim1pip_Evt_1Dppim_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pim1pip_Evt_1Dppim_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("p_{#pi-} (GeV)"); + fSettings.SetXTitle("p_{#pi^{-}} (GeV)"); fSettings.SetYTitle("Number of events (area norm.)"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_ppim_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h index 450d21b..a6eeea3 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIM1PIP_EVT_1DPPIM_NU_H_SEEN #define ANL_CC2PI_1PIM1PIP_EVT_1DPPIM_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pim1pip_Evt_1Dppim_nu : public Measurement1D { public: ANL_CC2pi_1pim1pip_Evt_1Dppim_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pim1pip_Evt_1Dppim_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx index 0749bc7..64f9a72 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pim1pip_Evt_1Dppip_nu::ANL_CC2pi_1pim1pip_Evt_1Dppip_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pim1pip_Evt_1Dppip_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("p_{#pi+} (GeV)"); + fSettings.SetXTitle("p_{#pi^{+}} (GeV)"); fSettings.SetYTitle("Number of events (area norm.)"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi^{+-}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_ppip_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h index 574972e..60ca6ef 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIM1PIP_EVT_1DPPIP_NU_H_SEEN #define ANL_CC2PI_1PIM1PIP_EVT_1DPPIP_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pim1pip_Evt_1Dppip_nu : public Measurement1D { public: ANL_CC2pi_1pim1pip_Evt_1Dppip_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pim1pip_Evt_1Dppip_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx index 3c63f4d..407e82b 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx @@ -1,89 +1,89 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu::ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("cos(#theta*)"); + fSettings.SetXTitle("p_{pr} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information - fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); + fSettings.SetTitle("ANL #nu_mu CC1#pi^{+}1#pi^{-}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip_pProt_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h index fb465d9..3c0447e 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h +++ b/src/ANL/ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIM1PIP_EVT_1DPROT_NU_H_SEEN #define ANL_CC2PI_1PIM1PIP_EVT_1DPROT_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu : public Measurement1D { public: ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx index 9e36fa9..019be75 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pim1pip_XSec_1DEnu_nu::ANL_CC2pi_1pim1pip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pim1pip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pim1pip/CC2pi_1pim1pip1p_xsec.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents) * 2.0 / 1.0 ; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h b/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h index a65aefb..518d841 100644 --- a/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIM1PIP_XSEC_1DENU_NU_H_SEEN #define ANL_CC2PI_1PIM1PIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pim1pip_XSec_1DEnu_nu : public Measurement1D { public: ANL_CC2pi_1pim1pip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pim1pip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); //void ScaleEvents(); //void FillHistograms(); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx index afb2c8d..6dd01ee 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu::ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_pMu_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h index 35751c0..d35641a 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PI0_EVT_1DPMU_NU_H_SEEN #define ANL_CC2PI_1PIP1PI0_EVT_1DPMU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu : public Measurement1D { public: ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx index 2800b13..d722f7d 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu::ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("p_{#pi0} (GeV)"); + fSettings.SetXTitle("p_{#pi^{0}} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_ppi0_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h index 9f9d0a4..f0eaf31 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PI0_EVT_1DPPI0_NU_H_SEEN #define ANL_CC2PI_1PIP1PI0_EVT_1DPPI0_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu : public Measurement1D { public: ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx index 564c557..29e3481 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu::ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("p_{#pi+} (GeV)"); + fSettings.SetXTitle("p_{#pi^{+}} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_ppip_weight.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h index ce19070..1769d26 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PI0_EVT_1DPPIP_NU_H_SEEN #define ANL_CC2PI_1PIP1PI0_EVT_1DPPIP_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu : public Measurement1D { public: ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx index 797a1ad..7c58fad 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx @@ -1,112 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu::ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{prot} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi0_pProt_weight.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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, GetFluxHistogram()); - PlotUtils::FluxUnfoldedScaling(mcFine, GetFluxHistogram()); - - mcHist->Scale(fScaleFactor); - mcFine->Scale(fScaleFactor); - - return; -} -*/ diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h index 934beb4..816a3ec 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PI0_EVT_1DPPROT_NU_H_SEEN #define ANL_CC2PI_1PIP1PI0_EVT_1DPPROT_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu : public Measurement1D { public: ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx index 9c115a5..cb2c4a0 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx @@ -1,85 +1,85 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu::ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pi0/CC2pi_1pip1pi01p_xsec.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h b/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h index 8b149ab..0bdbcc7 100644 --- a/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PI0_XSEC_1DENU_NU_H_SEEN #define ANL_CC2PI_1PIP1PI0_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu : public Measurement1D { public: ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx index 0a31a16..2a55d0a 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu::ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pMu_weight.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h index 70d4f14..bf58356 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PIP_EVT_1DPMU_NU_H_SEEN #define ANL_CC2PI_1PIP1PIP_EVT_1DPMU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu : public Measurement1D { public: ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx index 2cd6926..09e2065 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu::ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{n} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pNeutron_weight.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h index 83b5da7..a536aec 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PIP_EVT_1DPNEUT_NU_H_SEEN #define ANL_CC2PI_1PIP1PIP_EVT_1DPNEUT_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu : public Measurement1D { public: ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx index 91626cc..5a2402d 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu::ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi high} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pHigh_weight.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h index 57a2cf6..e640b5b 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PIP_EVT_1DPPIPHIGH_NU_H_SEEN #define ANL_CC2PI_1PIP1PIP_EVT_1DPPIPHIGH_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu : public Measurement1D { public: ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx index 215157a..3ecd8be 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx @@ -1,98 +1,98 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu::ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi low} (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_pLow_weight.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h index 3046ce9..bbf7492 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PIP_EVT_1DPPIPLOW_NU_H_SEEN #define ANL_CC2PI_1PIP1PIP_EVT_1DPPIPLOW_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu : public Measurement1D { public: ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx index 550807b..3f32bb0 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx @@ -1,85 +1,85 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /** * 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" //******************************************************************** ANL_CC2pi_1pip1pip_XSec_1DEnu_nu::ANL_CC2pi_1pip1pip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_CC2pi_1pip1pip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/CC2pi/1pip1pip/CC2pi_1pip1pip1n_xsec.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h b/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h index 8fc25af..9c0d60a 100644 --- a/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CC2PI_1PIP1PIP_XSEC_1DENU_NU_H_SEEN #define ANL_CC2PI_1PIP1PIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class ANL_CC2pi_1pip1pip_XSec_1DEnu_nu : public Measurement1D { public: ANL_CC2pi_1pip1pip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~ANL_CC2pi_1pip1pip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx index 53b5b17..72957b0 100755 --- a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx +++ b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.cxx @@ -1,160 +1,160 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CCQE_Evt_1DQ2_nu.h" //******************************************************************** ANL_CCQE_Evt_1DQ2_nu::ANL_CCQE_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CCQ2 Event Rate 1DQ2 nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CCQE} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/Q2CORR/MASK"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CCQE"); fSettings.DefineAllowedSpecies("numu"); // Hadronic Cut Info if (fSettings.Found("name", "PRL31")) { fSettings.SetDataInput( FitPar::GetDataBase() + "ANL/ANL_CCQE_Data_PRL31_844.root;ANL_1DQ2_Data" ); fSettings.SetEnuRange(0.0, 3.0); } else if (fSettings.Found("name", "PRD16")) { fSettings.SetDataInput( FitPar::GetDataBase() + "ANL/ANL_CCQE_Data_PRD16_3103.root;ANL_1DQ2_Data" ); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "ANL/ANL_Data_PRD26_537.root;ANL_1DQ2_Data" ); } // is Q2 Correction applied applyQ2correction = fSettings.Found("type", "Q2CORR"); if (applyQ2correction) { fSettings.SetS("q2correction_file", FitPar::GetDataBase() + "/ANL/ANL_CCQE_Data_PRL31_844.root"); fSettings.SetS("q2correction_hist", "ANL_1DQ2_Correction"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = 1.0; // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Correction Histogram if (applyQ2correction) { // Correction Hist CorrectionHist = PlotUtils::GetTH1DFromFile( fSettings.GetS("q2correction_file"), fSettings.GetS("q2correction_hist") ); SetAutoProcessTH1(CorrectionHist, kCMD_Write); // Make uncorrected MC hist fMCHist_NoCorr = (TH1D*) fDataHist->Clone(); fMCHist_NoCorr->Reset(); fMCHist_NoCorr->SetNameTitle( (fName + "_NOCORR").c_str(), (fName + "_NOCORR").c_str()); SetAutoProcessTH1(fMCHist_NoCorr); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } //******************************************************************** void ANL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent * event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; // Fill histogram with reconstructed Q2 Distribution fXVar = -999.9; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); fXVar = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0., true); GetQ2Box()->fQ2 = fXVar; return; }; //******************************************************************** bool ANL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent * event) { //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; // Q2 cut if (GetQ2Box()->fQ2 <= 0) return false; return true; }; //******************************************************************** void ANL_CCQE_Evt_1DQ2_nu::FillHistograms() { //******************************************************************** if (applyQ2correction) { fMCHist_NoCorr->Fill( GetQ2Box()->fQ2, Weight); if (GetQ2Box()->fQ2 < CorrectionHist->GetXaxis()->GetXmax() && GetQ2Box()->fQ2 > CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(GetQ2Box()->fQ2); } Measurement1D::FillHistograms(); } //******************************************************************** void ANL_CCQE_Evt_1DQ2_nu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); // Flux unfold our extra histogram if (applyQ2correction) { if (fMCHist_NoCorr->Integral()) { fMCHist_NoCorr->Scale(fDataHist->Integral() / fMCHist_NoCorr->Integral()); } } } diff --git a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.h b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.h index 80e4c43..0828512 100755 --- a/src/ANL/ANL_CCQE_Evt_1DQ2_nu.h +++ b/src/ANL/ANL_CCQE_Evt_1DQ2_nu.h @@ -1,66 +1,66 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CCQE_Evt_1DQ2_NU_H_SEEN #define ANL_CCQE_Evt_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "CustomVariableBoxes.h" /// \brief ANL Charged Current Quasi-elastic Measurement. /// 1D Event Rate in Q2QE /// /// Class supports multiple published datasets: \n /// - PRD.26.537 = ANL_CCQE_XSec_1DQ2_nu_PRD26, or ANL_CCQE_XSec_1DEnu_nu /// - PRD.16.3103 = ANL_CCQE_XSec_1DQ2_nu_PRD16 /// - PRL.31.844 = ANL_CCQE_XSec_1DEQ2_nu_PRL31 class ANL_CCQE_Evt_1DQ2_nu : public Measurement1D { public: ANL_CCQE_Evt_1DQ2_nu(nuiskey samplekey); virtual ~ANL_CCQE_Evt_1DQ2_nu() {}; /// \brief Fill Q2QE Event Information void FillEventVariables(FitEvent *event); /// \brief Selection only true CCQE bool isSignal(FitEvent *event); /// \brief Fill main histograms and correction histograms void FillHistograms(); /// \brief scale normal MC and corrected MC void ScaleEvents(); /// \brief Use Q2 Box to save correction info inline Q2VariableBox1D* GetQ2Box(){ return static_cast(GetBox()); }; /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox* CreateBox(){ return new Q2VariableBox1D(); }; private: bool applyQ2correction; ///< Flag of whether deut correction applied TH1D* CorrectionHist; ///< Correction factor TH1D* fMCHist_NoCorr; ///< Uncorrected fMCHist }; #endif diff --git a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx index aba8733..169213b 100644 --- a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.cxx @@ -1,152 +1,152 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ANL_CCQE_XSec_1DEnu_nu.h" //******************************************************************** ANL_CCQE_XSec_1DEnu_nu::ANL_CCQE_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL CCQ2 XSec 1DEnu nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/neutron)"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/Q2CORR/MASK"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("ANL #nu_mu CCQE"); fSettings.DefineAllowedSpecies("numu"); // Hadronic Cut Info if (fSettings.Found("name", "PRL31")) { fSettings.SetDataInput( FitPar::GetDataBase() + "ANL/ANL_CCQE_Data_PRL31_844.root;ANL_1DEnu_Data" ); fSettings.SetEnuRange(0.0, 3.0); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "ANL/ANL_CCQE_Data_PRD16_3103.root;ANL_1DEnu_fluxtuned_Data" ); } // is Q2 Correction applied applyQ2correction = fSettings.Found("type", "Q2CORR"); fSettings.SetS("q2correction_file", FitPar::GetDataBase() + "/ANL/ANL_CCQE_Data_PRL31_844.root"); fSettings.SetS("q2correction_hist", "ANL_1DQ2_Correction"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = (GetEventHistogram()->Integral("width") * 2.0 / 1.0 * 1E-38 / (fNEvents + 0.)); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Correction Histogram if (applyQ2correction) { // Correction Hist CorrectionHist = PlotUtils::GetTH1DFromFile( fSettings.GetS("q2correction_file"), fSettings.GetS("q2correction_hist") ); SetAutoProcessTH1(CorrectionHist, kCMD_Write); // Make uncorrected MC hist fMCHist_NoCorr = (TH1D*) fDataHist->Clone(); fMCHist_NoCorr->Reset(); fMCHist_NoCorr->SetNameTitle( (fName + "_NOCORR").c_str(), (fName + "_NOCORR").c_str()); SetAutoProcessTH1(fMCHist_NoCorr); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } //******************************************************************** void ANL_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; // Get Q2 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; GetQ2Box()->fQ2 = q2qe; return; }; //******************************************************************** bool ANL_CCQE_XSec_1DEnu_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCQE(event, 14, EnuMin, EnuMax); }; //******************************************************************** void ANL_CCQE_XSec_1DEnu_nu::FillHistograms() { //******************************************************************** if (applyQ2correction) { fMCHist_NoCorr->Fill( GetQ2Box()->fQ2, Weight); if (GetQ2Box()->fQ2 < CorrectionHist->GetXaxis()->GetXmax() && GetQ2Box()->fQ2 > CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(GetQ2Box()->fQ2); } Measurement1D::FillHistograms(); } //******************************************************************** void ANL_CCQE_XSec_1DEnu_nu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); // Flux unfold our extra histogram if (applyQ2correction) { PlotUtils::FluxUnfoldedScaling(fMCHist_NoCorr, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); } } diff --git a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.h b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.h index 08397e2..1c16bc0 100644 --- a/src/ANL/ANL_CCQE_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_CCQE_XSec_1DEnu_nu.h @@ -1,63 +1,63 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_CCQE_XSEC_1DENU_NU_H_SEEN #define ANL_CCQE_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" #include "CustomVariableBoxes.h" /// /brief ANL Charged Current Quasi-elastic Measurement /// /// 1D Flux unfolded cross-section in Enu /// Class supports multiple published datasets: \n /// - PRD.16.3103 = ANL_CCQE_XSec_1DEnu_nu_PRD16, or ANL_CCQE_XSec_1DEnu_nu /// - PRL.31.844 = ANL_CCQE_XSec_1DEnu_nu_PRL31 class ANL_CCQE_XSec_1DEnu_nu : public Measurement1D { public: ANL_CCQE_XSec_1DEnu_nu(nuiskey samplekey); virtual ~ANL_CCQE_XSec_1DEnu_nu() {}; /// \brief Get Q2 assuming QE scattering void FillEventVariables(FitEvent *event); /// \brief Selection only true CCQE bool isSignal(FitEvent *event); /// \brief fill normal MC and corrected MC void FillHistograms(); /// \brief scale normal MC and corrected MC void ScaleEvents(); /// \brief Use Q2 Box to save correction info inline Q2VariableBox1D* GetQ2Box(){ return static_cast(GetBox()); }; /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox* CreateBox(){ return new Q2VariableBox1D(); }; private: bool applyQ2correction; ///< Apply free nucleon to dueterium correction TH1D* CorrectionHist; ///< Histogram to interpolate free nucleon correction TH1D* fMCHist_NoCorr; ///< Uncorrected fMCHist }; #endif diff --git a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx index 568b693..c3eb39f 100644 --- a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx +++ b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_NC1npip_Evt_1Dppi_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi} (MeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 100.0); // No Enu Range given in v1r0p1 fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu NC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/NC1npip/ANL_ppi_NC1npip_weight.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon this->fScaleFactor = GetEventHistogram()->Integral("width")/((fNEvents+0.)*GetFluxHistogram()->Integral("width"))*(16./8.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_NC1npip_Evt_1Dppi_nu.h b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.h index e70fb45..c4d7b70 100644 --- a/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.h +++ b/src/ANL/ANL_NC1npip_Evt_1Dppi_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_NC1NPIP_EVT_1DPPI_NU_H_SEEN #define ANL_NC1NPIP_EVT_1DPPI_NU_H_SEEN #include "Measurement1D.h" /*! ANL Neutral Current 1npip Measurement. \n\n 1D Kinematics in pion momentum. \n Raw event rates. \n */ class ANL_NC1npip_Evt_1Dppi_nu : public Measurement1D { public: ANL_NC1npip_Evt_1Dppi_nu(nuiskey samplekey); virtual ~ANL_NC1npip_Evt_1Dppi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx b/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx index 77856e1..7ef3420 100644 --- a/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx +++ b/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx @@ -1,94 +1,94 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_NC1ppim_Evt_1DcosmuStar_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("cos*_{#mu}"); + fSettings.SetXTitle("cos#theta*_{#mu}"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.3, 1.5); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu CC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/NC1ppim/ANL_NC1ppim_cosMuStar.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/((fNEvents+0.)*GetFluxHistogram()->Integral("width"))*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_Evt_1DcosmuStar_nu.h b/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.h index de8c258..22b2f3d 100644 --- a/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.h +++ b/src/ANL/ANL_NC1ppim_Evt_1DcosmuStar_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_NC1PPIM_EVT_1DCOSMUSTAR_NU_H_SEEN #define ANL_NC1PPIM_EVT_1DCOSMUSTAR_NU_H_SEEN #include "Measurement1D.h" /*! ANL Neutral Current 1p pi- Measurement. \n\n 1D total cross-section \n */ class ANL_NC1ppim_Evt_1DcosmuStar_nu : public Measurement1D { public: ANL_NC1ppim_Evt_1DcosmuStar_nu(nuiskey samplekey); virtual ~ANL_NC1ppim_Evt_1DcosmuStar_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx b/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx index f33f5b9..b9477d8 100644 --- a/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx +++ b/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.cxx @@ -1,76 +1,76 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ANL_NC1ppim_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.3, 1.5); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("ANL #nu_mu NC1n#pi^{+}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ANL/NC1ppim/ANL_NC1ppim_Enu_xsec.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * 1E-38 /(fNEvents+0)*(16./8.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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/ANL/ANL_NC1ppim_XSec_1DEnu_nu.h b/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.h index d05fc61..69685cf 100644 --- a/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.h +++ b/src/ANL/ANL_NC1ppim_XSec_1DEnu_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ANL_NC1PPIM_XSEC_1DENU_NU_H_SEEN #define ANL_NC1PPIM_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" /*! ANL Neutral Current 1p pi- Measurement. \n\n 1D total cross-section \n */ class ANL_NC1ppim_XSec_1DEnu_nu : public Measurement1D { public: ANL_NC1ppim_XSec_1DEnu_nu(nuiskey samplekey); virtual ~ANL_NC1ppim_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ANL/CMakeLists.txt b/src/ANL/CMakeLists.txt index fc1de57..904405c 100644 --- a/src/ANL/CMakeLists.txt +++ b/src/ANL/CMakeLists.txt @@ -1,149 +1,149 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ANL_CCQE_Evt_1DQ2_nu.cxx ANL_CCQE_XSec_1DEnu_nu.cxx ANL_CC1npip_Evt_1DcosmuStar_nu.cxx ANL_CC1npip_Evt_1Dppi_nu.cxx ANL_CC1npip_Evt_1DQ2_nu.cxx ANL_CC1npip_XSec_1DEnu_nu.cxx ANL_CC1npip_Evt_1DWNpi_nu.cxx ANL_CC1npip_Evt_1DWNmu_nu.cxx ANL_CC1npip_Evt_1DWmupi_nu.cxx ANL_CC1pi0_Evt_1DcosmuStar_nu.cxx ANL_CC1pi0_Evt_1DQ2_nu.cxx ANL_CC1pi0_XSec_1DEnu_nu.cxx ANL_CC1pi0_Evt_1DWNpi_nu.cxx ANL_CC1pi0_Evt_1DWNmu_nu.cxx ANL_CC1pi0_Evt_1DWmupi_nu.cxx ANL_CC1ppip_Evt_1DcosmuStar_nu.cxx ANL_CC1ppip_Evt_1Dppi_nu.cxx ANL_CC1ppip_Evt_1DQ2_nu.cxx ANL_CC1ppip_Evt_1Dthpr_nu.cxx ANL_CC1ppip_XSec_1DEnu_nu.cxx ANL_CC1ppip_XSec_1DQ2_nu.cxx ANL_CC1ppip_Evt_1DcosthAdler_nu.cxx ANL_CC1ppip_Evt_1Dphi_nu.cxx ANL_CC1ppip_Evt_1DWNpi_nu.cxx ANL_CC1ppip_Evt_1DWNmu_nu.cxx ANL_CC1ppip_Evt_1DWmupi_nu.cxx ANL_NC1npip_Evt_1Dppi_nu.cxx ANL_NC1ppim_XSec_1DEnu_nu.cxx ANL_NC1ppim_Evt_1DcosmuStar_nu.cxx ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.cxx ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.cxx ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.cxx ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.cxx ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.cxx ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.cxx ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.cxx ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.cxx ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.cxx ) set(HEADERFILES ANL_CCQE_Evt_1DQ2_nu.h ANL_CCQE_XSec_1DEnu_nu.h ANL_CC1npip_Evt_1DcosmuStar_nu.h ANL_CC1npip_Evt_1Dppi_nu.h ANL_CC1npip_Evt_1DQ2_nu.h ANL_CC1npip_XSec_1DEnu_nu.h ANL_CC1npip_Evt_1DWNpi_nu.h ANL_CC1npip_Evt_1DWNmu_nu.h ANL_CC1npip_Evt_1DWmupi_nu.h ANL_CC1pi0_Evt_1DcosmuStar_nu.h ANL_CC1pi0_Evt_1DQ2_nu.h ANL_CC1pi0_XSec_1DEnu_nu.h ANL_CC1pi0_Evt_1DWNpi_nu.h ANL_CC1pi0_Evt_1DWNmu_nu.h ANL_CC1pi0_Evt_1DWmupi_nu.h ANL_CC1ppip_Evt_1DcosmuStar_nu.h ANL_CC1ppip_Evt_1Dppi_nu.h ANL_CC1ppip_Evt_1DQ2_nu.h ANL_CC1ppip_Evt_1Dthpr_nu.h ANL_CC1ppip_XSec_1DEnu_nu.h ANL_CC1ppip_XSec_1DQ2_nu.h ANL_CC1ppip_Evt_1DcosthAdler_nu.h ANL_CC1ppip_Evt_1Dphi_nu.h ANL_CC1ppip_Evt_1DWNpi_nu.h ANL_CC1ppip_Evt_1DWNpi_nu.h ANL_CC1ppip_Evt_1DWNmu_nu.h ANL_CC1ppip_Evt_1DWmupi_nu.h ANL_NC1npip_Evt_1Dppi_nu.h ANL_NC1ppim_XSec_1DEnu_nu.h ANL_NC1ppim_Evt_1DcosmuStar_nu.h ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu.h ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu.h ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu.h ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu.h) set(LIBNAME expANL) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/ANL) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/ANL/SAMPLEREADME b/src/ANL/SAMPLEREADME deleted file mode 100644 index 2038655..0000000 --- a/src/ANL/SAMPLEREADME +++ /dev/null @@ -1,9 +0,0 @@ -Samples for this Measurement - -ANL_CCQE_Evt_1DQ2_nu : Event rate measurement in reconstructed Q2 for ANL numu data. - -ANL_CCQE_XSec_1DEnu_nu : Cross-section measurement as a fucntion of reconstructed Enu. - -ANL_CC1ppip: - -ANL_CC2pi: diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.cxx index 4e53199..949311c 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu::ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/dp_{#mu} (cm^{2} Ar^{-1} GeV^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #bar#nu_{#mu} 1Dp_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dmumom_nubar.dat" ); fSettings.DefineAllowedSpecies("numubar"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(-13); if (pmu) fXVar = pmu->fP.Vect().Mag() / 1000; return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, -14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h index cbb3562..29844c1 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.cxx index 5a60f73..7e33eb1 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dpmu_nu::ArgoNeuT_CC1Pi_XSec_1Dpmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dpmu_nu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/dp_{#mu} (cm^{2} Ar^{-1} GeV^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #nu_{#mu} 1Dp_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dmumom_nu.dat" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dpmu_nu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(13); if (pmu) fXVar = pmu->fP.Vect().Mag() / 1000; return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dpmu_nu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, 14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h index 3a6309f..df5a986 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dpmu_nu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dpmu_nu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dpmu_nu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dpmu_nu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.cxx index c6cbce8..00146f2 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu::ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu} (cm^{2} nucleon^{-1} degree^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #bar#nu_{#mu} 1D#theta_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dthetamu_nubar.dat" ); fSettings.DefineAllowedSpecies("numubar"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(-13); if (pmu) fXVar = pmu->fP.Vect().Theta() * 180.0 / TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, -14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h index 2af9178..76ffc2b 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.cxx index 3629843..ee22ad0 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu::ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu} (cm^{2} nucleon^{-1} degree^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #nu_{#mu} 1D#theta_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dthetamu_nu.dat" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(13); if (pmu) fXVar = pmu->fP.Vect().Theta() * 180.0 / TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, 14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h index 21438a3..a149343 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.cxx index 13d90ec..f590df3 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu::ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#mu#pi} (GeV)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu#pi} (cm^{2} nucleon^{-1} degree^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #bar#nu_{#mu} 1D#theta_{#mu#pi}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dthetamupi_nubar.dat" ); fSettings.DefineAllowedSpecies("numubar"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(-13); FitParticle* ppi = event->GetHMFSChargePions(); if (pmu && ppi) fXVar = pmu->fP.Vect().Angle(ppi->fP.Vect()) * 180.0 / TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, -14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h index 1cab874..6c77d44 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.cxx index 19350ad..1f8fd72 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu::ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#mu#pi} (GeV)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu#pi} (cm^{2} nucleon^{-1} degree^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #nu_{#mu} 1D#theta_{#mu#pi}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dthetamupi_nu.dat" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu::FillEventVariables(FitEvent *event) { FitParticle* pmu = event->GetHMFSParticle(13); FitParticle* ppi = event->GetHMFSChargePions(); if (pmu && ppi) fXVar = pmu->fP.Vect().Angle(ppi->fP.Vect()) * 180.0 / TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, 14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h index b9f3a0e..2f68776 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.cxx index d037562..b83886e 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu::ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2} nucleon^{-1} degree^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #bar#nu_{#mu} 1D#theta_{#pi}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dthetapi_nubar.dat" ); fSettings.DefineAllowedSpecies("numubar"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu::FillEventVariables(FitEvent *event) { FitParticle* p = event->GetHMFSChargePions(); if (p) fXVar = p->fP.Vect().Theta() * 180.0 / TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, -14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h index 8444f08..ad6c052 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.cxx index f357f6b..8651ed8 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h" //******************************************************************** ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu::ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: CC, single charged pion > 0.1 GeV/c, no other mesons. \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2} nucleon^{-1} degree^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("Ar"); // CC1Pi plot information fSettings.SetTitle("ArgoNeut CC1#pi^{#pm} #nu_{#mu} 1D#theta_{#pi}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CC1Pi_dsig_dthetapi_nu.dat" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu::FillEventVariables(FitEvent *event) { FitParticle* p = event->GetHMFSChargePions(); if (p) fXVar = p->fP.Vect().Theta() * 180.0 / TMath::Pi(); return; }; //******************************************************************** bool ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu::isSignal(FitEvent *event) //******************************************************************** { if (!SignalDef::isCCINC(event, 14, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPiCharge = event->NumFSChargePions(); int nPiZero = event->NumFSPiZero(); if (nPiCharge != 1 || nMesons != 1 || nLeptons != 1 || nPiZero > 0) { return false; } if (event->GetHMFSChargePions()->fP.Vect().Mag() < 100) return false; return true; } diff --git a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h index eb14af9..b659311 100644 --- a/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h +++ b/src/ArgoNeuT/ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu_H_SEEN #define ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu : public Measurement1D { public: ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu(nuiskey samplekey); virtual ~ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx index 20cfb61..0f0959a 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx @@ -1,74 +1,74 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ArgoNeuT_CCInc_XSec_1Dpmu_nu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dpmu_nu::ArgoNeuT_CCInc_XSec_1Dpmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CCInc_XSec_1Dpmu_nu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/dp_{#mu} (cm^{2} Ar^{-1} GeV^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 50.0); fSettings.DefineAllowedTargets("Ar"); // CCQELike plot information fSettings.SetTitle("ArgoNeut CC-INC numu 1Dp_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CCInc_dsig_dmumom_nu.dat" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1Dpmu_nu.h b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.h index c02159e..c7cd929 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.h +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dpmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ArgoNeuT_CCInc_XSec_1Dpmu_nu_H_SEEN #define ArgoNeuT_CCInc_XSec_1Dpmu_nu_H_SEEN #include "Measurement1D.h" class ArgoNeuT_CCInc_XSec_1Dpmu_nu : public Measurement1D { public: ArgoNeuT_CCInc_XSec_1Dpmu_nu(nuiskey samplekey); virtual ~ArgoNeuT_CCInc_XSec_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx index bfb6101..3fd3dc4 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx @@ -1,56 +1,56 @@ #include "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dthetamu_antinu::ArgoNeuT_CCInc_XSec_1Dthetamu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("theta_{#mu} (degrees)"); + fSettings.SetXTitle("#theta_{#mu} (degrees)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu} (cm^{2} Ar^{-1} degrees^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 50.0); fSettings.DefineAllowedTargets("Ar"); // CCQELike plot information fSettings.SetTitle("ArgoNeut CC-INC antinumu 1D#theta_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CCInc_dsig_dthetamu_nubar.dat" ); fSettings.DefineAllowedSpecies("numub"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 94acc32..a77d50d 100644 --- a/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx +++ b/src/ArgoNeuT/ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx @@ -1,59 +1,59 @@ #include "ArgoNeuT_CCInc_XSec_1Dthetamu_nu.h" //******************************************************************** ArgoNeuT_CCInc_XSec_1Dthetamu_nu::ArgoNeuT_CCInc_XSec_1Dthetamu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "ArgoNeuT_CCInc_XSec_1Dthetamu_antinu sample. \n" \ "Target: Ar40 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("theta_{#mu} (degrees)"); + fSettings.SetXTitle("#theta_{#mu} (degrees)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu} (cm^{2} Ar^{-1} degrees^{-1})"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 50.0); fSettings.DefineAllowedTargets("Ar"); // CCQELike plot information fSettings.SetTitle("ArgoNeut CC-INC numu 1D#theta_{#mu}"); fSettings.SetDataInput( FitPar::GetDataBase() + "/ArgoNeuT/CCInc_dsig_dthetamu_nu.dat"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (40.0 /*Data is /Ar */) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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/ArgoNeuT/CMakeLists.txt b/src/ArgoNeuT/CMakeLists.txt index 40f9e95..476b09a 100644 --- a/src/ArgoNeuT/CMakeLists.txt +++ b/src/ArgoNeuT/CMakeLists.txt @@ -1,72 +1,72 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.cxx ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.cxx ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.cxx ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.cxx ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.cxx ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.cxx ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.cxx ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.cxx ArgoNeuT_CCInc_XSec_1Dpmu_antinu.cxx ArgoNeuT_CCInc_XSec_1Dpmu_nu.cxx ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.cxx ArgoNeuT_CCInc_XSec_1Dthetamu_nu.cxx ) set(HEADERFILES ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu.h ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h ArgoNeuT_CCInc_XSec_1Dpmu_antinu.h ArgoNeuT_CCInc_XSec_1Dpmu_nu.h ArgoNeuT_CCInc_XSec_1Dthetamu_antinu.h ArgoNeuT_CCInc_XSec_1Dthetamu_nu.h ) set(LIBNAME expArgoNeuT) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) # Add Extra Links if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/ArgoNeuT/) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx index ead028f..d251525 100644 --- a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx +++ b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.cxx @@ -1,89 +1,89 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1npim_XSec_1DEnu_antinu.h" //******************************************************************** BEBC_CC1npim_XSec_1DEnu_antinu::BEBC_CC1npim_XSec_1DEnu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1npim_XSec_1DEnu_antinu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1npim_XSec_1DEnu_antinu"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/theses/BEBC_theses_ANU_CC1pi-_nFin_W14.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DEnu_antinu.h b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.h index b0c2b91..9816d3a 100644 --- a/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.h +++ b/src/BEBC/BEBC_CC1npim_XSec_1DEnu_antinu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1NPIM_XSEC_1DENU_ANTINU_H_SEEN #define BEBC_CC1NPIM_XSEC_1DENU_ANTINU_H_SEEN #include "Measurement1D.h" class BEBC_CC1npim_XSec_1DEnu_antinu : public Measurement1D { public: BEBC_CC1npim_XSec_1DEnu_antinu(nuiskey samplekey); virtual ~BEBC_CC1npim_XSec_1DEnu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx index 9cdb865..6047aab 100644 --- a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx +++ b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.cxx @@ -1,109 +1,109 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1npim_XSec_1DQ2_antinu.h" //******************************************************************** BEBC_CC1npim_XSec_1DQ2_antinu::BEBC_CC1npim_XSec_1DQ2_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1npim_XSec_1DQ2_antinu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1npim_XSec_1DQ2_antinu"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/Dfill/BEBC_Dfill_CC1pi-_on_n_W14_edit.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); 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()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_CC1npim_XSec_1DQ2_antinu.h b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.h index 72bc15e..5fadab6 100644 --- a/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.h +++ b/src/BEBC/BEBC_CC1npim_XSec_1DQ2_antinu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1NPIM_XSEC_1DQ2_ANTINU_H_SEEN #define BEBC_CC1NPIM_XSEC_1DQ2_ANTINU_H_SEEN #include "Measurement1D.h" class BEBC_CC1npim_XSec_1DQ2_antinu : public Measurement1D { public: BEBC_CC1npim_XSec_1DQ2_antinu(nuiskey samplekey); virtual ~BEBC_CC1npim_XSec_1DQ2_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillHistograms(); void Write(std::string drawOpts); private: TH1D *hadMassHist; double hadMass; }; #endif diff --git a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx index 74fb299..9955574 100644 --- a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx +++ b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1npip_XSec_1DEnu_nu.h" //******************************************************************** BEBC_CC1npip_XSec_1DEnu_nu::BEBC_CC1npip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1npip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1npip_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/theses/BEBC_theses_CC1pip_on_n_W14.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DEnu_nu.h b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.h index e9f2345..c96f938 100644 --- a/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.h +++ b/src/BEBC/BEBC_CC1npip_XSec_1DEnu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1NPIP_XSEC_1DENU_NU_H_SEEN #define BEBC_CC1NPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class BEBC_CC1npip_XSec_1DEnu_nu : public Measurement1D { public: BEBC_CC1npip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BEBC_CC1npip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx index c486408..2c2311a 100644 --- a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.cxx @@ -1,108 +1,108 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1npip_XSec_1DQ2_nu.h" //******************************************************************** BEBC_CC1npip_XSec_1DQ2_nu::BEBC_CC1npip_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1npip_XSec_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1npip_XSec_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/Dfill/BEBC_Dfill_CC1pi+_on_n_W14_edit.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); 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()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_CC1npip_XSec_1DQ2_nu.h b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.h index 1581a1c..d185fce 100644 --- a/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.h +++ b/src/BEBC/BEBC_CC1npip_XSec_1DQ2_nu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1NPIP_XSEC_1DQ2_NU_H_SEEN #define BEBC_CC1NPIP_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class BEBC_CC1npip_XSec_1DQ2_nu : public Measurement1D { public: BEBC_CC1npip_XSec_1DQ2_nu(nuiskey samplekey); virtual ~BEBC_CC1npip_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillHistograms(); void Write(std::string drawOpts); private: TH1D *hadMassHist; double hadMass; }; #endif diff --git a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx index 3f31236..9220600 100644 --- a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1pi0_XSec_1DEnu_nu.h" //******************************************************************** BEBC_CC1pi0_XSec_1DEnu_nu::BEBC_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1pi0_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1pi0_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/theses/BEBC_theses_CC1pi0_W14.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DEnu_nu.h b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.h index 5ec66b8..822a9e7 100644 --- a/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.h +++ b/src/BEBC/BEBC_CC1pi0_XSec_1DEnu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1PI0_XSEC_1DENU_NU_H_SEEN #define BEBC_CC1PI0_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class BEBC_CC1pi0_XSec_1DEnu_nu : public Measurement1D { public: BEBC_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BEBC_CC1pi0_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx index 31a4725..64bd2bb 100644 --- a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.cxx @@ -1,108 +1,108 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1pi0_XSec_1DQ2_nu.h" //******************************************************************** BEBC_CC1pi0_XSec_1DQ2_nu::BEBC_CC1pi0_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1pi0_XSec_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1pi0_XSec_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/Dfill/BEBC_Dfill_CC1pi0_on_n_W14_edit.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); 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()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_CC1pi0_XSec_1DQ2_nu.h b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.h index d6172ef..874812b 100644 --- a/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.h +++ b/src/BEBC/BEBC_CC1pi0_XSec_1DQ2_nu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1PI0_XSEC_1DQ2_NU_H_SEEN #define BEBC_CC1PI0_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class BEBC_CC1pi0_XSec_1DQ2_nu : public Measurement1D { public: BEBC_CC1pi0_XSec_1DQ2_nu(nuiskey samplekey); virtual ~BEBC_CC1pi0_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillHistograms(); void Write(std::string drawOpts); private: TH1D *hadMassHist; double hadMass; }; #endif diff --git a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx index 0503e31..0a381ce 100644 --- a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx +++ b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1ppim_XSec_1DEnu_antinu.h" //******************************************************************** BEBC_CC1ppim_XSec_1DEnu_antinu::BEBC_CC1ppim_XSec_1DEnu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1ppim_XSec_1DEnu_antinu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/proton)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1ppim_XSec_1DEnu_antinu"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/theses/BEBC_theses_ANU_CC1pi-_pFin_W14.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DEnu_antinu.h b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.h index d8b3c47..2d85022 100644 --- a/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.h +++ b/src/BEBC/BEBC_CC1ppim_XSec_1DEnu_antinu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1PPIM_XSEC_1DENU_ANTINU_H_SEEN #define BEBC_CC1PPIM_XSEC_1DENU_ANTINU_H_SEEN #include "Measurement1D.h" class BEBC_CC1ppim_XSec_1DEnu_antinu : public Measurement1D { public: BEBC_CC1ppim_XSec_1DEnu_antinu(nuiskey samplekey); virtual ~BEBC_CC1ppim_XSec_1DEnu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx index d7f376f..20e742b 100644 --- a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx +++ b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.cxx @@ -1,107 +1,107 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1ppim_XSec_1DQ2_antinu.h" //******************************************************************** BEBC_CC1ppim_XSec_1DQ2_antinu::BEBC_CC1ppim_XSec_1DQ2_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1ppim_XSec_1DQ2_antinu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1ppim_XSec_1DQ2_antinu"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/Dfill/BEBC_Dfill_CC1pi-_on_p_W14_edit.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); 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()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_CC1ppim_XSec_1DQ2_antinu.h b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.h index 027824b..f1f6040 100644 --- a/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.h +++ b/src/BEBC/BEBC_CC1ppim_XSec_1DQ2_antinu.h @@ -1,43 +1,43 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1PPIM_XSEC_1DQ2_ANTINU_H_SEEN #define BEBC_CC1PPIM_XSEC_1DQ2_ANTINU_H_SEEN #include "Measurement1D.h" class BEBC_CC1ppim_XSec_1DQ2_antinu : public Measurement1D { public: BEBC_CC1ppim_XSec_1DQ2_antinu(nuiskey samplekey); virtual ~BEBC_CC1ppim_XSec_1DQ2_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillHistograms(); void Write(std::string drawOpts); private: TH1D *hadMassHist; double hadMass; }; #endif diff --git a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx index ca501fc..e8bb93e 100644 --- a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1ppip_XSec_1DEnu_nu.h" //******************************************************************** BEBC_CC1ppip_XSec_1DEnu_nu::BEBC_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1ppip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/proton)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1ppip_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/theses/BEBC_theses_CC1pip_on_p_W14.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1DEnu_nu.h b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.h index d4b100f..fa303be 100644 --- a/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.h +++ b/src/BEBC/BEBC_CC1ppip_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1PPIP_XSEC_1DENU_NU_H_SEEN #define BEBC_CC1PPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class BEBC_CC1ppip_XSec_1DEnu_nu : public Measurement1D { public: BEBC_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BEBC_CC1ppip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx index 3bc4a93..6f5c9da 100644 --- a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.cxx @@ -1,112 +1,112 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CC1ppip_XSec_1DQ2_nu.h" //******************************************************************** BEBC_CC1ppip_XSec_1DQ2_nu::BEBC_CC1ppip_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CC1ppip_XSec_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)"); fSettings.SetAllowedTypes("FIX/FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CC1ppip_XSec_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BEBC/Dfill/BEBC_Dfill_CC1pi+_on_p_W14_edit.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38)/((fNEvents+0.)*TotalIntegratedFlux("width"))*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); 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()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_CC1ppip_XSec_1DQ2_nu.h b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.h index 7c3e913..6e87efa 100644 --- a/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.h +++ b/src/BEBC/BEBC_CC1ppip_XSec_1DQ2_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CC1PPIP_XSEC_1DQ2_NU_H_SEEN #define BEBC_CC1PPIP_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class BEBC_CC1ppip_XSec_1DQ2_nu : public Measurement1D { public: BEBC_CC1ppip_XSec_1DQ2_nu(nuiskey samplekey); virtual ~BEBC_CC1ppip_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillHistograms(); void Write(std::string drawOpts); private: TH1D *hadMassHist; double hadMass; }; #endif diff --git a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx index b1b323f..2d71de9 100755 --- a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx +++ b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.cxx @@ -1,132 +1,132 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BEBC_CCQE_XSec_1DQ2_nu.h" //******************************************************************** BEBC_CCQE_XSec_1DQ2_nu::BEBC_CCQE_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BEBC_CCQE_XSec_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CCQE} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/Q2CORR/MASK"); fSettings.SetEnuRange(0.0, 200.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BEBC_CCQE_XSec_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "BEBC/BEBC_CCQE_Data_NPB343_285.root;BEBC_1DQ2_Data"); // is Q2 Correction applied applyQ2correction = fSettings.Found("type", "Q2CORR"); if (applyQ2correction) { fSettings.SetS("q2correction_file", FitPar::GetDataBase() + "/data/ANL/ANL_CCQE_Data_PRL31_844.root"); fSettings.SetS("q2correction_hist", "ANL_XSec_1DQ2_Correction"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = (GetEventHistogram()->Integral("width")/(fNEvents+0.))*1E-38 / (TotalIntegratedFlux("width")); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Correction Histogram if (applyQ2correction) { // Correction Hist CorrectionHist = PlotUtils::GetTH1DFromFile( fSettings.GetS("q2correction_file"), fSettings.GetS("q2correction_hist") ); SetAutoProcessTH1(CorrectionHist, kCMD_Write); // Make uncorrected MC hist fMCHist_NoCorr = (TH1D*) fDataHist->Clone(); fMCHist_NoCorr->Reset(); fMCHist_NoCorr->SetNameTitle( (fName + "_NOCORR").c_str(), (fName + "_NOCORR").c_str()); SetAutoProcessTH1(fMCHist_NoCorr); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } //******************************************************************** void BEBC_CCQE_XSec_1DQ2_nu::FillEventVariables(FitEvent * event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; // Fill histogram with reconstructed Q2 Distribution fXVar = -999.9; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); fXVar = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0., true); GetQ2Box()->fQ2 = fXVar; return; }; //******************************************************************** bool BEBC_CCQE_XSec_1DQ2_nu::isSignal(FitEvent * event) { //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; // Q2 cut if (GetQ2Box()->fQ2 <= 0) return false; return true; }; //******************************************************************** void BEBC_CCQE_XSec_1DQ2_nu::FillHistograms() { //******************************************************************** if (applyQ2correction) { fMCHist_NoCorr->Fill( GetQ2Box()->fQ2, Weight); if (GetQ2Box()->fQ2 < CorrectionHist->GetXaxis()->GetXmax() && GetQ2Box()->fQ2 > CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(GetQ2Box()->fQ2); } Measurement1D::FillHistograms(); } diff --git a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.h b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.h index 3e10cce..90dd722 100755 --- a/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.h +++ b/src/BEBC/BEBC_CCQE_XSec_1DQ2_nu.h @@ -1,57 +1,57 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEBC_CCQE_XSEC_1DQ2_NU_H_SEEN #define BEBC_CCQE_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "CustomVariableBoxes.h" //******************************************************************** class BEBC_CCQE_XSec_1DQ2_nu : public Measurement1D { //******************************************************************** public: BEBC_CCQE_XSec_1DQ2_nu(nuiskey samplekey); virtual ~BEBC_CCQE_XSec_1DQ2_nu() {}; /// \brief Fill Q2QE Event Information void FillEventVariables(FitEvent *event); /// \brief Selection only true CCQE bool isSignal(FitEvent *event); /// \brief Fill main histograms and correction histograms void FillHistograms(); /// \brief Use Q2 Box to save correction info inline Q2VariableBox1D* GetQ2Box(){ return static_cast(GetBox()); }; /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox* CreateBox(){ return new Q2VariableBox1D(); }; private: bool applyQ2correction; ///< Flag of whether deut correction applied TH1D* CorrectionHist; ///< Correction factor TH1D* fMCHist_NoCorr; ///< Uncorrected fMCHist }; #endif diff --git a/src/BEBC/CMakeLists.txt b/src/BEBC/CMakeLists.txt index 86dd94a..f2b2715 100644 --- a/src/BEBC/CMakeLists.txt +++ b/src/BEBC/CMakeLists.txt @@ -1,67 +1,67 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES BEBC_CC1npim_XSec_1DEnu_antinu.cxx BEBC_CC1npim_XSec_1DQ2_antinu.cxx BEBC_CC1npip_XSec_1DEnu_nu.cxx BEBC_CC1npip_XSec_1DQ2_nu.cxx BEBC_CC1pi0_XSec_1DEnu_nu.cxx BEBC_CC1pi0_XSec_1DQ2_nu.cxx BEBC_CC1ppim_XSec_1DEnu_antinu.cxx BEBC_CC1ppim_XSec_1DQ2_antinu.cxx BEBC_CC1ppip_XSec_1DEnu_nu.cxx BEBC_CC1ppip_XSec_1DQ2_nu.cxx BEBC_CCQE_XSec_1DQ2_nu.cxx ) set(HEADERFILES BEBC_CC1npim_XSec_1DEnu_antinu.h BEBC_CC1npim_XSec_1DQ2_antinu.h BEBC_CC1npip_XSec_1DEnu_nu.h BEBC_CC1npip_XSec_1DQ2_nu.h BEBC_CC1pi0_XSec_1DEnu_nu.h BEBC_CC1pi0_XSec_1DQ2_nu.h BEBC_CC1ppim_XSec_1DEnu_antinu.h BEBC_CC1ppim_XSec_1DQ2_antinu.h BEBC_CC1ppip_XSec_1DEnu_nu.h BEBC_CC1ppip_XSec_1DQ2_nu.h BEBC_CCQE_XSec_1DQ2_nu.h ) set(LIBNAME expBEBC) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/BNL) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx index df844bb..84ab4b1 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.cxx @@ -1,93 +1,93 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1npip_Evt_1DQ2_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 3 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1npip_Evt_1DQ2_nu::BNL_CC1npip_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1npip_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL_CC1npip_Evt_1DQ2_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_n/BNL_CC1pip_on_n_noEvents_q2_noWcut_HighQ2Gone.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor =GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.h b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.h index 4a85f6a..4921f4d 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.h +++ b/src/BNL/BNL_CC1npip_Evt_1DQ2_nu.h @@ -1,47 +1,47 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1NPIP_EVT_1DQ2_NU_H_SEEN #define BNL_CC1NPIP_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 3 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1npip_Evt_1DQ2_nu : public Measurement1D { public: BNL_CC1npip_Evt_1DQ2_nu(nuiskey samplekey); virtual ~BNL_CC1npip_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.cxx b/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.cxx index d223090..ccb5c92 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.cxx +++ b/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1npip_Evt_1DWNmu_nu.h" //******************************************************************** BNL_CC1npip_Evt_1DWNmu_nu::BNL_CC1npip_Evt_1DWNmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1npip Event Rate 1D W(N mu) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1n#pi^{+}"); fSettings.SetXTitle("W(N#mu) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_n/BNL_CC1npip_WNmu_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1npip_Evt_1DWNmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double hadMass = (Pn+Pmu).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1npip_Evt_1DWNmu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.h b/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.h index a259510..cf2351d 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.h +++ b/src/BNL/BNL_CC1npip_Evt_1DWNmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1NPIP_EVT_1DWNMU_NU_H_SEEN #define BNL_CC1NPIP_EVT_1DWNMU_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1npip_Evt_1DWNmu_nu : public Measurement1D { public: BNL_CC1npip_Evt_1DWNmu_nu(nuiskey samplekey); virtual ~BNL_CC1npip_Evt_1DWNmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.cxx b/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.cxx index 867b651..14d4bd3 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.cxx +++ b/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1npip_Evt_1DWNpi_nu.h" //******************************************************************** BNL_CC1npip_Evt_1DWNpi_nu::BNL_CC1npip_Evt_1DWNpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1npip Event Rate 1D W(N pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1n#pi^{+}"); fSettings.SetXTitle("W(N#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_n/BNL_CC1npip_WNpi_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1npip_Evt_1DWNpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pn = event->GetHMFSParticle(2112)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pn+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1npip_Evt_1DWNpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.h b/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.h index b5d9405..19be2ac 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.h +++ b/src/BNL/BNL_CC1npip_Evt_1DWNpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1NPIP_EVT_1DWNPI_NU_H_SEEN #define BNL_CC1NPIP_EVT_1DWNPI_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1npip_Evt_1DWNpi_nu : public Measurement1D { public: BNL_CC1npip_Evt_1DWNpi_nu(nuiskey samplekey); virtual ~BNL_CC1npip_Evt_1DWNpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.cxx b/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.cxx index 3c56224..f0443e4 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.cxx +++ b/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1npip_Evt_1DWmupi_nu.h" //******************************************************************** BNL_CC1npip_Evt_1DWmupi_nu::BNL_CC1npip_Evt_1DWmupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1npip Event Rate 1D W(mu pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1n#pi^{+}"); fSettings.SetXTitle("W(#mu#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_n/BNL_CC1npip_Wmupi_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1npip_Evt_1DWmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2112) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pmu+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1npip_Evt_1DWmupi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2112, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.h b/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.h index e396d87..649fd1b 100644 --- a/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.h +++ b/src/BNL/BNL_CC1npip_Evt_1DWmupi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1NPIP_EVT_1DWMUPI_NU_H_SEEN #define BNL_CC1NPIP_EVT_1DWMUPI_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1npip_Evt_1DWmupi_nu : public Measurement1D { public: BNL_CC1npip_Evt_1DWmupi_nu(nuiskey samplekey); virtual ~BNL_CC1npip_Evt_1DWmupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx index a2f8080..9f55212 100644 --- a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.cxx @@ -1,114 +1,114 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1npip_XSec_1DEnu_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 7 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1npip_XSec_1DEnu_nu::BNL_CC1npip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1npip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetS("norm_error", "0.15"); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BNL_CC1npip_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); // User can specifiy to use uncorrected data UseCorrectedData = !fSettings.Found("name", "Uncorr"); // Now read in different data depending on what the user has specified std::string DataLocation = GeneralUtils::GetTopLevelDir() + "/data/BNL/CC1pip_on_n/"; // If we're using corrected data if (UseCorrectedData) { DataLocation += "BNL_CC1pip_on_n_1986_corr.txt"; // If we're using raw uncorrected data } else { DataLocation += "BNL_CC1pip_on_n_1986.txt"; } fSettings.SetDataInput(DataLocation); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/proton fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / ((fNEvents + 0.)) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.h b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.h index 0770b35..0c54565 100644 --- a/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CC1npip_XSec_1DEnu_nu.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1NPIP_XSEC_1DENU_NU_H_SEEN #define BNL_CC1NPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 7 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1npip_XSec_1DEnu_nu : public Measurement1D { public: BNL_CC1npip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CC1npip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool UseCorrectedData; }; #endif diff --git a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx index 11ff3c4..9507b05 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.cxx @@ -1,95 +1,95 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1pi0_Evt_1DQ2_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 3 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1pi0_Evt_1DQ2_nu::BNL_CC1pi0_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1pi0_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL_CC1pi0_Evt_1DQ2_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pi0_on_n/BNL_CC1pi0_on_n_noEvents_q2_noWcut_HighQ2Gone.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 // 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_Evt_1DQ2_nu.h b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.h index 87d137a..c9237f8 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.h +++ b/src/BNL/BNL_CC1pi0_Evt_1DQ2_nu.h @@ -1,47 +1,47 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PI0_EVT_1DQ2_NU_H_SEEN #define BNL_CC1PI0_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 3 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1pi0_Evt_1DQ2_nu : public Measurement1D { public: BNL_CC1pi0_Evt_1DQ2_nu(nuiskey samplekey); virtual ~BNL_CC1pi0_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.cxx b/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.cxx index d08833a..2eb4d32 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.cxx +++ b/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1pi0_Evt_1DWNmu_nu.h" //******************************************************************** BNL_CC1pi0_Evt_1DWNmu_nu::BNL_CC1pi0_Evt_1DWNmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1pi0 Event Rate 1D W(N mu) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1p#pi^{0}"); fSettings.SetXTitle("W(N#mu) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pi0_on_n/BNL_CC1pi0_WNmu_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1pi0_Evt_1DWNmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double hadMass = (Pmu+Pp).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1pi0_Evt_1DWNmu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.h b/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.h index 24c17bd..a87bd26 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.h +++ b/src/BNL/BNL_CC1pi0_Evt_1DWNmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPI0_EVT_1DWNMU_NU_H_SEEN #define BNL_CC1PPI0_EVT_1DWNMU_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1pi0_Evt_1DWNmu_nu : public Measurement1D { public: BNL_CC1pi0_Evt_1DWNmu_nu(nuiskey samplekey); virtual ~BNL_CC1pi0_Evt_1DWNmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.cxx b/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.cxx index 50b6682..b26108b 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.cxx +++ b/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1pi0_Evt_1DWNpi_nu.h" //******************************************************************** BNL_CC1pi0_Evt_1DWNpi_nu::BNL_CC1pi0_Evt_1DWNpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1pi0 Event Rate 1D W(N pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1p#pi^{0}"); fSettings.SetXTitle("W(N#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pi0_on_n/BNL_CC1pi0_WNpi_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1pi0_Evt_1DWNpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(111)->fP; double hadMass = (Pp+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1pi0_Evt_1DWNpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.h b/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.h index 450ad50..3f07a1c 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.h +++ b/src/BNL/BNL_CC1pi0_Evt_1DWNpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPI0_EVT_1DWNPI_NU_H_SEEN #define BNL_CC1PPI0_EVT_1DWNPI_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1pi0_Evt_1DWNpi_nu : public Measurement1D { public: BNL_CC1pi0_Evt_1DWNpi_nu(nuiskey samplekey); virtual ~BNL_CC1pi0_Evt_1DWNpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.cxx b/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.cxx index a586558..2f9bdee 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.cxx +++ b/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1pi0_Evt_1DWmupi_nu.h" //******************************************************************** BNL_CC1pi0_Evt_1DWmupi_nu::BNL_CC1pi0_Evt_1DWmupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1pi0 Event Rate 1D W(mu pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1p#pi^{0}"); fSettings.SetXTitle("W(#mu#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pi0_on_n/BNL_CC1pi0_Wmupi_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1pi0_Evt_1DWmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(111)->fP; double hadMass = (Pmu+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1pi0_Evt_1DWmupi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 111, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.h b/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.h index eaab58a..48d9484 100644 --- a/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.h +++ b/src/BNL/BNL_CC1pi0_Evt_1DWmupi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPI0_EVT_1DWMUPI_NU_H_SEEN #define BNL_CC1PPI0_EVT_1DWMUPI_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1pi0_Evt_1DWmupi_nu : public Measurement1D { public: BNL_CC1pi0_Evt_1DWmupi_nu(nuiskey samplekey); virtual ~BNL_CC1pi0_Evt_1DWmupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx index 30330cf..d267027 100644 --- a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,107 +1,107 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1pi0_XSec_1DEnu_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 7 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1pi0_XSec_1DEnu_nu::BNL_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1pi0_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.SetS("norm_error", "0.15"); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BNL_CC1pi0_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); // User can specifiy to use uncorrected data UseCorrectedData = !fSettings.Found("name", "Uncorr"); // Now read in different data depending on what the user has specified std::string DataLocation = GeneralUtils::GetTopLevelDir() + "/data/BNL/CC1pi0_on_n/"; // If we're using corrected data if (UseCorrectedData) { DataLocation += "BNL_CC1pi0_on_n_1986_corr.txt"; // If we're using raw uncorrected data } else { DataLocation += "BNL_CC1pi0_on_n_1986.txt"; } fSettings.SetDataInput(DataLocation); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/proton fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); } diff --git a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.h b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.h index ede614d..7ad2e75 100644 --- a/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CC1pi0_XSec_1DEnu_nu.h @@ -1,47 +1,47 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PI0_XSEC_1DENU_NU_H_SEEN #define BNL_CC1PI0_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 7 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1pi0_XSec_1DEnu_nu : public Measurement1D { public: BNL_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CC1pi0_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool UseCorrectedData; }; #endif diff --git a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx index b303d44..5037cdf 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,114 +1,114 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 3 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 // Figure 8 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 #include "BNL_CC1ppip_Evt_1DQ2_nu.h" //******************************************************************** BNL_CC1ppip_Evt_1DQ2_nu::BNL_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1ppip_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.5, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BNL #nu_mu CC1n#pi^{+}"); fSettings.DefineAllowedSpecies("numu"); // Hadronic Cut Info HadCut = fSettings.Found("name", "W14Cut") ? 1.4 : 10.0; if (HadCut == 1.4) { fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1pip_on_p_noEvents_q2_w14_enu05to6_firstQ2rem.txt" ); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1pip_on_p_noEvents_q2_noWcut_HighQ2Gone.txt"); fSettings.SetEnuRange(0.0, 10.0); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 and no W cut. // This should be specified by user in "type" field // Reverts to 10 GeV (essentially no W cut!) if (hadMass < HadCut * 1000.) { 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); } diff --git a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.h b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.h index d8d435e..8f6951c 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.h +++ b/src/BNL/BNL_CC1ppip_Evt_1DQ2_nu.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_EVT_1DQ2_NU_H_SEEN #define BNL_CC1PPIP_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 3 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 // Figure 8 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 class BNL_CC1ppip_Evt_1DQ2_nu : public Measurement1D { public: BNL_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double HadCut; // Hadronic mass cut, specified by user (W < 1.4 or no W cut) }; #endif diff --git a/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.cxx index 3bc4370..764239a 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1ppip_Evt_1DWNmu_nu.h" //******************************************************************** BNL_CC1ppip_Evt_1DWNmu_nu::BNL_CC1ppip_Evt_1DWNmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1ppip Event Rate 1D W(N mu) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("W(N#mu) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1ppip_WNmu_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1ppip_Evt_1DWNmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double hadMass = (Pmu+Pp).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1ppip_Evt_1DWNmu_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.h b/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.h index c755487..7962f99 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.h +++ b/src/BNL/BNL_CC1ppip_Evt_1DWNmu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_EVT_1DWNMU_NU_H_SEEN #define BNL_CC1PPIP_EVT_1DWNMU_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1ppip_Evt_1DWNmu_nu : public Measurement1D { public: BNL_CC1ppip_Evt_1DWNmu_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_Evt_1DWNmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.cxx index 64daf97..8a2bcc1 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1ppip_Evt_1DWNpi_nu.h" //******************************************************************** BNL_CC1ppip_Evt_1DWNpi_nu::BNL_CC1ppip_Evt_1DWNpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1ppip Event Rate 1D W(N pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("W(N#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1ppip_WNpi_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1ppip_Evt_1DWNpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pp+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1ppip_Evt_1DWNpi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.h b/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.h index 5626c03..01635f1 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.h +++ b/src/BNL/BNL_CC1ppip_Evt_1DWNpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_EVT_1DWNPI_NU_H_SEEN #define BNL_CC1PPIP_EVT_1DWNPI_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1ppip_Evt_1DWNpi_nu : public Measurement1D { public: BNL_CC1ppip_Evt_1DWNpi_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_Evt_1DWNpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.cxx index bf04364..81e1942 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1ppip_Evt_1DWmupi_nu.h" //******************************************************************** BNL_CC1ppip_Evt_1DWmupi_nu::BNL_CC1ppip_Evt_1DWmupi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CC1ppip Event Rate 1D W(mu pi) nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetTitle("BNL #nu_mu CC1p#pi^{+}"); fSettings.SetXTitle("W(#mu#pi) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("D,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1ppip_Wmupi_per_0.05GeV.txt" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1ppip_Evt_1DWmupi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(211) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double hadMass = (Pmu+Ppip).Mag()/1000.; fXVar = hadMass; return; }; bool BNL_CC1ppip_Evt_1DWmupi_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.h b/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.h index 0324df4..61083f8 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.h +++ b/src/BNL/BNL_CC1ppip_Evt_1DWmupi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_EVT_1DWMUPI_NU_H_SEEN #define BNL_CC1PPIP_EVT_1DWMUPI_NU_H_SEEN #include "Measurement1D.h" class BNL_CC1ppip_Evt_1DWmupi_nu : public Measurement1D { public: BNL_CC1ppip_Evt_1DWmupi_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_Evt_1DWmupi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx index 7ae0582..7baf744 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx @@ -1,100 +1,100 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1ppip_Evt_1DcosthAdler_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 12 and related // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1ppip_Evt_1DcosthAdler_nu::BNL_CC1ppip_Evt_1DcosthAdler_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1ppip_Evt_1DcosthAdler_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{Adler}"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.5, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL_CC1ppip_Evt_1DcosthAdler_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1ppip_W14_cosThAdler.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor =GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1ppip_Evt_1DcosthAdler_nu::FillEventVariables(FitEvent *event) { fXVar = -999.99; 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); if (hadMass > 1400) return; // Get Adler cos theta double cosThAdler = FitUtils::CosThAdler(Pnu, Pmu, Ppip, Pp); fXVar = cosThAdler; }; bool BNL_CC1ppip_Evt_1DcosthAdler_nu::isSignal(FitEvent *event) { return SignalDef::isCC1pi3Prong(event, 14, 211, 2212,EnuMin,EnuMax); } diff --git a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.h b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.h index 8db8ed7..07aaa33 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.h +++ b/src/BNL/BNL_CC1ppip_Evt_1DcosthAdler_nu.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_EVT_1DCOSTHADLER_NU_H_SEEN #define BNL_CC1PPIP_EVT_1DCOSTHADLER_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 12 and related // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1ppip_Evt_1DcosthAdler_nu : public Measurement1D { public: BNL_CC1ppip_Evt_1DcosthAdler_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_Evt_1DcosthAdler_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx index dd39272..9e490f2 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx +++ b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.cxx @@ -1,123 +1,123 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1ppip_Evt_1Dphi_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 12 and related // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1ppip_Evt_1Dphi_nu::BNL_CC1ppip_Evt_1Dphi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1ppip_Evt_1Dphi_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#phi_{Adler}"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL_CC1ppip_Evt_1Dphi_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CC1pip_on_p/BNL_CC1ppip_W14_phiAdler.csv" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor =GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC1ppip_Evt_1Dphi_nu::FillEventVariables(FitEvent *event) { fXVar = -999.99; 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); if (hadMass > 1400) return; // Get phi Adler double phi = FitUtils::PhiAdler(Pnu, Pmu, Ppip, Pp); fXVar = phi; }; 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, GetFluxHistogram()); PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram()); fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); return; } */ diff --git a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.h b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.h index d9b077f..0bd9554 100644 --- a/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.h +++ b/src/BNL/BNL_CC1ppip_Evt_1Dphi_nu.h @@ -1,49 +1,49 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_EVT_1DPHI_NU_H_SEEN #define BNL_CC1PPIP_EVT_1DPHI_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 12 and related // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1ppip_Evt_1Dphi_nu : public Measurement1D { public: BNL_CC1ppip_Evt_1Dphi_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_Evt_1Dphi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: TRandom3 rand; }; #endif diff --git a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx index cf78d78..14aa5d9 100644 --- a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,128 +1,128 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC1ppip_XSec_1DEnu_nu.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 7 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 //******************************************************************** BNL_CC1ppip_XSec_1DEnu_nu::BNL_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC1ppip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma (cm^{2}/proton)"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 6.0); fSettings.SetS("norm_error", "0.15"); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BNL_CC1ppip_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); // User can specifiy to use uncorrected data UseCorrectedData = !fSettings.Found("name", "Uncorr"); // User can specify 1.4 or no W cut if (fSettings.Found("name", "W14Cut")) wTrueCut = 1.4; else wTrueCut = 10.0; // Now read in different data depending on what the user has specified std::string DataLocation = GeneralUtils::GetTopLevelDir() + "/data/BNL/CC1pip_on_p/"; // If we're using corrected data if (UseCorrectedData) { if (wTrueCut == 1.4) { DataLocation += "BNL_CC1pip_on_p_W14_1986_corr.txt"; fSettings.SetEnuRange(0.5, 3.0); } else { DataLocation += "BNL_CC1pip_on_p_1986_corr.txt"; fSettings.SetEnuRange(0.4, 4.0); } // If we're using raw uncorrected data } else { if (wTrueCut == 1.4) { DataLocation += "BNL_CC1pip_on_p_W14_1986.txt"; fSettings.SetEnuRange(0.6, 3.0); } else { DataLocation += "BNL_CC1pip_on_p_1986.txt"; fSettings.SetEnuRange(0.5, 14.0); } } fSettings.SetDataInput(DataLocation); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/proton fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / ((fNEvents + 0.)) * 2. / 1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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; if (hadMass/1000. < wTrueCut) { 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); } diff --git a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.h b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.h index a69c357..d8e2916 100644 --- a/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CC1ppip_XSec_1DEnu_nu.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC1PPIP_XSEC_1DENU_NU_H_SEEN #define BNL_CC1PPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" // T. Kitagaki et al. "Charged-current exclusive pion production in neutrino-deuterium interactions" // Physical Review D, Volume 34, Number 9, 1 Nov 1986 // Figure 7 // // Also see // N. J. Baker et al. "Study of the isospin structure of single-pion production in charged-current neutrino interactions" // Physical Review D, Volume 23, Number 11, 1 June 1981 // // K. Furuno et al. NuInt02 proceedings, (supposedly published in Nucl. Phys. B but I never found it), Retreieved from KEK preprints. // KEK Preprint 2003-48, RCNS-03-01, September 2003 class BNL_CC1ppip_XSec_1DEnu_nu : public Measurement1D { public: BNL_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CC1ppip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double wTrueCut; bool UseCorrectedData; }; #endif diff --git a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.cxx b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.cxx index bdf0ce8..ff10007 100644 --- a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.cxx +++ b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.cxx @@ -1,82 +1,82 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.h" //******************************************************************** BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu::BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("W(#pi^{+}#pi^{-}) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 15.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CCmultipi/BNL_CC1pim1pip1p_Wpimpip_per_0.05GeV.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/double(fNEvents) * 2.0 / 1.0 ; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(-211) == 0) return; TLorentzVector Ppim = event->GetHMFSParticle(-211)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; fXVar = (Ppim+Ppip).Mag()/1000; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.h b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.h index b43b41e..5dc482a 100644 --- a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.h +++ b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC2PI_1PIM1PIP_EVT_1DWPIPPIM_NU_H_SEEN #define BNL_CC2PI_1PIM1PIP_EVT_1DWPIPPIM_NU_H_SEEN #include "Measurement1D.h" class BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu : public Measurement1D { public: BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu(nuiskey samplekey); virtual ~BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.cxx b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.cxx index d3b1a79..d651fe5 100644 --- a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.cxx +++ b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.cxx @@ -1,83 +1,83 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.h" //******************************************************************** BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu::BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("W(#pi^{+}#pi^{-}) (GeV)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG","EVT/SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 15.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CCmultipi/BNL_CC1pim1pip1p_Wppip_per_0.05GeV.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")/double(fNEvents) * 2.0 / 1.0 ; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumFSParticle(2212) == 0) return; TLorentzVector Ppr = event->GetHMFSParticle(2212)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; fXVar = (Ppr+Ppip).Mag()/1000; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.h b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.h index dddca7b..ae000cb 100644 --- a/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.h +++ b/src/BNL/BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC2PI_1PIM1PIP_EVT_1DWPIPPR_NU_H_SEEN #define BNL_CC2PI_1PIM1PIP_EVT_1DWPIPPR_NU_H_SEEN #include "Measurement1D.h" class BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu : public Measurement1D { public: BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu(nuiskey samplekey); virtual ~BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx index 93b447f..ddace73 100644 --- a/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx @@ -1,78 +1,78 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.h" //******************************************************************** BNL_CC2pi_1pim1pip_XSec_1DEnu_nu::BNL_CC2pi_1pim1pip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC2pi_1pim1pip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 15.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL #nu_mu CC2#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CCmultipi/BNL_CC1pim1pip1p_xsec.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents) * 2.0 / 1.0 ; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); + this->fDataHist = PlotUtils::RestrictHistRange(this->fDataHist, 0, 6); ScaleData(1E-38); + SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC2pi_1pim1pip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; this->fXVar = Pnu.E()/1000.; return; } // Signal asks for 1pi-, 1pi+, 1mu-, 1p bool BNL_CC2pi_1pim1pip_XSec_1DEnu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } - - diff --git a/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.h b/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.h index 01c14d5..3a31dc7 100644 --- a/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC2PI_1PIM1PIP_XSEC_1DENU_NU_H_SEEN #define BNL_CC2PI_1PIM1PIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class BNL_CC2pi_1pim1pip_XSec_1DEnu_nu : public Measurement1D { public: BNL_CC2pi_1pim1pip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CC2pi_1pim1pip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.cxx index c7d467b..73834cc 100644 --- a/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.cxx @@ -1,78 +1,80 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.h" //******************************************************************** BNL_CC3pi_1pim2pip_XSec_1DEnu_nu::BNL_CC3pi_1pim2pip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC3pi_1pim2pip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 15.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL #nu_mu CC3#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CCmultipi/BNL_CC2pip1pim1p_xsec.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents) * 2.0 / 1.0 ; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); + this->fDataHist = PlotUtils::RestrictHistRange(this->fDataHist, 0, 6); + SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC3pi_1pim2pip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; this->fXVar = Pnu.E()/1000.; return; } // Signal asks for 1pi-, 2pi+, 1mu-, 1p bool BNL_CC3pi_1pim2pip_XSec_1DEnu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.h b/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.h index ed04a5a..2c6a6a0 100644 --- a/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC3PI_1PIM2PIP_XSEC_1DENU_NU_H_SEEN #define BNL_CC3PI_1PIM2PIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class BNL_CC3pi_1pim2pip_XSec_1DEnu_nu : public Measurement1D { public: BNL_CC3pi_1pim2pip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CC3pi_1pim2pip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.cxx index fbc5f89..c11c8fa 100644 --- a/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.cxx @@ -1,78 +1,80 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.h" //******************************************************************** BNL_CC4pi_2pim2pip_XSec_1DEnu_nu::BNL_CC4pi_2pim2pip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CC4pi_2pim2pip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX,FREE,SHAPE/DIAG"); fSettings.SetEnuRange(0.0, 15.0); fSettings.DefineAllowedTargets("D,H"); // CCQELike plot information fSettings.SetTitle("BNL #nu_mu CC4#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/BNL/CCmultipi/BNL_CC2pim2pip1p_xsec.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents) * 2.0 / 1.0 ; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-38); + this->fDataHist = PlotUtils::RestrictHistRange(this->fDataHist, 0, 6); + SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void BNL_CC4pi_2pim2pip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { TLorentzVector Pnu = event->GetNeutrinoIn()->fP; this->fXVar = Pnu.E()/1000.; return; } // Signal asks for 2pi-, 2pi+, 1mu-, 1p bool BNL_CC4pi_2pim2pip_XSec_1DEnu_nu::isSignal(FitEvent *event) { int pdgs[] = {13, 211, 211, -211, -211, 2212}; return SignalDef::isCCWithFS(event, 14, pdgs, EnuMin, EnuMax); } diff --git a/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.h b/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.h index 366a666..79e60cd 100644 --- a/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CC4PI_2PIM2PIP_XSEC_1DENU_NU_H_SEEN #define BNL_CC4PI_2PIM2PIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class BNL_CC4pi_2pim2pip_XSec_1DEnu_nu : public Measurement1D { public: BNL_CC4pi_2pim2pip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CC4pi_2pim2pip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx index 6e91ddb..6f9c32b 100755 --- a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx +++ b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.cxx @@ -1,148 +1,148 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CCQE_Evt_1DQ2_nu.h" //******************************************************************** BNL_CCQE_Evt_1DQ2_nu::BNL_CCQE_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL_CCQE_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CCQE} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/Q2CORR/MASK"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BNL #nu_mu CCQE"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "BNL/BNL_Data_PRD23_2499.root;BNL_1DQ2_Data"); // is Q2 Correction applied applyQ2correction = fSettings.Found("type", "Q2CORR"); if (applyQ2correction) { fSettings.SetS("q2correction_file", FitPar::GetDataBase() + "ANL/ANL_CCQE_Data_PRL31_844.root"); fSettings.SetS("q2correction_hist", "ANL_1DQ2_Correction"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = 1.0; // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Correction Histogram if (applyQ2correction) { // Correction Hist CorrectionHist = PlotUtils::GetTH1DFromFile( fSettings.GetS("q2correction_file"), fSettings.GetS("q2correction_hist") ); SetAutoProcessTH1(CorrectionHist, kCMD_Write); // Make uncorrected MC hist fMCHist_NoCorr = (TH1D*) fDataHist->Clone(); fMCHist_NoCorr->Reset(); fMCHist_NoCorr->SetNameTitle( (fName + "_NOCORR").c_str(), (fName + "_NOCORR").c_str()); SetAutoProcessTH1(fMCHist_NoCorr); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } //******************************************************************** void BNL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent * event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; // Fill histogram with reconstructed Q2 Distribution fXVar = -999.9; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); fXVar = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0., true); GetQ2Box()->fQ2 = fXVar; return; }; //******************************************************************** bool BNL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent * event) { //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; // Q2 cut if (GetQ2Box()->fQ2 <= 0) return false; return true; }; //******************************************************************** void BNL_CCQE_Evt_1DQ2_nu::FillHistograms() { //******************************************************************** if (applyQ2correction) { fMCHist_NoCorr->Fill( GetQ2Box()->fQ2, Weight); if (GetQ2Box()->fQ2 < CorrectionHist->GetXaxis()->GetXmax() && GetQ2Box()->fQ2 > CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(GetQ2Box()->fQ2); } Measurement1D::FillHistograms(); } //******************************************************************** void BNL_CCQE_Evt_1DQ2_nu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); // Flux unfold our extra histogram if (applyQ2correction) { if (fMCHist_NoCorr->Integral()) { fMCHist_NoCorr->Scale(fDataHist->Integral() / fMCHist_NoCorr->Integral()); } } } diff --git a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.h b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.h index acfc74f..8b37a3b 100755 --- a/src/BNL/BNL_CCQE_Evt_1DQ2_nu.h +++ b/src/BNL/BNL_CCQE_Evt_1DQ2_nu.h @@ -1,64 +1,64 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CCQE_Evt_1DQ2_NU_H_SEEN #define BNL_CCQE_Evt_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "CustomVariableBoxes.h" //******************************************************************** class BNL_CCQE_Evt_1DQ2_nu : public Measurement1D { //******************************************************************** public: BNL_CCQE_Evt_1DQ2_nu(nuiskey samplekey); virtual ~BNL_CCQE_Evt_1DQ2_nu() {}; /// \brief Get Q2 assuming QE void FillEventVariables(FitEvent *event); /// \brief Get True CCQE bool isSignal(FitEvent *event); /// \brief Fill main histograms and correction histograms void FillHistograms(); /// \brief scale the MC Hist and correction histograms void ScaleEvents(); /// \brief Use Q2 Box to save correction info inline Q2VariableBox1D* GetQ2Box(){ return static_cast(GetBox()); }; /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox* CreateBox(){ return new Q2VariableBox1D(); }; private: bool applyQ2correction; ///< Flag of whether deut correction applied TH1D* CorrectionHist; ///< Correction factor TH1D* fMCHist_NoCorr; ///< Uncorrected fMCHist double ThetaMu; double q2qe; }; #endif diff --git a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx index fad5e99..e0af822 100644 --- a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx +++ b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.cxx @@ -1,147 +1,147 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BNL_CCQE_XSec_1DEnu_nu.h" //******************************************************************** BNL_CCQE_XSec_1DEnu_nu::BNL_CCQE_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "BNL CCQ2 XSec 1DEnu nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); - fSettings.SetYTitle("#sigma(#E_{#nu}) (cm^{2}/neutron)"); + fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/neutron)"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/Q2CORR/MASK"); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("BNL #nu_mu CCQE"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "BNL/BNL_Data_PRD23_2499.root;BNL_1DEnu_Data"); // is Q2 Correction applied applyQ2correction = fSettings.Found("type", "Q2CORR"); if (applyQ2correction) { fSettings.SetS("q2correction_file", FitPar::GetDataBase() + "/ANL/ANL_CCQE_Data_PRL31_844.root"); fSettings.SetS("q2correction_hist", "ANL_1DQ2_Correction"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = (GetEventHistogram()->Integral("width") * (2.0 / 1.0) * 1E-38 / (fNEvents + 0.)); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Correction Histogram if (applyQ2correction) { // Correction Hist CorrectionHist = PlotUtils::GetTH1DFromFile( fSettings.GetS("q2correction_file"), fSettings.GetS("q2correction_hist") ); SetAutoProcessTH1(CorrectionHist, kCMD_Write); // Make uncorrected MC hist fMCHist_NoCorr = (TH1D*) fDataHist->Clone(); fMCHist_NoCorr->Reset(); fMCHist_NoCorr->SetNameTitle( (fName + "_NOCORR").c_str(), (fName + "_NOCORR").c_str()); SetAutoProcessTH1(fMCHist_NoCorr); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } //******************************************************************** void BNL_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; // Get Q2 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; GetQ2Box()->fQ2 = q2qe; return; }; //******************************************************************** bool BNL_CCQE_XSec_1DEnu_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCCQE(event, 14, EnuMin, EnuMax); }; //******************************************************************** void BNL_CCQE_XSec_1DEnu_nu::FillHistograms() { //******************************************************************** if (applyQ2correction) { fMCHist_NoCorr->Fill( GetQ2Box()->fQ2, Weight); if (GetQ2Box()->fQ2 < CorrectionHist->GetXaxis()->GetXmax() && GetQ2Box()->fQ2 > CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(GetQ2Box()->fQ2); } Measurement1D::FillHistograms(); } //******************************************************************** void BNL_CCQE_XSec_1DEnu_nu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); // Flux unfold our extra histogram if (applyQ2correction) { PlotUtils::FluxUnfoldedScaling(fMCHist_NoCorr, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); } } diff --git a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.h b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.h index 6adb6ea..645dba0 100644 --- a/src/BNL/BNL_CCQE_XSec_1DEnu_nu.h +++ b/src/BNL/BNL_CCQE_XSec_1DEnu_nu.h @@ -1,58 +1,58 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BNL_CCQE_XSEC_1DENU_NU_H_SEEN #define BNL_CCQE_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" #include "CustomVariableBoxes.h" //******************************************************************** class BNL_CCQE_XSec_1DEnu_nu : public Measurement1D { //******************************************************************** public: BNL_CCQE_XSec_1DEnu_nu(nuiskey samplekey); virtual ~BNL_CCQE_XSec_1DEnu_nu() {}; /// \brief Get Q2 assuming QE scattering void FillEventVariables(FitEvent *event); /// \brief Selection only true CCQE bool isSignal(FitEvent *event); /// \brief fill normal MC and corrected MC void FillHistograms(); /// \brief scale normal MC and corrected MC void ScaleEvents(); /// \brief Use Q2 Box to save correction info inline Q2VariableBox1D* GetQ2Box(){ return static_cast(GetBox()); }; /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox* CreateBox(){ return new Q2VariableBox1D(); }; private: bool applyQ2correction; ///< Apply free nucleon to dueterium correction TH1D* CorrectionHist; ///< Histogram to interpolate free nucleon correction TH1D* fMCHist_NoCorr; ///< Uncorrected fMCHist }; #endif diff --git a/src/BNL/CMakeLists.txt b/src/BNL/CMakeLists.txt index 4045a5b..644e8a2 100644 --- a/src/BNL/CMakeLists.txt +++ b/src/BNL/CMakeLists.txt @@ -1,93 +1,93 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES BNL_CC1npip_Evt_1DQ2_nu.cxx BNL_CC1npip_XSec_1DEnu_nu.cxx BNL_CC1npip_Evt_1DWmupi_nu.cxx BNL_CC1npip_Evt_1DWNpi_nu.cxx BNL_CC1npip_Evt_1DWNmu_nu.cxx BNL_CC1pi0_Evt_1DQ2_nu.cxx BNL_CC1pi0_XSec_1DEnu_nu.cxx BNL_CC1pi0_Evt_1DWmupi_nu.cxx BNL_CC1pi0_Evt_1DWNpi_nu.cxx BNL_CC1pi0_Evt_1DWNmu_nu.cxx BNL_CC1ppip_Evt_1DQ2_nu.cxx BNL_CC1ppip_XSec_1DEnu_nu.cxx BNL_CC1ppip_Evt_1DWmupi_nu.cxx BNL_CC1ppip_Evt_1DWNpi_nu.cxx BNL_CC1ppip_Evt_1DWNmu_nu.cxx BNL_CCQE_Evt_1DQ2_nu.cxx BNL_CCQE_XSec_1DEnu_nu.cxx BNL_CC1ppip_Evt_1DcosthAdler_nu.cxx BNL_CC1ppip_Evt_1Dphi_nu.cxx BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.cxx BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.cxx BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.cxx BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.cxx ) set(HEADERFILES BNL_CC1npip_Evt_1DQ2_nu.h BNL_CC1npip_XSec_1DEnu_nu.h BNL_CC1npip_Evt_1DWmupi_nu.h BNL_CC1npip_Evt_1DWNpi_nu.h BNL_CC1npip_Evt_1DWNmu_nu.h BNL_CC1pi0_Evt_1DQ2_nu.h BNL_CC1pi0_XSec_1DEnu_nu.h BNL_CC1pi0_Evt_1DWmupi_nu.h BNL_CC1pi0_Evt_1DWNpi_nu.h BNL_CC1pi0_Evt_1DWNmu_nu.h BNL_CC1ppip_Evt_1DQ2_nu.h BNL_CC1ppip_XSec_1DEnu_nu.h BNL_CC1ppip_Evt_1DWmupi_nu.h BNL_CC1ppip_Evt_1DWNpi_nu.h BNL_CC1ppip_Evt_1DWNmu_nu.h BNL_CCQE_Evt_1DQ2_nu.h BNL_CCQE_XSec_1DEnu_nu.h BNL_CC1ppip_Evt_1DcosthAdler_nu.h BNL_CC1ppip_Evt_1Dphi_nu.h BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.h BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.h BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.h BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.h BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.h ) set(LIBNAME expBNL) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() 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/BNL/SAMPLEREADME b/src/BNL/SAMPLEREADME deleted file mode 100644 index be822fc..0000000 --- a/src/BNL/SAMPLEREADME +++ /dev/null @@ -1,2 +0,0 @@ -./BNL_CCQE_Evt_1DQ2_nu.cxx -./BNL_CCQE_XSec_1DEnu_nu.cxx diff --git a/src/Config/CMakeLists.txt b/src/Config/CMakeLists.txt index 64464af..34a0c37 100644 --- a/src/Config/CMakeLists.txt +++ b/src/Config/CMakeLists.txt @@ -1,52 +1,52 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(HEADERFILES NuisConfig.h NuisKey.h ) set(IMPLFILES NuisConfig.cxx NuisKey.cxx ) set(LIBNAME Config) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Config) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Config/NuisConfig.cxx b/src/Config/NuisConfig.cxx index fbda8de..ab69cb0 100644 --- a/src/Config/NuisConfig.cxx +++ b/src/Config/NuisConfig.cxx @@ -1,817 +1,817 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "NuisConfig.h" #include "FitLogger.h" #include "GeneralUtils.h" #include "TXMLEngine.h" namespace Config { nuisconfig &Get() { return nuisconfig::GetConfig(); }; std::string GetPar(std::string const &name) { return Get().GetConfig(name); } bool HasPar(std::string const &name) { return Get().HasConfig(name); } std::string GetParS(std::string const &name) { return Get().GetConfigS(name); } int GetParI(std::string const &name) { return Get().GetConfigI(name); } bool GetParB(std::string const &name) { return Get().GetConfigB(name); } float GetParF(std::string const &name) { return Get().GetConfigF(name); } double GetParD(std::string const &name) { return Get().GetConfigD(name); } void SetPar(std::string const &name, std::string const &val) { Get().SetConfig(name, val); } void SetPar(std::string const &name, char const *val) { Get().SetConfig(name, val); } void SetPar(std::string const &name, bool val) { Get().SetConfig(name, val); } void SetPar(std::string const &name, int val) { Get().SetConfig(name, val); } void SetPar(std::string const &name, float val) { Get().SetConfig(name, val); } void SetPar(std::string const &name, double val) { Get().SetConfig(name, val); } } namespace FitPar { std::string GetDataBase() { return GeneralUtils::GetTopLevelDir() + "/data/"; }; nuisconfig &Config() { return Config::Get(); }; } nuisconfig *nuisconfig::m_nuisconfigInstance = NULL; nuisconfig &nuisconfig::GetConfig(void) { if (!m_nuisconfigInstance) m_nuisconfigInstance = new nuisconfig; return *m_nuisconfigInstance; }; // Main Class Definition nuisconfig::nuisconfig() { // Load default Parameters std::string filename = (GeneralUtils::GetTopLevelDir() + "/parameters/config.xml"); std::cout << "[ NUISANCE ]: Loading DEFAULT settings from : " << filename << std::endl; // Create XML Engine fXML = new TXMLEngine; fXML->SetSkipComments(true); // Load in documents fXMLDocs.push_back(fXML->ParseFile(filename.c_str(), 1000000)); if (!fXMLDocs[0]) { NUIS_ABORT("Cannot Read Parameters File!"); } // Setup Main XML Node to be the first file read fMainNode = fXML->DocGetRootElement(fXMLDocs[0]); // Print result std::cout << "[ NUISANCE ]: Finished nuisconfig." << std::endl; } nuisconfig::~nuisconfig() { // Should really delete XML objects here but we don't } void nuisconfig::LoadSettings(std::string const &filename, std::string const &state) { // Open file and see if its XML std::cout << "[ NUISANCE ]: Trying to parse file : " << filename; // StopTalking(); XMLDocPointer_t readdoc = fXML->ParseFile(filename.c_str(), 1000000); // StartTalking(); // If it is parse it as a nice XML config file if (readdoc) { std::cout << " -> Found XML file." << std::endl; LoadXMLSettings(filename, state); // Otherwise its an old simple card file } else { std::cout << " -> Assuming its a simple card file." << std::endl; LoadCardSettings(filename, state); } } void nuisconfig::LoadXMLSettings(std::string const &filename, std::string const &state) { std::cout << "[ NUISANCE ]: Loading XML settings from : " << filename << std::endl; // Add new file to xml docs list fXMLDocs.push_back(fXML->ParseFile(filename.c_str(), 1000000)); if (!fXMLDocs.back()) { NUIS_ABORT("Failed to read: " << filename); } // Loop over children and add XMLNodePointer_t child = fXML->GetChild(fXML->DocGetRootElement(fXMLDocs.back())); // // Here we manually load all the children from the card file into our root // node if (!child) { NUIS_ABORT("CANNOT Find child inside settings file!"); } while (child) { // SPECIAL CONFIG CASE // If its a config node, then remove previous attributes, overriding old // value if (!std::string(fXML->GetNodeName(child)).compare("config")) { // Loop over attribues XMLAttrPointer_t attr1 = fXML->GetFirstAttr(child); while (attr1) { // If a valid attribute name is given then compare if (!GetConfigS(fXML->GetAttrName(attr1)).empty()) { // Get full list of present configs std::vector confignodes = GetNodes("config"); // Loop over present configs and compare for (size_t i = 0; i < confignodes.size(); i++) { // If we already have this config, free the old attribute if (fXML->HasAttr(confignodes[i], fXML->GetAttrName(attr1))) { fXML->FreeAttr(confignodes[i], fXML->GetAttrName(attr1)); break; } } } // Move onto next config attribute attr1 = fXML->GetNextAttr(attr1); } } TString nodeStr; fXML->SaveSingleNode(child, &nodeStr); XMLNodePointer_t copyNode = fXML->ReadSingleNode(nodeStr.Data()); // std::cout << "copying node..." << std::endl; // PrintXML(copyNode); // Add this child to the main config list fXML->AddChild(fMainNode, copyNode); // std::cout << "Done, was it added?" << std::endl; // PrintXML(fMainNode); // Get Next Child child = fXML->GetNext(child); } std::cout << "[ NUISANCE ]: Finished loading XML settings" << std::endl; } void nuisconfig::LoadCardSettings(std::string const &filename, std::string const &state) { std::cout << "[ NUISANCE ]: Loading simple config from : " << filename << std::endl; // Build XML Config from the card file by parsing each line std::vector cardlines = GeneralUtils::ParseFileToStr(filename, "\n"); int linecount = 0; // Loop over all input lines for (std::vector::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; // Parse whitespace std::vector strvct = GeneralUtils::ParseToStr(line, " "); if (strvct.empty()) continue; // Get Identifier std::string id = strvct[0]; // Build backwards compatible xml configs // Sample structure if (!id.compare("sample")) { CreateSampleNodeFromLine(line); } // Any parameter structure if (id.find("_parameter") != std::string::npos) { CreateParameterNodeFromLine(line); } // Any covar structure if (!id.compare("covar") || !id.compare("pull") || !id.compare("throw")) { CreatePullNodeFromLine(line); } // Any config structure if (!id.compare("config")) { CreateOldConfigNodeFromLine(line); } } std::cout << "[ NUISANCE ]: Finished loading simple config" << std::endl; } XMLNodePointer_t nuisconfig::CreateSampleNodeFromLine(std::string const &line) { // Create new node entry XMLNodePointer_t samplenode = CreateNode("sample"); // Parse line std::vector strvct = GeneralUtils::ParseToStr(line, " "); // Add line elements to the node // name input type norm if (strvct.size() > 1) Set(samplenode, "name", strvct[1]); if (strvct.size() > 2) Set(samplenode, "input", strvct[2]); if (strvct.size() > 3) Set(samplenode, "type", strvct[3]); if (strvct.size() > 4) Set(samplenode, "norm", strvct[4]); return samplenode; } XMLNodePointer_t nuisconfig::CreateParameterNodeFromLine( std::string const &line) { // Create new node entry XMLNodePointer_t parnode = CreateNode("parameter"); // Parse line std::vector strvct = GeneralUtils::ParseToStr(line, " "); // Add line elements to the node // type name nominal [low] [high] [step] state if (strvct.size() > 0) Set(parnode, "type", strvct[0]); if (strvct.size() > 1) Set(parnode, "name", strvct[1]); if (strvct.size() > 2) Set(parnode, "nominal", strvct[2]); // If free structure if (strvct.size() == 7) { Set(parnode, "low", strvct[3]); Set(parnode, "high", strvct[4]); Set(parnode, "step", strvct[5]); Set(parnode, "state", strvct[6]); // Fixed param structure } else if (strvct.size() == 3) { Set(parnode, "state", "FIX"); } else if (strvct.size() == 4) { Set(parnode, "state", strvct[3]); } return parnode; } XMLNodePointer_t nuisconfig::CreatePullNodeFromLine(std::string const &line) { // Create new node entry XMLNodePointer_t parnode = CreateNode("covar"); // Parse line std::vector strvct = GeneralUtils::ParseToStr(line, " "); // Add line elements to the node // name input type if (strvct.size() > 1) Set(parnode, "name", strvct[1]); if (strvct.size() > 2) Set(parnode, "input", strvct[2]); if (strvct.size() > 3) Set(parnode, "type", strvct[3]); return parnode; } XMLNodePointer_t nuisconfig::CreateOldConfigNodeFromLine( std::string const &line) { // Create new node entry XMLNodePointer_t confignode = CreateNode("config"); // Parse line std::vector strvct = GeneralUtils::ParseToStr(line, " "); // Add line elements to the node // name value if (strvct.size() > 2) Set(confignode, strvct[1], strvct[2]); return confignode; } void nuisconfig::FinaliseSettings(std::string const &name) { std::cout << "[ NUISANCE ]: Finalising run settings" << std::endl; WriteSettings(name); // Save full config to file RemoveEmptyNodes(); RemoveIdenticalNodes(); std::cout << "[ NUISANCE ]: Finished finalising run settings" << std::endl; } void nuisconfig::WriteSettings(std::string const &outputname) { // Create a New XML Doc XMLDocPointer_t newxmldoc = fXML->NewDoc(); fXML->DocSetRootElement(newxmldoc, fMainNode); // Save document to file if (GetConfigB("SaveParsedXMLFile")) { fXML->SaveDoc(newxmldoc, outputname.c_str()); } } void nuisconfig::PrintXML(XMLNodePointer_t node, int indent) { if (!node) { node = fMainNode; } std::stringstream ss(""); for (int i = 0; i < indent; ++i) { ss << " "; } std::cout << ss.str() << "<" << fXML->GetNodeName(node) << std::flush; XMLAttrPointer_t attr = fXML->GetFirstAttr(node); while (attr) { std::cout << " " << fXML->GetAttrName(attr) << "=\"" << fXML->GetAttrValue(attr) << "\"" << std::flush; attr = fXML->GetNextAttr(attr); } if (!fXML->GetChild(node)) { std::cout << " />" << std::endl; return; } std::cout << " >" << std::endl; XMLNodePointer_t child = fXML->GetChild(node); while (child) { PrintXML(child, indent + 1); child = fXML->GetNext(child); } std::cout << ss.str() << "GetNodeName(node) << ">" << std::endl; } XMLNodePointer_t nuisconfig::CreateNode(std::string const &name) { return fXML->NewChild(fMainNode, 0, name.c_str()); } XMLNodePointer_t nuisconfig::CreateNode(XMLNodePointer_t node, std::string const &name) { return fXML->NewChild(node, 0, name.c_str()); } XMLNodePointer_t nuisconfig::GetNode(XMLNodePointer_t node, std::string const &type) { /// Loop over all children XMLNodePointer_t child = fXML->GetChild(node); while (child != 0) { /// Get nodes for given type (if type empty return all) if (std::string(fXML->GetNodeName(child)) == type.c_str() or type.empty()) { return child; } // Next child child = fXML->GetNext(child); } // Child not found return 0; } void nuisconfig::RemoveEmptyNodes() { std::vector nodelist = Config::Get().GetNodes(); for (size_t i = 0; i < nodelist.size(); i++) { if (fXML->IsEmptyNode(nodelist[i])) { std::cout << "Removing empty node: " << fXML->GetNodeName(nodelist[i]) << ", with child ?" << bool(fXML->GetChild(nodelist[i])) << std::endl; RemoveNode(nodelist[i]); } } } void nuisconfig::RemoveIdenticalNodes() { std::vector removed; // Loop over all nodes and check for identical nodes std::vector nodelist = Config::Get().GetNodes(); for (size_t i = 0; i < nodelist.size(); i++) { for (size_t j = 0; j < nodelist.size(); j++) { if (i == j) continue; XMLNodePointer_t node1 = nodelist[i]; XMLNodePointer_t node2 = nodelist[j]; // Check node already removed. if (std::find(removed.begin(), removed.end(), node1) != removed.end()) { continue; } if (std::find(removed.begin(), removed.end(), node2) != removed.end()) { continue; } // Check matching if (!MatchingNodes(node1, node2)) { continue; } if (std::string(fXML->GetNodeName(node1)).compare("config") and fXML->IsEmptyNode(node1)) { // Matching so print out warning std::cout << "Matching nodes given! Removing node1!" << std::endl << "Node 1" << std::endl; PrintNode(node1); std::cout << "Node 2" << std::endl; PrintNode(node2); } // Remove node removed.push_back(node1); } } // Now go through and remove this node. for (size_t i = 0; i < removed.size(); i++) { RemoveNode(removed.at(i)); } return; } void nuisconfig::RemoveNode(XMLNodePointer_t node) { - std::cout << "[ CONFIG ]: Removing node: "; - PrintNode(node); + // std::cout << "[ CONFIG ]: Removing node: "; + // PrintNode(node); fXML->FreeAllAttr(node); fXML->CleanNode(node); fXML->FreeNode(node); fXML->UnlinkNode(node); } void nuisconfig::PrintNode(XMLNodePointer_t node) { // Print Node Name std::cout << fXML->GetNodeName(node) << std::endl; // Loop and print all attributes XMLAttrPointer_t attr = fXML->GetFirstAttr(node); while (attr != 0) { std::cout << "\t\t|-> " << fXML->GetAttrName(attr) << " : " << fXML->GetAttrValue(attr) << std::endl; attr = fXML->GetNextAttr(attr); } } bool nuisconfig::MatchingNodes(XMLNodePointer_t node1, XMLNodePointer_t node2) { bool matching = true; XMLAttrPointer_t attr = fXML->GetFirstAttr(node1); while (attr != 0) { if (GetS(node2, fXML->GetAttrName(attr)) != fXML->GetAttrValue(attr)) matching = false; attr = fXML->GetNextAttr(attr); } return matching; } XMLNodePointer_t nuisconfig::GetNode(std::string const &type) { return GetNode(fMainNode, type); } std::vector nuisconfig::GetNodes(XMLNodePointer_t node, std::string const &type) { // Create new vector for nodes std::vector nodelist; /// Loop over all children XMLNodePointer_t child = fXML->GetChild(node); while (child != 0) { /// Get nodes for given type (if type empty return all) if (std::string(fXML->GetNodeName(child)) == type.c_str() or type.empty()) { nodelist.push_back(child); } // Next child child = fXML->GetNext(child); } // return list return nodelist; } std::vector nuisconfig::GetNodes(std::string const &type) { return GetNodes(fMainNode, type); } void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, std::string const &val) { // Remove and re-add attribute if (fXML->HasAttr(node, name.c_str())) { fXML->FreeAttr(node, name.c_str()); } fXML->NewAttr(node, 0, name.c_str(), val.c_str()); } void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, char const *val) { Set(node, name, std::string(val)); } void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, bool val) { Set(node, name, GeneralUtils::BoolToStr(val)); } void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, int val) { Set(node, name, GeneralUtils::IntToStr(val)); } void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, float val) { Set(node, name, GeneralUtils::DblToStr(val)); } void nuisconfig::Set(XMLNodePointer_t node, std::string const &name, double val) { Set(node, name, GeneralUtils::DblToStr(val)); } void nuisconfig::SetS(XMLNodePointer_t node, std::string const &name, std::string const &val) { Set(node, name, val); } void nuisconfig::SetB(XMLNodePointer_t node, std::string const &name, bool val) { Set(node, name, GeneralUtils::BoolToStr(val)); } void nuisconfig::SetI(XMLNodePointer_t node, std::string const &name, int val) { Set(node, name, GeneralUtils::IntToStr(val)); } void nuisconfig::SetF(XMLNodePointer_t node, std::string const &name, float val) { Set(node, name, GeneralUtils::DblToStr(val)); } void nuisconfig::SetD(XMLNodePointer_t node, std::string const &name, double val) { Set(node, name, GeneralUtils::DblToStr(val)); } bool nuisconfig::Has(XMLNodePointer_t node, std::string const &name) { // If node empty return empty if (node == 0) return false; // Search attributes XMLAttrPointer_t attr = fXML->GetFirstAttr(node); bool found = false; // Loop over all attributes while (attr != 0) { // Find value of correct name if (std::string(fXML->GetAttrName(attr)) == name.c_str()) { found = true; break; } // Next Attribute attr = fXML->GetNextAttr(attr); } return found; } std::string nuisconfig::Get(XMLNodePointer_t node, std::string const &name) { // If node empty return empty if (node == 0) return ""; // Get Attribute from child with name XMLAttrPointer_t attr = fXML->GetFirstAttr(node); std::string temp = ""; // Loop over all attributes while (attr != 0) { // If valid match then save if (std::string(fXML->GetAttrName(attr)) == name.c_str()) { temp = fXML->GetAttrValue(attr); } // Next Attribute attr = fXML->GetNextAttr(attr); } return temp; } std::string nuisconfig::GetS(XMLNodePointer_t node, std::string const &name) { return Get(node, name); } bool nuisconfig::GetB(XMLNodePointer_t node, std::string const &name) { std::string tempattr = Get(node, name); return GeneralUtils::StrToBool(tempattr); } int nuisconfig::GetI(XMLNodePointer_t node, std::string const &name) { std::string tempattr = Get(node, name); return GeneralUtils::StrToInt(tempattr); } float nuisconfig::GetF(XMLNodePointer_t node, std::string const &name) { std::string tempattr = Get(node, name); return GeneralUtils::StrToDbl(tempattr); } double nuisconfig::GetD(XMLNodePointer_t node, std::string const &name) { std::string tempattr = Get(node, name); return GeneralUtils::StrToDbl(tempattr); } std::vector nuisconfig::GetVS(XMLNodePointer_t node, std::string const &name, const char *del) { std::string tempattr = Get(node, name); return GeneralUtils::ParseToStr(tempattr, del); } // std::vector nuisconfig::GetVB(XMLNodePointer_t node, // std::string name, // const char* del) { // std::string tempattr = Get(node, name); // return GeneralUtils::ParseToBool(tempattr, del); // } std::vector nuisconfig::GetVI(XMLNodePointer_t node, std::string const &name, const char *del) { std::string tempattr = Get(node, name); return GeneralUtils::ParseToInt(tempattr, del); } // std::vector nuisconfig::GetVF(XMLNodePointer_t node, // std::string name, // const char* del) { // std::string tempattr = Get(node, name); // return GeneralUtils::ParseToDouble(tempattr, del); // } std::vector nuisconfig::GetVD(XMLNodePointer_t node, std::string const &name, char const *del) { std::string tempattr = Get(node, name); return GeneralUtils::ParseToDbl(tempattr, del); } std::vector nuisconfig::GetAllKeysForNode(XMLNodePointer_t node) { //bool matching = true; XMLAttrPointer_t attr = fXML->GetFirstAttr(node); std::vector keys; while (attr != 0) { if (!std::string(fXML->GetAttrName(attr)).empty()) { keys.push_back(std::string(fXML->GetAttrName(attr))); } attr = fXML->GetNextAttr(attr); } return keys; } XMLNodePointer_t nuisconfig::GetConfigNode(std::string const &name) { // Loop over children and look for name XMLNodePointer_t child = fXML->GetChild(fMainNode); while (child != 0) { // Select only config parameters if (!std::string(fXML->GetNodeName(child)).compare("config")) { // Loop over config attributes and search for name XMLAttrPointer_t attr = fXML->GetFirstAttr(child); while (attr != 0) { // Save name value if (std::string(fXML->GetAttrName(attr)) == name.c_str()) { return child; } // Get Next Attribute attr = fXML->GetNextAttr(attr); } } // Next Child child = fXML->GetNext(child); } return 0; } void nuisconfig::SetConfig(std::string const &name, std::string const &val) { XMLNodePointer_t node = GetConfigNode(name); if (!node) node = CreateNode("config"); Set(node, name, val); } void nuisconfig::SetConfig(std::string const &name, char const *val) { SetConfig(name, std::string(val)); } void nuisconfig::SetConfig(std::string const &name, bool val) { XMLNodePointer_t node = GetConfigNode(name); if (!node) node = CreateNode("config"); Set(node, name, val); } void nuisconfig::SetConfig(std::string const &name, int val) { XMLNodePointer_t node = GetConfigNode(name); if (!node) node = CreateNode("config"); Set(node, name, val); } void nuisconfig::SetConfig(std::string const &name, float val) { XMLNodePointer_t node = GetConfigNode(name); if (!node) node = CreateNode("config"); Set(node, name, val); } void nuisconfig::SetConfig(std::string const &name, double val) { XMLNodePointer_t node = GetConfigNode(name); if (!node) node = CreateNode("config"); Set(node, name, val); } void nuisconfig::OverrideConfig(std::string const &conf) { std::vector opts = GeneralUtils::ParseToStr(conf, "="); SetConfig(opts[0], opts[1]); } std::string nuisconfig::GetConfig(std::string const &name) { XMLNodePointer_t node = GetConfigNode(name); if (!node) return ""; XMLAttrPointer_t attr = fXML->GetFirstAttr(node); std::string temp = ""; // Loop config attributes while (attr != 0) { // Find match if (std::string(fXML->GetAttrName(attr)) == name.c_str()) { temp = fXML->GetAttrValue(attr); } // Get Next Attribute attr = fXML->GetNextAttr(attr); } return temp; } bool nuisconfig::HasConfig(std::string const &name) { return bool(GetConfigNode(name)); } std::string nuisconfig::GetConfigS(std::string const &name) { return GetConfig(name); } bool nuisconfig::GetConfigB(std::string const &name) { std::string pars = GetConfig(name); return GeneralUtils::StrToBool(pars); } int nuisconfig::GetConfigI(std::string const &name) { std::string pars = GetConfig(name); return GeneralUtils::StrToInt(pars); } float nuisconfig::GetConfigF(std::string const &name) { std::string pars = GetConfig(name); return GeneralUtils::StrToDbl(pars); } double nuisconfig::GetConfigD(std::string const &name) { std::string pars = GetConfig(name); return GeneralUtils::StrToDbl(pars); } std::string nuisconfig::GetParDIR(std::string const &parName) { std::string outstr = this->GetParS(parName); // Make replacements in the string const int nfiletypes = 2; const std::string filetypes[nfiletypes] = {"@data", "@nuisance"}; std::string filerepl[nfiletypes] = {FitPar::GetDataBase(), FitPar::GetDataBase() + "/../"}; for (int i = 0; i < nfiletypes; i++) { std::string findstring = filetypes[i]; std::string replstring = filerepl[i]; if (outstr.find(findstring) != std::string::npos) { outstr.replace(outstr.find(findstring), findstring.size(), filerepl[i]); break; } } return outstr; }; diff --git a/src/Config/NuisConfig.h b/src/Config/NuisConfig.h index d95795e..2df80e5 100644 --- a/src/Config/NuisConfig.h +++ b/src/Config/NuisConfig.h @@ -1,193 +1,193 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef NUISCONFIG_H_SEEN #define NUISCONFIG_H_SEEN #include #include #include "TFile.h" #include "TXMLEngine.h" /// NUISANCE Global Settings Class class nuisconfig { public: /// Singleton Get Function static nuisconfig &GetConfig(void); /// Constructor \n /// Loads defaults from $NUISANCE/parameters/config.xml nuisconfig(); /// Desctructor \n Frees XML Docs virtual ~nuisconfig(); /// Adds a new configuration list void LoadSettings(std::string const &filename, std::string const &state); /// Adds a new config from new xml file format void LoadXMLSettings(std::string const &filename, std::string const &state = ""); /// Adds a new config from old card file format void LoadCardSettings(std::string const &filename, std::string const &state); /// Save the config to file void WriteSettings(std::string const &filename); void PrintXML(XMLNodePointer_t node, int indent = 0); XMLNodePointer_t CreateNode(std::string const &name); XMLNodePointer_t CreateNode(XMLNodePointer_t node, std::string const &name); void RemoveEmptyNodes(); void RemoveIdenticalNodes(); bool MatchingNodes(XMLNodePointer_t node1, XMLNodePointer_t node2); void PrintNode(XMLNodePointer_t node); void RemoveNode(XMLNodePointer_t node); void FinaliseSettings(std::string const &name); XMLNodePointer_t CreateSampleNodeFromLine(std::string const &line); XMLNodePointer_t CreateParameterNodeFromLine(std::string const &line); XMLNodePointer_t CreatePullNodeFromLine(std::string const &line); XMLNodePointer_t CreateOldConfigNodeFromLine(std::string const &line); // Get List of child nodes of nuisance element std::vector GetNodes(std::string const &type = ""); std::vector GetNodes(XMLNodePointer_t node, std::string const &type = ""); XMLNodePointer_t GetNode(std::string const &type = ""); XMLNodePointer_t GetNode(XMLNodePointer_t node, std::string const &type = ""); std::vector GetAllKeysForNode(XMLNodePointer_t node); std::string GetElementName(XMLNodePointer_t node) { return fXML->GetNodeName(node); } /// Check node has key name bool Has(XMLNodePointer_t node, std::string const &name); /// Add attribute to node void Set(XMLNodePointer_t node, std::string const &name, std::string const &val); void Set(XMLNodePointer_t node, std::string const &name, char const *val); void Set(XMLNodePointer_t node, std::string const &name, bool val); void Set(XMLNodePointer_t node, std::string const &name, int val); void Set(XMLNodePointer_t node, std::string const &name, float val); void Set(XMLNodePointer_t node, std::string const &name, double val); void SetS(XMLNodePointer_t node, std::string const &name, std::string const &val); void SetB(XMLNodePointer_t node, std::string const &name, bool val); void SetI(XMLNodePointer_t node, std::string const &name, int val); void SetF(XMLNodePointer_t node, std::string const &name, float val); void SetD(XMLNodePointer_t node, std::string const &name, double val); /// Get String from a given node std::string Get(XMLNodePointer_t node, std::string const &name); std::string GetS(XMLNodePointer_t node, std::string const &name); bool GetB(XMLNodePointer_t node, std::string const &name); int GetI(XMLNodePointer_t node, std::string const &name); float GetF(XMLNodePointer_t node, std::string const &name); double GetD(XMLNodePointer_t node, std::string const &name); // Get values parsed into a vector std::vector GetVS(XMLNodePointer_t node, std::string const &name, const char *del); std::vector GetVI(XMLNodePointer_t node, std::string const &name, const char *del); std::vector GetVD(XMLNodePointer_t node, std::string const &name, const char *del); /// Set an already set config value to something else void OverrideConfig(std::string const &conf); /// Return the node of a given config parameter XMLNodePointer_t GetConfigNode(std::string const &name); void SetConfig(std::string const &name, std::string const &val); void SetConfig(std::string const &name, char const *val); void SetConfig(std::string const &name, bool val); void SetConfig(std::string const &name, int val); void SetConfig(std::string const &name, float val); void SetConfig(std::string const &name, double val); void SetParS(std::string const &name, std::string const &val); void SetParB(std::string const &name, bool val); void SetParI(std::string const &name, int val); void SetParD(std::string const &name, double val); std::string GetConfig(std::string const &name); bool HasConfig(std::string const &name); std::string GetConfigS(std::string const &name); bool GetConfigB(std::string const &name); int GetConfigI(std::string const &name); float GetConfigF(std::string const &name); double GetConfigD(std::string const &name); std::string GetPar(std::string const &name) { return GetConfig(name); }; std::string GetParS(std::string const &name) { return GetConfigS(name); }; bool GetParB(std::string const &name) { return GetConfigB(name); }; int GetParI(std::string const &name) { return GetConfigI(name); }; float GetParF(std::string const &name) { return GetConfigF(name); }; double GetParD(std::string const &name) { return GetConfigD(name); }; std::string GetParDIR(std::string const &parName); TFile *out; private: XMLNodePointer_t fMainNode; ///< Main XML Parent Node TXMLEngine *fXML; ///< ROOT XML Engine std::vector fXMLDocs; ///< List of all XML document inputs protected: static nuisconfig *m_nuisconfigInstance; }; namespace Config { nuisconfig &Get(); std::string GetPar(std::string const &name); bool HasPar(std::string const &name); std::string GetParS(std::string const &name); bool GetParB(std::string const &name); int GetParI(std::string const &name); float GetParF(std::string const &name); double GetParD(std::string const &name); void SetPar(std::string const &name, std::string const &val); void SetPar(std::string const &name, char const *val); void SetPar(std::string const &name, bool val); void SetPar(std::string const &name, int val); void SetPar(std::string const &name, float val); void SetPar(std::string const &name, double val); } namespace FitPar { nuisconfig &Config(); std::string GetDataBase(); } /*! @} */ #endif diff --git a/src/Devel/CMakeLists.txt b/src/Devel/CMakeLists.txt index 926dd82..f7b63f0 100644 --- a/src/Devel/CMakeLists.txt +++ b/src/Devel/CMakeLists.txt @@ -1,233 +1,233 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ANL_CC1npip_1DEnu_nu.cxx ANL_CC1npip_1Dppi_nu.cxx ANL_CC1npip_1DQ2Ev_nu.cxx ANL_CC1pi0_1DEnu_nu.cxx ANL_CC1pi0_1DQ2Ev_nu.cxx ANL_CC1ppip_1DEnu_nu.cxx ANL_CC1ppip_1Dppi_nu.cxx ANL_CC1ppip_1DQ2Ev_nu.cxx ANL_CC1ppip_1DQ2_nu.cxx ANL_CC1ppip_1Dthpr_nu.cxx ANL_NC1npip_1Dppi_nu.cxx BEBC_CC1npim_1DEnu_antinu.cxx BEBC_CC1npim_1DQ2_antinu.cxx BEBC_CC1npip_1DEnu_nu.cxx BEBC_CC1npip_1DQ2_nu.cxx BEBC_CC1pi0_1DEnu_nu.cxx BEBC_CC1pi0_1DQ2_nu.cxx BEBC_CC1ppim_1DEnu_antinu.cxx BEBC_CC1ppim_1DQ2_antinu.cxx BEBC_CC1ppip_1DEnu_nu.cxx BEBC_CC1ppip_1DQ2_nu.cxx BNL_CC1npip_1DEnu_nu.cxx BNL_CC1npip_1DQ2Ev_nu.cxx BNL_CC1pi0_1DEnu_nu.cxx BNL_CC1pi0_1DQ2Ev_nu.cxx BNL_CC1ppip_1DEnu_nu.cxx BNL_CC1ppip_1DQ2Ev_nu.cxx BNL_NC1ppim_1DEnu_nu.cxx BNL_NC1ppim_1DQ2_nu.cxx FitUtils.cxx FNAL_CC1ppim_1DEnu_anu.cxx FNAL_CC1ppim_1DQ2_anu.cxx FNAL_CC1ppip_1DEnu_nu.cxx FNAL_CC1ppip_1DQ2Ev_nu.cxx FNAL_CC1ppip_1DQ2_nu.cxx GGM_CC1ppip_1DEnu_nu.cxx GGM_CC1ppip_1DQ2Ev_nu.cxx K2K_CCpip_CCQE_1DEnu_nu.cxx K2K_NCpi0_1Dppi0_nu.cxx MINERvA_1DQ2_antinu_20deg.cxx MINERvA_1DQ2_antinu.cxx MINERvA_1DQ2_nu_20deg.cxx MINERvA_1DQ2_nu.cxx MINERvA_CCcoh_1DEnu_antinu.cxx MINERvA_CCcoh_1DEnu_nu.cxx MINERvA_CCcoh_1DEpi_antinu.cxx MINERvA_CCcoh_1DEpi_nu.cxx MINERvA_CCcoh_1Dth_antinu.cxx MINERvA_CCcoh_1Dth_nu.cxx MINERvA_CCpi0_1Dppi0_antinu.cxx MINERvA_CCpi0_1Dth_antinu.cxx MINERvA_CCpip_1Dth_20deg_nu.cxx MINERvA_CCpip_1Dth_nu.cxx MINERvA_CCpip_1DTpi_20deg_nu.cxx MINERvA_CCpip_1DTpi_nu.cxx MiniBooNE_1DEnuLike_nu.cxx MiniBooNE_1DEnu_nu.cxx MiniBooNE_1DQ2_antinu.cxx MiniBooNE_1DQ2_nu.cxx MiniBooNE_2DTcos_antinu_CCQELike.cxx MiniBooNE_2DTcos_antinu.cxx MiniBooNE_2DTcos_nu_CCQELike.cxx MiniBooNE_2DTcos_nu.cxx MiniBooNE_CCpi0_1Dcosmu_nu.cxx MiniBooNE_CCpi0_1Dcospi0_nu.cxx MiniBooNE_CCpi0_1DEnu_nu.cxx MiniBooNE_CCpi0_1Dppi0_nu.cxx MiniBooNE_CCpi0_1DQ2_nu.cxx MiniBooNE_CCpi0_1DTu_nu.cxx MiniBooNE_CCpip_1DEnu_nu.cxx MiniBooNE_CCpip_1DQ2_nu.cxx MiniBooNE_CCpip_1DTpi_nu.cxx MiniBooNE_CCpip_1DTu_nu.cxx MiniBooNE_CCpip_2DQ2Enu_nu.cxx MiniBooNE_CCpip_2DTpiCospi_nu.cxx MiniBooNE_CCpip_2DTpiEnu_nu.cxx MiniBooNE_CCpip_2DTuCosmu_nu.cxx MiniBooNE_CCpip_2DTuEnu_nu.cxx MiniBooNE_CCpip_CCQE_1DEnu_nu.cxx MiniBooNE_CCpip_CCQELike_1DEnu_nu.cxx MiniBooNE_NCpi0_1Dcospi0_antinu.cxx MiniBooNE_NCpi0_1Dcospi0_joint_antinu.cxx MiniBooNE_NCpi0_1Dcospi0_joint_nu.cxx MiniBooNE_NCpi0_1Dcospi0_nu.cxx MiniBooNE_NCpi0_1Dppi0_antinu.cxx MiniBooNE_NCpi0_1Dppi0_joint_antinu.cxx MiniBooNE_NCpi0_1Dppi0_joint_nu.cxx MiniBooNE_NCpi0_1Dppi0_nu.cxx SignalDef.cxx T2K_CCpip_1Dcosmu_nu.cxx T2K_CCpip_1Dcosmupi_nu.cxx T2K_CCpip_1Dcospi_nu.cxx T2K_CCpip_1DEnuDelta_nu.cxx T2K_CCpip_1DEnuMB_nu.cxx T2K_CCpip_1Dpmu_nu.cxx T2K_CCpip_1Dppip_nu.cxx ) set(HEADERFILES ANL_CC1npip_1DEnu_nu.h ANL_CC1npip_1Dppi_nu.h ANL_CC1npip_1DQ2Ev_nu.h ANL_CC1pi0_1DEnu_nu.h ANL_CC1pi0_1DQ2Ev_nu.h ANL_CC1ppip_1DEnu_nu.h ANL_CC1ppip_1Dppi_nu.h ANL_CC1ppip_1DQ2Ev_nu.h ANL_CC1ppip_1DQ2_nu.h ANL_CC1ppip_1Dthpr_nu.h ANL_NC1npip_1Dppi_nu.h BEBC_CC1npim_1DEnu_antinu.h BEBC_CC1npim_1DQ2_antinu.h BEBC_CC1npip_1DEnu_nu.h BEBC_CC1npip_1DQ2_nu.h BEBC_CC1pi0_1DEnu_nu.h BEBC_CC1pi0_1DQ2_nu.h BEBC_CC1ppim_1DEnu_antinu.h BEBC_CC1ppim_1DQ2_antinu.h BEBC_CC1ppip_1DEnu_nu.h BEBC_CC1ppip_1DQ2_nu.h BNL_CC1npip_1DEnu_nu.h BNL_CC1npip_1DQ2Ev_nu.h BNL_CC1pi0_1DEnu_nu.h BNL_CC1pi0_1DQ2Ev_nu.h BNL_CC1ppip_1DEnu_nu.h BNL_CC1ppip_1DQ2Ev_nu.h BNL_NC1ppim_1DEnu_nu.h BNL_NC1ppim_1DQ2_nu.h FitUtils.h FNAL_CC1ppim_1DEnu_anu.h FNAL_CC1ppim_1DQ2_anu.h FNAL_CC1ppip_1DEnu_nu.h FNAL_CC1ppip_1DQ2Ev_nu.h FNAL_CC1ppip_1DQ2_nu.h GGM_CC1ppip_1DEnu_nu.h GGM_CC1ppip_1DQ2Ev_nu.h K2K_CCpip_CCQE_1DEnu_nu.h K2K_NCpi0_1Dppi0_nu.h MINERvA_1DQ2_antinu_20deg.h MINERvA_1DQ2_antinu.h MINERvA_1DQ2_nu_20deg.h MINERvA_1DQ2_nu.h MINERvA_CCcoh_1DEnu_antinu.h MINERvA_CCcoh_1DEnu_nu.h MINERvA_CCcoh_1DEpi_antinu.h MINERvA_CCcoh_1DEpi_nu.h MINERvA_CCcoh_1Dth_antinu.h MINERvA_CCcoh_1Dth_nu.h MINERvA_CCpi0_1Dppi0_antinu.h MINERvA_CCpi0_1Dth_antinu.h MINERvA_CCpip_1Dth_20deg_nu.h MINERvA_CCpip_1Dth_nu.h MINERvA_CCpip_1DTpi_20deg_nu.h MINERvA_CCpip_1DTpi_nu.h MiniBooNE_1DEnuLike_nu.h MiniBooNE_1DEnu_nu.h MiniBooNE_1DQ2_antinu.h MiniBooNE_1DQ2_nu.h MiniBooNE_2DTcos_antinu_CCQELike.h MiniBooNE_2DTcos_antinu.h MiniBooNE_2DTcos_nu_CCQELike.h MiniBooNE_2DTcos_nu.h MiniBooNE_CCpi0_1Dcosmu_nu.h MiniBooNE_CCpi0_1Dcospi0_nu.h MiniBooNE_CCpi0_1DEnu_nu.h MiniBooNE_CCpi0_1Dppi0_nu.h MiniBooNE_CCpi0_1DQ2_nu.h MiniBooNE_CCpi0_1DTu_nu.h MiniBooNE_CCpip_1DEnu_nu.h MiniBooNE_CCpip_1DQ2_nu.h MiniBooNE_CCpip_1DTpi_nu.h MiniBooNE_CCpip_1DTu_nu.h MiniBooNE_CCpip_2DQ2Enu_nu.h MiniBooNE_CCpip_2DTpiCospi_nu.h MiniBooNE_CCpip_2DTpiEnu_nu.h MiniBooNE_CCpip_2DTuCosmu_nu.h MiniBooNE_CCpip_2DTuEnu_nu.h MiniBooNE_CCpip_CCQE_1DEnu_nu.h MiniBooNE_CCpip_CCQELike_1DEnu_nu.h MiniBooNE_NCpi0_1Dcospi0_antinu.h MiniBooNE_NCpi0_1Dcospi0_joint_antinu.h MiniBooNE_NCpi0_1Dcospi0_joint_nu.h MiniBooNE_NCpi0_1Dcospi0_nu.h MiniBooNE_NCpi0_1Dppi0_antinu.h MiniBooNE_NCpi0_1Dppi0_joint_antinu.h MiniBooNE_NCpi0_1Dppi0_joint_nu.h MiniBooNE_NCpi0_1Dppi0_nu.h SignalDef.h T2K_CCpip_1Dcosmu_nu.h T2K_CCpip_1Dcosmupi_nu.h T2K_CCpip_1Dcospi_nu.h T2K_CCpip_1DEnuDelta_nu.h T2K_CCpip_1DEnuMB_nu.h T2K_CCpip_1Dpmu_nu.h T2K_CCpip_1Dppip_nu.h ) set(LIBNAME Devel) if(CMAKE_BUILD_TYPE MATCHES DEBUG) add_library(${LIBNAME} STATIC ${IMPLFILES}) else(CMAKE_BUILD_TYPE MATCHES RELEASE) add_library(${LIBNAME} SHARED ${IMPLFILES}) endif() set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_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/Electron/CMakeLists.txt b/src/Electron/CMakeLists.txt index a785720..b872a22 100644 --- a/src/Electron/CMakeLists.txt +++ b/src/Electron/CMakeLists.txt @@ -1,48 +1,48 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ElectronScattering_DurhamData.cxx ) set(HEADERFILES ElectronScattering_DurhamData.h ) set(LIBNAME expElectron) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION - "${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}") + "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Electron) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Electron/ElectronScattering_DurhamData.cxx b/src/Electron/ElectronScattering_DurhamData.cxx index 7d8cf8c..7910d81 100644 --- a/src/Electron/ElectronScattering_DurhamData.cxx +++ b/src/Electron/ElectronScattering_DurhamData.cxx @@ -1,483 +1,483 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ElectronScattering_DurhamData.h" //******************************************************************** ElectronScattering_DurhamData::ElectronScattering_DurhamData( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "Electron Scattering Durham Data sample. \n" "Target: Multiple \n" "Flux: Energy should match data being handled \n" "Signal: Any event with an electron in the final state \n"; fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.DefineAllowedSpecies("electron"); fSettings.SetTitle("Electron"); fSettings.SetAllowedTypes("FIX/DIAG", "FIX,FREE,SHAPE/DIAG/NORM/MASK"); fSettings.SetXTitle("q0"); fSettings.SetYTitle("#sigma"); fIsNoWidth = true; FinaliseSampleSettings(); // Plot Setup ------------------------------------------------------- SetDataFromName(fSettings.GetS("originalname")); SetCovarFromDiagonal(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon // fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents // + 0.)) / TotalIntegratedFlux()); EnuMin = fZLowLim; EnuMax = fZHighLim; double sigscale = GetEventHistogram()->Integral() * 1E-38 / double(fNEvents) / TotalIntegratedFlux(); // double dangle = 2 * M_PI * fabs((1. - cos(fYLowLim * M_PI / 180.)) - (1. - // cos(fYHighLim * M_PI / 180.))); // fScaleFactor = sigscale / dangle / fZCenter; fScaleFactor = sigscale; std::cout << "Event Integral = " << GetEventHistogram()->Integral() << std::endl; std::cout << "Flux Integral = " << TotalIntegratedFlux() << std::endl; std::cout << "FNEvents = " << fNEvents << std::endl; std::cout << "Z Limits = " << fZLowLim << " " << fZHighLim << std::endl; std::cout << "sigscale = " << sigscale << std::endl; std::cout << "fZCenter = " << fZCenter << std::endl; std::cout << "ScaleFactor = " << fScaleFactor << std::endl; // Finish up FinaliseMeasurement(); }; //******************************************************************** void ElectronScattering_DurhamData::SetDataFromName(std::string name) { //******************************************************************** // Data Should be given in the format // Electron_Z_A_Energy_Theta_Source std::vector splitstring = GeneralUtils::ParseToStr(name, "_"); std::string zstring = splitstring[1]; std::string astring = splitstring[2]; std::string estring = splitstring[3]; std::string tstring = splitstring[4]; std::string sstring = splitstring[5]; fYCenter = GeneralUtils::StrToDbl(tstring); fZCenter = GeneralUtils::StrToDbl(estring); // Create effective E and Theta bin Edges std::vector thetabinedges; std::vector ebinedges; int nthetabins = FitPar::Config().GetParI("Electron_NThetaBins"); int nebins = FitPar::Config().GetParI("Electron_NEnergyBins"); double thetawidth = FitPar::Config().GetParD("Electron_ThetaWidth"); double ewidth = FitPar::Config().GetParD("Electron_EnergyWidth"); for (int i = -nthetabins; i <= nthetabins; i++) { thetabinedges.push_back(fYCenter + thetawidth * (double(i))); } for (int i = -nebins; i <= nebins; i++) { double newval = fZCenter + ewidth * (double(i)); if (newval < 0.0) newval = 0.0; if (newval < GetEventHistogram()->GetXaxis()->GetXmin()) newval = GetEventHistogram()->GetXaxis()->GetXmin(); if (newval > GetEventHistogram()->GetXaxis()->GetXmax()) newval = GetEventHistogram()->GetXaxis()->GetXmax(); if (std::find(ebinedges.begin(), ebinedges.end(), newval) != ebinedges.end()) continue; ebinedges.push_back(newval); } // Determine target std::string target = ""; if (!zstring.compare("6") && !astring.compare("12")) target = "12C.dat"; else if (!zstring.compare("8") && !astring.compare("16")) target = "16O.dat"; else { NUIS_ABORT("Target not supported in electron scattering module!" ); } // Fill Data Points std::string line; std::ifstream mask((FitPar::GetDataBase() + "/Electron/" + target).c_str(), std::ifstream::in); if (!mask.good()) { NUIS_ABORT("Failed to open e-scattering database file: " << (FitPar::GetDataBase() + "/Electron/" + target)); } int i = 0; std::vector pointx; std::vector errorx; std::vector pointy; std::vector errory; double scalef = 1.E-38 * 1.E5; while (std::getline(mask >> std::ws, line, '\n')) { // std::cout << "Line = " << line << std::endl; if (line.empty()) continue; std::vector lineentries = GeneralUtils::ParseToStr(line, " "); // std::cout << "Checking : " << line << std::endl; if (zstring.compare(lineentries[0])) continue; if (astring.compare(lineentries[1])) continue; if (estring.compare(lineentries[2])) continue; if (tstring.compare(lineentries[3])) continue; if (sstring.compare(lineentries[7])) continue; // std::cout << "Registering data point : " << line << std::endl; // std::cout << "Adding Graph Point : " << // GeneralUtils::StrToDbl(lineentries[4]) << " " << // GeneralUtils::StrToDbl(lineentries[5]) << std::endl; // Loop through x and y points and find a place to insert if (pointx.empty()) { pointx.push_back(GeneralUtils::StrToDbl(lineentries[4])); errorx.push_back(0.0); pointy.push_back(GeneralUtils::StrToDbl(lineentries[5]) * scalef); errory.push_back(GeneralUtils::StrToDbl(lineentries[6]) * scalef); } else { for (size_t j = 0; j < pointx.size(); j++) { if (GeneralUtils::StrToDbl(lineentries[4]) < pointx[j] && j == 0) { // std::cout << "Inserting at start point iterator " << std::endl; pointx.insert(pointx.begin() + j, GeneralUtils::StrToDbl(lineentries[4])); errorx.insert(errorx.begin() + j, 0.0); pointy.insert(pointy.begin() + j, GeneralUtils::StrToDbl(lineentries[5]) * scalef); errory.insert(errory.begin() + j, GeneralUtils::StrToDbl(lineentries[6]) * scalef); break; } else if (GeneralUtils::StrToDbl(lineentries[4]) > pointx[j] && j == pointx.size() - 1) { // std::cout << "Pushing back data point " << std::endl; pointx.push_back(GeneralUtils::StrToDbl(lineentries[4])); errorx.push_back(0.0); pointy.push_back(GeneralUtils::StrToDbl(lineentries[5]) * scalef); errory.push_back(GeneralUtils::StrToDbl(lineentries[6]) * scalef); break; } else if (GeneralUtils::StrToDbl(lineentries[4]) > pointx[j - 1] && GeneralUtils::StrToDbl(lineentries[4]) < pointx[j]) { // std::cout << "Inserting at point iterator = " << j << std::endl; pointx.insert(pointx.begin() + j, GeneralUtils::StrToDbl(lineentries[4])); errorx.insert(errorx.begin() + j, 0.0); pointy.insert(pointy.begin() + j, GeneralUtils::StrToDbl(lineentries[5]) * scalef); errory.insert(errory.begin() + j, GeneralUtils::StrToDbl(lineentries[6]) * scalef); break; } } } // pointx.push_back(GeneralUtils::StrToDbl(lineentries[4])); // errorx.push_back(0.0); // pointy.push_back(GeneralUtils::StrToDbl(lineentries[5])); // errory.push_back(GeneralUtils::StrToDbl(lineentries[6])); i++; } if (!pointx.size() || (pointx.size() != errorx.size()) || !pointy.size() || (pointy.size() != errory.size())) { NUIS_ABORT("Failed to find dataset: " << name << "{" << "Z: " << zstring << ", A: " << astring << ", E: " << estring << ", CTheta: " << tstring << ", PubID: " << sstring << " } in file: " << (FitPar::GetDataBase() + "/Electron/" + target)); } // for (uint i = 0; i < pointx.size(); i++) { // std::cout << "Q0 Point " << i << " = " << pointx[i] << std::endl; // } fDataGraph = new TGraphErrors(pointx.size(), &pointx[0], &pointy[0], &errorx[0], &errory[0]); fDataGraph->SetNameTitle((fName + "_data_GRAPH").c_str(), (fName + "_data_GRAPH").c_str()); // Now form an effective data and mc histogram std::vector q0binedges; const double* x = fDataGraph->GetX(); // Loop over graph and get mid way point between each data point. for (int i = 0; i < fDataGraph->GetN(); i++) { // std::cout << "X Point = " << x[i] << std::endl; if (i == 0) { // First point set lower width as half distance to point above q0binedges.push_back(x[0] - ((x[1] - x[0]) / 2.0)); } else if (i == fDataGraph->GetN() - 1) { // Last point set upper width as half distance to point above. q0binedges.push_back(x[i] - ((x[i] - x[i - 1]) / 2.0)); q0binedges.push_back(x[i] + ((x[i] - x[i - 1]) / 2.0)); } else { // Set half distance to point below q0binedges.push_back(x[i] - ((x[i] - x[i - 1]) / 2.0)); } } // Bubble Sort // for (uint i = 0; i < q0binedges.size(); i++) { // std::cout << "Q0 Edge " << i << " = " << q0binedges[i] << std::endl; // } // for (uint i = 0; i < ebinedges.size(); i++) { // std::cout << "e Edge " << i << " = " << ebinedges[i] << std::endl; // } // for (uint i = 0; i < thetabinedges.size(); i++) { // std::cout << "theta Edge " << i << " = " << thetabinedges[i] << // std::endl; // } // Form the data hist, mchist, etc fDataHist = new TH1D((fName + "_data").c_str(), (fName + "_data").c_str(), q0binedges.size() - 1, &q0binedges[0]); fMCHist = (TH1D*)fDataHist->Clone("MC"); const double* y = fDataGraph->GetY(); const double* ey = fDataGraph->GetEY(); for (int i = 0; i < fDataGraph->GetN(); i++) { // std::cout << "Setting Data Bin " << i + 1 << " to " << y[i] << " +- " << // ey[i] << std::endl; fDataHist->SetBinContent(i + 1, y[i]); fDataHist->SetBinError(i + 1, ey[i]); fMCHist->SetBinContent(i + 1, 0.0); fMCHist->SetBinError(i + 1, 0.0); } fMCScan_Q0vsThetavsE = new TH3D((fName + "_MC_q0vsthetavse").c_str(), "MC_q0vsthetavse", q0binedges.size() - 1, &q0binedges[0], thetabinedges.size() - 1, &thetabinedges[0], ebinedges.size() - 1, &ebinedges[0]); fMCScan_Q0vsThetavsE->Reset(); fMCScan_Q0vsTheta = new TH2D( (fName + "_MC_q0vstheta").c_str(), "MC_q0vstheta", q0binedges.size() - 1, &q0binedges[0], thetabinedges.size() - 1, &thetabinedges[0]); fMCScan_Q0vsTheta->Reset(); fMCScan_Q0vsE = new TH2D((fName + "_MC_q0vse").c_str(), "MC_q0vse", q0binedges.size() - 1, &q0binedges[0], ebinedges.size() - 1, &ebinedges[0]); fMCScan_Q0vsE->Reset(); fXLowLim = fMCScan_Q0vsThetavsE->GetXaxis()->GetBinLowEdge(1); fXHighLim = fMCScan_Q0vsThetavsE->GetXaxis()->GetBinLowEdge( fMCScan_Q0vsThetavsE->GetNbinsX() + 2); fYLowLim = fMCScan_Q0vsThetavsE->GetYaxis()->GetBinLowEdge(1); fYHighLim = fMCScan_Q0vsThetavsE->GetYaxis()->GetBinLowEdge( fMCScan_Q0vsThetavsE->GetNbinsY() + 2); fZLowLim = fMCScan_Q0vsThetavsE->GetZaxis()->GetBinLowEdge(1); fZHighLim = fMCScan_Q0vsThetavsE->GetZaxis()->GetBinLowEdge( fMCScan_Q0vsThetavsE->GetNbinsZ() + 2); std::cout << "Sample " << name << "initialised: " << "{" << fXLowLim << "--" << fXHighLim << ", " << fYLowLim << "--" << fYHighLim << ", " << fZLowLim << "--" << fZHighLim << "}" << std::endl; } //******************************************************************** void ElectronScattering_DurhamData::FillEventVariables(FitEvent* event) { //******************************************************************** if (event->NumFSParticle(11) == 0) return; FitParticle* ein = event->PartInfo(0); FitParticle* eout = event->GetHMFSParticle(11); double q0 = fabs(ein->fP.E() - eout->fP.E()) / 1000.0; double E = ein->fP.E() / 1000.0; double theta = ein->fP.Vect().Angle(eout->fP.Vect()) * 180. / M_PI; fXVar = q0; fYVar = theta; fZVar = E; return; }; //******************************************************************** bool ElectronScattering_DurhamData::isSignal(FitEvent* event) { //******************************************************************** if (event->NumFSParticle(11) == 0) { std::cout << "Ev Cut due to no FS electron." << std::endl; return false; } // std::cout << "fXVar = " << fXVar << " " << fXLowLim << " " << fXHighLim << // std::endl; // std::cout << "fYVar = " << fYVar << " " << fYLowLim << " " << fYHighLim << // std::endl; // std::cout << "fZVar = " << fZVar << " " << fZLowLim << " " << fZHighLim << // std::endl; // std::cout << "iWeight: " << event->InputWeight << std::endl; if (fXVar < fXLowLim or fXVar > fXHighLim) { // std::cout << "Ev Cut due to X lims: " << fXLowLim << " -- " << fXHighLim // << " !<> " << fXVar << std::endl; return false; } if (fYVar < fYLowLim or fYVar > fYHighLim) { // std::cout << "Ev Cut due to Y lims: " << fYLowLim << " -- " << fYHighLim // << " !<> " << fXVar << std::endl; return false; } if (fZVar < fZLowLim or fZVar > fZHighLim) { // std::cout << "Ev Cut due to Z lims: " << fZLowLim << " -- " << fZHighLim // << " !<> " << fXVar << std::endl; return false; } return true; }; //******************************************************************** void ElectronScattering_DurhamData::FillHistograms() { //******************************************************************** Measurement1D::FillHistograms(); if (Signal) { fMCScan_Q0vsThetavsE->Fill(fXVar, fYVar, fZVar); fMCScan_Q0vsTheta->Fill(fXVar, fYVar); fMCScan_Q0vsE->Fill(fXVar, fZVar); } } // Weight = 1.0; // if (Signal) { // fMCHist->Fill(fXVar, Weight); // fMCFine->Fill(fXVar, Weight); // fMCStat->Fill(fXVar, 1.0); // if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, fXVar, Weight); // } // } void ElectronScattering_DurhamData::ResetAll() { Measurement1D::ResetAll(); fMCScan_Q0vsThetavsE->Reset(); fMCScan_Q0vsTheta->Reset(); fMCScan_Q0vsE->Reset(); } void ElectronScattering_DurhamData::ApplyNormScale(double norm) { Measurement1D::ApplyNormScale(norm); fMCScan_Q0vsThetavsE->Scale(1.0 / norm); fMCScan_Q0vsTheta->Scale(1.0 / norm); fMCScan_Q0vsE->Scale(1.0 / norm); } //******************************************************************** void ElectronScattering_DurhamData::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); /* fMCScan_Q0vsThetavsE->Scale(fScaleFactor, "width"); // Project into fMCScan_Q0vsTheta for (int x = 0; x < fMCScan_Q0vsThetavsE->GetNbinsX(); x++) { for (int y = 0; y < fMCScan_Q0vsThetavsE->GetNbinsY(); y++) { double total = 0.; for (int z = 0; z < fMCScan_Q0vsThetavsE->GetNbinsZ(); z++) { double zwidth = fMCScan_Q0vsThetavsE->GetZaxis()->GetBinWidth(z + 1); total += fMCScan_Q0vsThetavsE->GetBinContent(x + 1, y + 1, z + 1) * zwidth; } fMCScan_Q0vsTheta->SetBinContent(x + 1, y + 1, total); } } // Project into fMCScan_Q0vsE for (int x = 0; x < fMCScan_Q0vsThetavsE->GetNbinsX(); x++) { for (int z = 0; z < fMCScan_Q0vsThetavsE->GetNbinsZ(); z++) { double total = 0.; for (int y = 0; y < fMCScan_Q0vsThetavsE->GetNbinsY(); y++) { double ywidth = fMCScan_Q0vsThetavsE->GetYaxis()->GetBinWidth(y + 1); total += fMCScan_Q0vsThetavsE->GetBinContent(x + 1, y + 1, z + 1) * ywidth; } fMCScan_Q0vsE->SetBinContent(x + 1, z + 1, total); } } // Project fMCScan_Q0vsTheta into MC Hist for (int x = 0; x < fMCScan_Q0vsTheta->GetNbinsX(); x++) { double total = 0.; for (int y = 0; y < fMCScan_Q0vsTheta->GetNbinsY(); y++) { double ywidth = fMCScan_Q0vsTheta->GetYaxis()->GetBinWidth(y + 1); total += fMCScan_Q0vsTheta->GetBinContent(x + 1, y + 1); } double xwidth = fMCScan_Q0vsTheta->GetXaxis()->GetBinWidth(x + 1); fMCHist->SetBinContent(x + 1, total * xwidth); } fMCHist->Scale(fDataHist->Integral() / fMCHist->Integral()); */ } //******************************************************************** int ElectronScattering_DurhamData::GetNDOF() { //******************************************************************** return fDataGraph->GetN(); } void ElectronScattering_DurhamData::Write(std::string drawOpts) { Measurement1D::Write(drawOpts); fMCScan_Q0vsThetavsE->Write(); fMCScan_Q0vsTheta->Write(); fMCScan_Q0vsE->Write(); fDataGraph->Write(); } double ElectronScattering_DurhamData::GetLikelihood() { return 0.0; } void ElectronScattering_DurhamData::SetFitOptions(std::string opt) { return; } TH1D* ElectronScattering_DurhamData::GetMCHistogram(void) { return fMCHist; } TH1D* ElectronScattering_DurhamData::GetDataHistogram(void) { return fDataHist; } diff --git a/src/Electron/ElectronScattering_DurhamData.h b/src/Electron/ElectronScattering_DurhamData.h index b76d539..94af9ac 100644 --- a/src/Electron/ElectronScattering_DurhamData.h +++ b/src/Electron/ElectronScattering_DurhamData.h @@ -1,65 +1,65 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ElectronScattering_DurhamData_H_SEEN #define ElectronScattering_DurhamData_H_SEEN #include "Measurement1D.h" #include "TH3D.h" //******************************************************************** class ElectronScattering_DurhamData : public Measurement1D { //******************************************************************** public: ElectronScattering_DurhamData(nuiskey samplekey); virtual ~ElectronScattering_DurhamData() {}; void FillEventVariables(FitEvent *event); void FillHistograms(); bool isSignal(FitEvent *event); void ScaleEvents(); // Converts TH3D to TH1D void ResetAll(); void ApplyNormScale(double norm); void Write(std::string drawOpts); void SetDataFromName(std::string name); int GetNDOF(); double GetLikelihood(); void SetFitOptions(std::string opt); // MeasurementVariableBox* CreateBox() {return new MeasurementVariableBox1D();}; // ElectronVariableBox* GetBox() { return static_cast(MeasurementBase::GetBox()); }; TH1D* GetMCHistogram(void); TH1D* GetDataHistogram(void); private: TH3D* fMCScan_Q0vsThetavsE; TH2D* fMCScan_Q0vsTheta; TH2D* fMCScan_Q0vsE; // TH1D* fMCHist; // TH1D* fDataHist; TGraphErrors* fDataGraph; double fXLowLim, fXHighLim, fYLowLim, fYHighLim, fZLowLim, fZHighLim; double fYCenter, fZCenter; }; #endif diff --git a/src/FCN/CMakeLists.txt b/src/FCN/CMakeLists.txt index fe490d3..50d59be 100644 --- a/src/FCN/CMakeLists.txt +++ b/src/FCN/CMakeLists.txt @@ -1,59 +1,59 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES JointFCN.cxx SampleList.cxx ) set(HEADERFILES JointFCN.h MinimizerFCN.h SampleList.h ) set(LIBNAME FCN) 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(${MINIMUM_INCLUDE_DIRECTORIES}) include_directories(${EXP_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/Electron) include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/FCN) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FCN/JointFCN.cxx b/src/FCN/JointFCN.cxx index b5ea56f..774d693 100755 --- a/src/FCN/JointFCN.cxx +++ b/src/FCN/JointFCN.cxx @@ -1,1157 +1,1153 @@ #include "JointFCN.h" #include "FitUtils.h" #include //*************************************************** JointFCN::JointFCN(TFile *outfile) { //*************************************************** fOutputDir = gDirectory; if (outfile) Config::Get().out = outfile; std::vector samplekeys = Config::QueryKeys("sample"); LoadSamples(samplekeys); std::vector covarkeys = Config::QueryKeys("covar"); LoadPulls(covarkeys); fCurIter = 0; fMCFilled = false; fIterationTree = false; fDialVals = NULL; fNDials = 0; fUsingEventManager = FitPar::Config().GetParB("EventManager"); fOutputDir->cd(); } //*************************************************** JointFCN::JointFCN(std::vector samplekeys, TFile *outfile) { //*************************************************** fOutputDir = gDirectory; if (outfile) Config::Get().out = outfile; LoadSamples(samplekeys); fCurIter = 0; fMCFilled = false; fOutputDir->cd(); fIterationTree = false; fDialVals = NULL; fNDials = 0; fUsingEventManager = FitPar::Config().GetParB("EventManager"); fOutputDir->cd(); } //*************************************************** JointFCN::~JointFCN() { //*************************************************** // Delete Samples for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; delete exp; } for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; delete pull; } // Sort Tree if (fIterationTree) DestroyIterationTree(); if (fDialVals) delete fDialVals; if (fSampleLikes) delete fSampleLikes; }; //*************************************************** void JointFCN::CreateIterationTree(std::string name, FitWeight *rw) { //*************************************************** NUIS_LOG(FIT, " Creating new iteration container! "); DestroyIterationTree(); fIterationTreeName = name; // Add sample likelihoods and ndof for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; std::string name = exp->GetName(); std::string liketag = name + "_likelihood"; fNameValues.push_back(liketag); fCurrentValues.push_back(0.0); std::string ndoftag = name + "_ndof"; fNameValues.push_back(ndoftag); fCurrentValues.push_back(0.0); } // Add Pull terms for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; std::string name = pull->GetName(); std::string liketag = name + "_likelihood"; fNameValues.push_back(liketag); fCurrentValues.push_back(0.0); std::string ndoftag = name + "_ndof"; fNameValues.push_back(ndoftag); fCurrentValues.push_back(0.0); } // Add Likelihoods fNameValues.push_back("total_likelihood"); fCurrentValues.push_back(0.0); fNameValues.push_back("total_ndof"); fCurrentValues.push_back(0.0); // Setup Containers fSampleN = fSamples.size() + fPulls.size(); fSampleLikes = new double[fSampleN]; fSampleNDOF = new int[fSampleN]; // Add Dials std::vector dials = rw->GetDialNames(); for (size_t i = 0; i < dials.size(); i++) { fNameValues.push_back(dials[i]); fCurrentValues.push_back(0.0); } fNDials = dials.size(); fDialVals = new double[fNDials]; // Set IterationTree Flag fIterationTree = true; } //*************************************************** void JointFCN::DestroyIterationTree() { //*************************************************** fIterationCount.clear(); fCurrentValues.clear(); fNameValues.clear(); fIterationValues.clear(); } //*************************************************** void JointFCN::WriteIterationTree() { //*************************************************** NUIS_LOG(FIT, "Writing iteration tree"); // Make a new TTree TTree *itree = new TTree(fIterationTreeName.c_str(), fIterationTreeName.c_str()); double *vals = new double[fNameValues.size()]; int count = 0; itree->Branch("iteration", &count, "Iteration/I"); for (size_t i = 0; i < fNameValues.size(); i++) { itree->Branch(fNameValues[i].c_str(), &vals[i], (fNameValues[i] + "/D").c_str()); } // Fill Iterations for (size_t i = 0; i < fIterationValues.size(); i++) { std::vector itervals = fIterationValues[i]; // Fill iteration state count = fIterationCount[i]; for (size_t j = 0; j < itervals.size(); j++) { vals[j] = itervals[j]; } // Save to TTree itree->Fill(); } // Write to file itree->Write(); } //*************************************************** void JointFCN::FillIterationTree(FitWeight *rw) { //*************************************************** // Loop over samples count int count = 0; for (int i = 0; i < fSampleN; i++) { fCurrentValues[count++] = fSampleLikes[i]; fCurrentValues[count++] = double(fSampleNDOF[i]); } // Fill Totals fCurrentValues[count++] = fLikelihood; fCurrentValues[count++] = double(fNDOF); // Loop Over Parameter Counts rw->GetAllDials(fDialVals, fNDials); for (int i = 0; i < fNDials; i++) { fCurrentValues[count++] = double(fDialVals[i]); } // Push Back Into Container fIterationCount.push_back(fCurIter); fIterationValues.push_back(fCurrentValues); } //*************************************************** double JointFCN::DoEval(const double *x) { //*************************************************** double *par_vals = new double[fNPars]; for (int i = 0; i < fNPars; ++i) { if (fMirroredParams.count(i)) { if (!fMirroredParams[i].mirror_above && (x[i] < fMirroredParams[i].mirror_value)) { double xabove = fMirroredParams[i].mirror_value - x[i]; par_vals[i] = fMirroredParams[i].mirror_value + xabove; std::cout << "\t--Parameter " << i << " mirrored from " << x[i] << " -> " << par_vals[i] << std::endl; } else if (fMirroredParams[i].mirror_above && (x[i] >= fMirroredParams[i].mirror_value)) { double xabove = x[i] - fMirroredParams[i].mirror_value; par_vals[i] = fMirroredParams[i].mirror_value - xabove; std::cout << "\t--Parameter " << i << " mirrored from " << x[i] << " -> " << par_vals[i] << std::endl; } else { par_vals[i] = x[i]; } } else { par_vals[i] = x[i]; } } // WEIGHT ENGINE fDialChanged = FitBase::GetRW()->HasRWDialChanged(par_vals); FitBase::GetRW()->UpdateWeightEngine(par_vals); if (fDialChanged) { FitBase::GetRW()->Reconfigure(); FitBase::EvtManager().ResetWeightFlags(); } if (LOG_LEVEL(REC)) { FitBase::GetRW()->Print(); } // SORT SAMPLES ReconfigureSamples(); // GET TEST STAT fLikelihood = GetLikelihood(); fNDOF = GetNDOF(); // PRINT PROGRESS NUIS_LOG(FIT, "Current Stat (iter. " << this->fCurIter << ") = " << fLikelihood); // UPDATE TREE if (fIterationTree) FillIterationTree(FitBase::GetRW()); delete[] par_vals; return fLikelihood; } //*************************************************** int JointFCN::GetNDOF() { //*************************************************** int totaldof = 0; int count = 0; // Total number of Free bins in each MC prediction for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; int dof = exp->GetNDOF(); // Save Separate DOF if (fIterationTree) { fSampleNDOF[count] = dof; } // Add to total totaldof += dof; count++; } // Loop over pulls for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; double dof = pull->GetLikelihood(); // Save separate DOF if (fIterationTree) { fSampleNDOF[count] = dof; } // Add to total totaldof += dof; count++; } // Set Data Variable if (fIterationTree) { fSampleNDOF[count] = totaldof; } return totaldof; } //*************************************************** double JointFCN::GetLikelihood() { //*************************************************** - NUIS_LOG(MIN, std::left << std::setw(43) << "Getting likelihoods..." + NUIS_LOG(MIN, std::left << std::setw(53) << "Getting likelihoods..." << " : " << "-2logL"); // Loop and add up likelihoods in an uncorrelated way double like = 0.0; int count = 0; for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; double newlike = exp->GetLikelihood(); int ndof = exp->GetNDOF(); // Save separate likelihoods if (fIterationTree) { fSampleLikes[count] = newlike; } - NUIS_LOG(MIN, "-> " << std::left << std::setw(40) << exp->GetName() << " : " + NUIS_LOG(MIN, "|-> " << std::left << std::setw(49) << exp->GetName() << " : " << newlike << "/" << ndof); // Add Weight Scaling // like *= FitBase::GetRW()->GetSampleLikelihoodWeight(exp->GetName()); // Add to total like += newlike; count++; } // Loop over pulls for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; double newlike = pull->GetLikelihood(); // Save separate likelihoods if (fIterationTree) { fSampleLikes[count] = newlike; } // Add to total like += newlike; count++; } // Set Data Variable fLikelihood = like; if (fIterationTree) { fSampleLikes[count] = fLikelihood; } return like; }; void JointFCN::LoadSamples(std::vector samplekeys) { NUIS_LOG(MIN, "Loading Samples : " << samplekeys.size()); for (size_t i = 0; i < samplekeys.size(); i++) { nuiskey key = samplekeys[i]; // Get Sample Options std::string samplename = key.GetS("name"); std::string samplefile = key.GetS("input"); std::string sampletype = key.GetS("type"); std::string fakeData = ""; NUIS_LOG(MIN, "Loading Sample : " << samplename); fOutputDir->cd(); MeasurementBase *NewLoadedSample = SampleUtils::CreateSample(key); if (!NewLoadedSample) { NUIS_ERR(FTL, "Could not load sample provided: " << samplename); NUIS_ERR(FTL, "Check spelling with that in src/FCN/SampleList.cxx"); throw; } else { fSamples.push_back(NewLoadedSample); } } } //*************************************************** void JointFCN::LoadPulls(std::vector pullkeys) { //*************************************************** for (size_t i = 0; i < pullkeys.size(); i++) { nuiskey key = pullkeys[i]; std::string pullname = key.GetS("name"); std::string pullfile = key.GetS("input"); std::string pulltype = key.GetS("type"); fOutputDir->cd(); fPulls.push_back(new ParamPull(pullname, pullfile, pulltype)); } } //*************************************************** void JointFCN::ReconfigureSamples(bool fullconfig) { //*************************************************** int starttime = time(NULL); + NUIS_LOG(REC, "------------"); NUIS_LOG(REC, "Starting Reconfigure iter. " << this->fCurIter); // std::cout << fUsingEventManager << " " << fullconfig << " " << fMCFilled // << std::endl; Event Manager Reconf if (fUsingEventManager) { if (!fullconfig && fMCFilled) ReconfigureFastUsingManager(); else ReconfigureUsingManager(); } else { // Loop over all Measurement Classes for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; // If RW Either do signal or full reconfigure. if (fDialChanged or !fMCFilled or fullconfig) { if (!fullconfig and fMCFilled) exp->ReconfigureFast(); else exp->Reconfigure(); // If RW Not needed just do normalisation } else { exp->Renormalise(); } } } // Loop over pulls and update for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; pull->Reconfigure(); } fMCFilled = true; NUIS_LOG(MIN, "Finished Reconfigure iter. " << fCurIter << " in " << time(NULL) - starttime << "s"); fCurIter++; } //*************************************************** void JointFCN::ReconfigureSignal() { //*************************************************** ReconfigureSamples(false); } //*************************************************** void JointFCN::ReconfigureAllEvents() { //*************************************************** FitBase::GetRW()->Reconfigure(); FitBase::EvtManager().ResetWeightFlags(); ReconfigureSamples(true); } std::vector JointFCN::GetInputList() { std::vector InputList; fIsAllSplines = true; MeasListConstIter iterSam = fSamples.begin(); for (; iterSam != fSamples.end(); iterSam++) { MeasurementBase *exp = (*iterSam); std::vector subsamples = exp->GetSubSamples(); for (size_t i = 0; i < subsamples.size(); i++) { InputHandlerBase *inp = subsamples[i]->GetInput(); if (std::find(InputList.begin(), InputList.end(), inp) == InputList.end()) { if (subsamples[i]->GetInput()->GetType() != kSPLINEPARAMETER) fIsAllSplines = false; InputList.push_back(subsamples[i]->GetInput()); } } } return InputList; } std::vector JointFCN::GetSubSampleList() { std::vector SampleList; MeasListConstIter iterSam = fSamples.begin(); for (; iterSam != fSamples.end(); iterSam++) { MeasurementBase *exp = (*iterSam); std::vector subsamples = exp->GetSubSamples(); for (size_t i = 0; i < subsamples.size(); i++) { SampleList.push_back(subsamples[i]); } } return SampleList; } //*************************************************** void JointFCN::ReconfigureUsingManager() { //*************************************************** // 'Slow' Event Manager Reconfigure NUIS_LOG(REC, "Event Manager Reconfigure"); - int timestart = time(NULL); + // int timestart = time(NULL); // Reset all samples MeasListConstIter iterSam = fSamples.begin(); for (; iterSam != fSamples.end(); iterSam++) { MeasurementBase *exp = (*iterSam); exp->ResetAll(); } - // If we are siving signal, reset all containers. + // If we are saving signal, reset all containers. bool savesignal = (FitPar::Config().GetParB("SignalReconfigures")); if (savesignal) { // Reset all of our event signal vectors fSignalEventBoxes.clear(); fSignalEventFlags.clear(); fSampleSignalFlags.clear(); fSignalEventSplines.clear(); } // Make sure we have a list of inputs if (fInputList.empty()) { fInputList = GetInputList(); fSubSampleList = GetSubSampleList(); } // If all inputs are splines make sure the readers are told // they need to be reconfigured. std::vector::iterator inp_iter = fInputList.begin(); if (fIsAllSplines) { for (; inp_iter != fInputList.end(); inp_iter++) { InputHandlerBase *curinput = (*inp_iter); // Tell reader in each BaseEvent it needs a Reconfigure next weight // calc. BaseFitEvt *curevent = curinput->FirstBaseEvent(); if (curevent->fSplineRead) { curevent->fSplineRead->SetNeedsReconfigure(true); } } } // MAIN INPUT LOOP ==================== int fillcount = 0; int inputcount = 0; inp_iter = fInputList.begin(); // Loop over each input in manager for (; inp_iter != fInputList.end(); inp_iter++) { InputHandlerBase *curinput = (*inp_iter); // Get event information FitEvent *curevent = curinput->FirstNuisanceEvent(); curinput->CreateCache(); int i = 0; int nevents = curinput->GetNEvents(); int countwidth = nevents / 10; uint textwidth = strlen(Form("%i", nevents)); // Start event loop iterating until we get a NULL pointer. while (curevent) { // Get Event Weight // The reweighting weight curevent->RWWeight = FitBase::GetRW()->CalcWeight(curevent); // The Custom weight and reweight curevent->Weight = curevent->RWWeight * curevent->InputWeight * curevent->CustomWeight; if (LOGGING(REC)) { if (countwidth && (i % countwidth == 0)) { - NUIS_LOG(REC, curinput->GetName() - << " : Processed " << std::setw(textwidth) << i - << " events. [M, W] = [" << std::setw(3) - << curevent->Mode << ", " << std::setw(5) - << Form("%.3lf", curevent->Weight) << "]"); + NUIS_LOG(REC, std::left << std::setw(52) << curinput->GetName() + << ": Processed " << std::right << std::setw(textwidth) << i + << " events. [M, W] = [" << std::setw(3) + << curevent->Mode << ", " << std::setw(5) + << Form("%.3lf", curevent->Weight) << "]"); } } // Setup flag for if signal found in at least one sample bool foundsignal = false; // Create a new signal bitset for this event std::vector signalbitset(fSubSampleList.size()); // Create a new signal box vector for this event std::vector signalboxes; // Start measurement iterator size_t measitercount = 0; std::vector::iterator meas_iter = fSubSampleList.begin(); // Loop over all subsamples (sub in JointMeas) for (; meas_iter != fSubSampleList.end(); meas_iter++) { MeasurementBase *curmeas = (*meas_iter); // Compare input pointers, to current input, skip if not. // Pointer tells us if it matches without doing ID checks. if (curinput != curmeas->GetInput()) { if (savesignal) { // Set bit to 0 as definitely not signal signalbitset[measitercount] = 0; } // Count up what measurement we are on. measitercount++; // Skip sample as input not signal. continue; } // Fill events for matching inputs. MeasurementVariableBox *box = curmeas->FillVariableBox(curevent); bool signal = curmeas->isSignal(curevent); curmeas->SetSignal(signal); curmeas->FillHistograms(curevent->Weight); // If its Signal tally up fills if (signal) { fillcount++; } // If we are saving signal/splines fill the bitset if (savesignal) { signalbitset[measitercount] = signal; } // If signal save a clone of the event box for use later. if (savesignal and signal) { foundsignal = true; signalboxes.push_back(box->CloneSignalBox()); } // Keep track of Measurement we are on. measitercount++; } // Once we've filled the measurements, if saving signal // push back if any sample flagged this event as signal if (savesignal) { fSignalEventFlags.push_back(foundsignal); } // Save the vector of signal boxes for this event if (savesignal && foundsignal) { fSignalEventBoxes.push_back(signalboxes); fSampleSignalFlags.push_back(signalbitset); } // If all inputs are splines we can save the spline coefficients // for fast in memory reconfigures later. if (fIsAllSplines && savesignal && foundsignal) { // Make temp vector to push back with std::vector coeff; for (size_t l = 0; l < (UInt_t)curevent->fSplineRead->GetNPar(); l++) { coeff.push_back(curevent->fSplineCoeff[l]); } // Push back to signal event splines. Kept in sync with // fSignalEventBoxes size. // int splinecount = fSignalEventSplines.size(); fSignalEventSplines.push_back(coeff); // if (splinecount % 1000 == 0) { // std::cout << "Pushed Back Coeff " << splinecount << " : "; // for (size_t l = 0; l < fSignalEventSplines[splinecount].size(); // l++) // { // std::cout << " " << fSignalEventSplines[splinecount][l]; // } // std::cout << std::endl; // } } // Clean up vectors once done with this event signalboxes.clear(); signalbitset.clear(); // Iterate to the next event. curevent = curinput->NextNuisanceEvent(); i++; } // curinput->RemoveCache(); // Keep track of what input we are on. inputcount++; } // End of Event Loop =============================== // Now event loop is finished loop over all Measurements // Converting Binned events to XSec Distributions iterSam = fSamples.begin(); for (; iterSam != fSamples.end(); iterSam++) { MeasurementBase *exp = (*iterSam); exp->ConvertEventRates(); } // Print out statements on approximate memory usage for profiling. NUIS_LOG(REC, "Filled " << fillcount << " signal events."); if (savesignal) { int mem = ( // sizeof(fSignalEventBoxes) + // fSignalEventBoxes.size() * sizeof(fSignalEventBoxes.at(0)) + sizeof(MeasurementVariableBox1D) * fillcount) * 1E-6; NUIS_LOG(REC, " -> Saved " << fillcount << " signal boxes for faster access. (~" << mem << " MB)"); if (fIsAllSplines and !fSignalEventSplines.empty()) { int splmem = sizeof(float) * fSignalEventSplines.size() * fSignalEventSplines[0].size() * 1E-6; NUIS_LOG(REC, " -> Saved " << fillcount << " " << fSignalEventSplines.size() << " spline sets into memory. (~" << splmem << " MB)"); } } - NUIS_LOG(REC, - "Time taken ReconfigureUsingManager() : " << time(NULL) - timestart); - // Check SignalReconfigures works for all samples if (savesignal) { double likefull = GetLikelihood(); ReconfigureFastUsingManager(); double likefast = GetLikelihood(); if (fabs(likefull - likefast) > 0.0001) { NUIS_ERR(FTL, "Fast and Full Likelihoods DIFFER! : " << likefull << " : " << likefast); NUIS_ERR(FTL, "This means some samples you are using are not setup to use " "SignalReconfigures=1"); NUIS_ERR(FTL, "Please turn OFF signal reconfigures."); throw; } else { NUIS_LOG(FIT, "Likelihoods for FULL and FAST match. Will use FAST next time."); } } }; //*************************************************** void JointFCN::ReconfigureFastUsingManager() { //*************************************************** - NUIS_LOG(FIT, " -> Doing FAST using manager"); + NUIS_LOG(FIT, "Reconfiguring FAST using manager"); // Get Start time for profilling - int timestart = time(NULL); + // int timestart = time(NULL); // Reset all samples MeasListConstIter iterSam = fSamples.begin(); for (; iterSam != fSamples.end(); iterSam++) { MeasurementBase *exp = (*iterSam); exp->ResetAll(); } // Check for saved variables if not do a full reconfigure. if (fSignalEventFlags.empty()) { - NUIS_ERR(WRN, "Signal Flags Empty! Using normal manager."); + NUIS_LOG(REC, "Signal Flags Empty! Using normal manager."); ReconfigureUsingManager(); return; } bool fFillNuisanceEvent = FitPar::Config().GetParB("FullEventOnSignalReconfigure"); // Setup fast vector iterators. std::vector::iterator inpsig_iter = fSignalEventFlags.begin(); std::vector >::iterator box_iter = fSignalEventBoxes.begin(); std::vector >::iterator spline_iter = fSignalEventSplines.begin(); std::vector >::iterator samsig_iter = fSampleSignalFlags.begin(); int splinecount = 0; // Setup stuff for logging int fillcount = 0; // This is just the total number of events // int nevents = fSignalEventFlags.size(); // This is the number of events that are signal int nevents = fSignalEventBoxes.size(); int countwidth = nevents / 10; // If All Splines tell splines they need a reconfigure. std::vector::iterator inp_iter = fInputList.begin(); if (fIsAllSplines) { NUIS_LOG(REC, "All Spline Inputs so using fast spline loop."); for (; inp_iter != fInputList.end(); inp_iter++) { InputHandlerBase *curinput = (*inp_iter); // Tell each fSplineRead in BaseFitEvent to reconf next weight calc BaseFitEvt *curevent = curinput->FirstBaseEvent(); if (curevent->fSplineRead) curevent->fSplineRead->SetNeedsReconfigure(true); } } // Loop over all possible spline inputs double *coreeventweights = new double[fSignalEventBoxes.size()]; splinecount = 0; inp_iter = fInputList.begin(); inpsig_iter = fSignalEventFlags.begin(); spline_iter = fSignalEventSplines.begin(); // Loop over all signal flags // For each valid signal flag add one to splinecount // Get Splines from that count and add to weight // Add splinecount int sigcount = 0; // #pragma omp parallel for shared(splinecount,sigcount) for (uint iinput = 0; iinput < fInputList.size(); iinput++) { InputHandlerBase *curinput = fInputList[iinput]; BaseFitEvt *curevent = curinput->FirstBaseEvent(); // Loop over the events in each input for (int i = 0; i < curinput->GetNEvents(); i++) { double rwweight = 0.0; // If the event is a signal event if (fSignalEventFlags[sigcount]) { // Get Event Info if (!fIsAllSplines) { if (fFillNuisanceEvent) { curevent = curinput->GetNuisanceEvent(i); } else { curevent = curinput->GetBaseEvent(i); } } else { curevent->fSplineCoeff = &fSignalEventSplines[splinecount][0]; } curevent->RWWeight = FitBase::GetRW()->CalcWeight(curevent); curevent->Weight = curevent->RWWeight * curevent->InputWeight * curevent->CustomWeight; rwweight = curevent->Weight; coreeventweights[splinecount] = rwweight; if (countwidth && ((splinecount % countwidth) == 0)) { NUIS_LOG(REC, curinput->GetName() << " : Processed " << i << " events. W = " << curevent->Weight << std::endl); } // #pragma omp atomic splinecount++; } // #pragma omp atomic sigcount++; } } NUIS_LOG(SAM, "Processed event weights."); // #pragma omp barrier // Reset Iterators inpsig_iter = fSignalEventFlags.begin(); spline_iter = fSignalEventSplines.begin(); box_iter = fSignalEventBoxes.begin(); samsig_iter = fSampleSignalFlags.begin(); int nsplineweights = splinecount; splinecount = 0; // Start of Fast Event Loop ============================ // Start input iterators // Loop over number of inputs for (int ispline = 0; ispline < nsplineweights; ispline++) { double rwweight = coreeventweights[ispline]; // Get iterators for this event std::vector::iterator subsamsig_iter = (*samsig_iter).begin(); std::vector::iterator subbox_iter = (*box_iter).begin(); // Loop over all sub measurements. std::vector::iterator meas_iter = fSubSampleList.begin(); for (; meas_iter != fSubSampleList.end(); meas_iter++, subsamsig_iter++) { MeasurementBase *curmeas = (*meas_iter); // If event flagged as signal for this sample fill from the box. if (*subsamsig_iter) { curmeas->SetSignal(true); curmeas->FillHistogramsFromBox((*subbox_iter), rwweight); // Move onto next box if there is one. subbox_iter++; fillcount++; } } if (ispline % countwidth == 0) { NUIS_LOG(REC, "Filled " << ispline << " sample weights."); } // Iterate over the main signal event containers. samsig_iter++; box_iter++; spline_iter++; splinecount++; } // End of Fast Event Loop =================== NUIS_LOG(SAM, "Filled sample distributions."); // Now loop over all Measurements // Convert Binned events iterSam = fSamples.begin(); for (; iterSam != fSamples.end(); iterSam++) { MeasurementBase *exp = (*iterSam); exp->ConvertEventRates(); } // Cleanup coreeventweights delete coreeventweights; // Print some reconfigure profiling. NUIS_LOG(REC, "Filled " << fillcount << " signal events."); - NUIS_LOG(REC, "Time taken ReconfigureFastUsingManager() : " << time(NULL) - - timestart); } //*************************************************** void JointFCN::Write() { //*************************************************** // Save a likelihood/ndof plot NUIS_LOG(MIN, "Writing likelihood plot..."); std::vector likes; std::vector ndofs; std::vector names; for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; double like = exp->GetLikelihood(); double ndof = exp->GetNDOF(); std::string name = exp->GetName(); likes.push_back(like); ndofs.push_back(ndof); names.push_back(name); } if (likes.size()) { TH1D likehist = TH1D("likelihood_hist", "likelihood_hist;Sample;#chi^{2}", likes.size(), 0.0, double(likes.size())); TH1D ndofhist = TH1D("ndof_hist", "ndof_hist;Sample;NDOF", ndofs.size(), 0.0, double(ndofs.size())); TH1D divhist = TH1D("likedivndof_hist", "likedivndof_hist;Sample;#chi^{2}/NDOF", likes.size(), 0.0, double(likes.size())); for (int i = 0; i < likehist.GetNbinsX(); i++) { likehist.SetBinContent(i + 1, likes[i]); ndofhist.SetBinContent(i + 1, ndofs[i]); if (ndofs[i] != 0.0) { divhist.SetBinContent(i + 1, likes[i] / ndofs[i]); } likehist.GetXaxis()->SetBinLabel(i + 1, names[i].c_str()); ndofhist.GetXaxis()->SetBinLabel(i + 1, names[i].c_str()); divhist.GetXaxis()->SetBinLabel(i + 1, names[i].c_str()); } likehist.Write(); ndofhist.Write(); divhist.Write(); } // Loop over individual experiments and call Write NUIS_LOG(MIN, "Writing each of the data classes..."); for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; exp->Write(); } // Save Pull Terms for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; pull->Write(); } if (FitPar::Config().GetParB("EventManager")) { // Get list of inputs std::map fInputs = FitBase::EvtManager().GetInputs(); std::map::const_iterator iterInp; for (iterInp = fInputs.begin(); iterInp != fInputs.end(); iterInp++) { InputHandlerBase *input = (iterInp->second); input->GetFluxHistogram()->Write(); input->GetXSecHistogram()->Write(); input->GetEventHistogram()->Write(); } } }; //*************************************************** void JointFCN::SetFakeData(std::string fakeinput) { //*************************************************** NUIS_LOG(MIN, "Setting fake data from " << fakeinput); for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; exp->SetFakeDataValues(fakeinput); } return; } //*************************************************** void JointFCN::ThrowDataToy() { //*************************************************** for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; exp->ThrowDataToy(); } return; } //*************************************************** std::vector JointFCN::GetAllNames() { //*************************************************** // Vect of all likelihoods and total std::vector namevect; // Loop over samples first for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; // Get Likelihoods and push to vector namevect.push_back(exp->GetName()); } // Loop over pulls second for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; // Push back to vector namevect.push_back(pull->GetName()); } // Finally add the total namevect.push_back("total"); return namevect; } //*************************************************** std::vector JointFCN::GetAllLikelihoods() { //*************************************************** // Vect of all likelihoods and total std::vector likevect; double total_likelihood = 0.0; NUIS_LOG(MIN, "Likelihoods : "); // Loop over samples first for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; // Get Likelihoods and push to vector double singlelike = exp->GetLikelihood(); likevect.push_back(singlelike); total_likelihood += singlelike; // Print Out NUIS_LOG(MIN, "-> " << std::left << std::setw(40) << exp->GetName() << " : " << singlelike); } // Loop over pulls second for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; // Push back to vector double singlelike = pull->GetLikelihood(); likevect.push_back(singlelike); total_likelihood += singlelike; // Print Out NUIS_LOG(MIN, "-> " << std::left << std::setw(40) << pull->GetName() << " : " << singlelike); } // Finally add the total likelihood likevect.push_back(total_likelihood); return likevect; } //*************************************************** std::vector JointFCN::GetAllNDOF() { //*************************************************** // Vect of all ndof and total std::vector ndofvect; int total_ndof = 0; // Loop over samples first for (MeasListConstIter iter = fSamples.begin(); iter != fSamples.end(); iter++) { MeasurementBase *exp = *iter; // Get Likelihoods and push to vector int singlendof = exp->GetNDOF(); ndofvect.push_back(singlendof); total_ndof += singlendof; } // Loop over pulls second for (PullListConstIter iter = fPulls.begin(); iter != fPulls.end(); iter++) { ParamPull *pull = *iter; // Push back to vector int singlendof = pull->GetNDOF(); ndofvect.push_back(singlendof); total_ndof += singlendof; } // Finally add the total ndof ndofvect.push_back(total_ndof); return ndofvect; } diff --git a/src/FCN/SAMPLEREADME b/src/FCN/SAMPLEREADME deleted file mode 100644 index 34b52f7..0000000 --- a/src/FCN/SAMPLEREADME +++ /dev/null @@ -1,3 +0,0 @@ -./minimizerFCN.cxx -./nodeFCN.cxx -./splinesFCN.cxx diff --git a/src/FCN/SampleList.cxx b/src/FCN/SampleList.cxx index 7b9b043..a28a428 100644 --- a/src/FCN/SampleList.cxx +++ b/src/FCN/SampleList.cxx @@ -1,1549 +1,1548 @@ #include "SampleList.h" #ifndef __NO_ANL__ #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_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" #include "ANL_CC1ppip_Evt_1DWNpi_nu.h" #include "ANL_CC1ppip_Evt_1DWNmu_nu.h" #include "ANL_CC1ppip_Evt_1DWmupi_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" #include "ANL_CC1npip_Evt_1DWNpi_nu.h" #include "ANL_CC1npip_Evt_1DWNmu_nu.h" #include "ANL_CC1npip_Evt_1DWmupi_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" #include "ANL_CC1pi0_Evt_1DWNpi_nu.h" #include "ANL_CC1pi0_Evt_1DWNmu_nu.h" #include "ANL_CC1pi0_Evt_1DWmupi_nu.h" // ANL NC1npip (mm, exotic!) #include "ANL_NC1npip_Evt_1Dppi_nu.h" // ANL NC1ppim (mm, exotic!) #include "ANL_NC1ppim_Evt_1DcosmuStar_nu.h" #include "ANL_NC1ppim_XSec_1DEnu_nu.h" // ANL CC2pi 1pim1pip (mm, even more exotic!) #include "ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dppim_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dppip_nu.h" #include "ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu.h" #include "ANL_CC2pi_1pim1pip_XSec_1DEnu_nu.h" // ANL CC2pi 1pip1pip (mm, even more exotic!) #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" #include "ANL_CC2pi_1pip1pip_XSec_1DEnu_nu.h" // ANL CC2pi 1pip1pi0 (mm, even more exotic!) #include "ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu.h" #include "ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu.h" #include "ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu.h" #endif #ifndef __NO_ArgoNeuT__ // ArgoNeuT CC1Pi #include "ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dpmu_nu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu.h" #include "ArgoNeuT_CC1Pi_XSec_1Dthetapi_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" #endif #ifndef __NO_BNL__ // 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_1DcosthAdler_nu.h" #include "BNL_CC1ppip_Evt_1Dphi_nu.h" #include "BNL_CC1ppip_XSec_1DEnu_nu.h" #include "BNL_CC1ppip_Evt_1DWNpi_nu.h" #include "BNL_CC1ppip_Evt_1DWNmu_nu.h" #include "BNL_CC1ppip_Evt_1DWmupi_nu.h" // BNL CC1npip #include "BNL_CC1npip_Evt_1DQ2_nu.h" #include "BNL_CC1npip_XSec_1DEnu_nu.h" #include "BNL_CC1npip_Evt_1DWNpi_nu.h" #include "BNL_CC1npip_Evt_1DWNmu_nu.h" #include "BNL_CC1npip_Evt_1DWmupi_nu.h" // BNL CC1pi0 #include "BNL_CC1pi0_Evt_1DQ2_nu.h" #include "BNL_CC1pi0_XSec_1DEnu_nu.h" #include "BNL_CC1pi0_Evt_1DWNpi_nu.h" #include "BNL_CC1pi0_Evt_1DWNmu_nu.h" #include "BNL_CC1pi0_Evt_1DWmupi_nu.h" // BNL multipi #include "BNL_CC2pi_1pim1pip_XSec_1DEnu_nu.cxx" #include "BNL_CC3pi_1pim2pip_XSec_1DEnu_nu.cxx" #include "BNL_CC4pi_2pim2pip_XSec_1DEnu_nu.cxx" #include "BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu.cxx" #include "BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu.cxx" #endif #ifndef __NO_FNAL__ // 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" #endif #ifndef __NO_BEBC__ // 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" #endif #ifndef __NO_GGM__ // GGM CC1ppip #include "GGM_CC1ppip_Evt_1DQ2_nu.h" #include "GGM_CC1ppip_XSec_1DEnu_nu.h" #endif #ifndef __NO_MiniBooNE__ // MiniBooNE CCQE #include "MiniBooNE_CCQE_XSec_1DEnu_nu.h" #include "MiniBooNE_CCQE_XSec_1DQ2_antinu.h" #include "MiniBooNE_CCQE_XSec_1DQ2_nu.h" #include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h" #include "MiniBooNE_CCQE_XSec_2DTcos_nu.h" // 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" #include "MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h" #include "MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h" #include "MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h" #include "MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h" // MiniBooNE NC1pi0 //#include "MiniBooNE_NCpi0_XSec_1Dppi0_nu.h" // MiniBooNE NCEL #include "MiniBooNE_NCEL_XSec_Treco_nu.h" #endif #ifndef __NO_MicroBooNE__ #include "MicroBooNE_CCInc_XSec_2DPcos_nu.h" #endif #ifndef __NO_MINERvA__ // 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" // 2018 MINERvA CC0pi STV #include "MINERvA_CC0pinp_STV_XSec_1D_nu.h" // 2018 MINERvA CC0pi 2D #include "MINERvA_CC0pi_XSec_1D_2018_nu.h" #include "MINERvA_CC0pi_XSec_2D_nu.h" // #include "MINERvA_CC0pi_XSec_3DptpzTp_nu.h" // 2018 MINERvA CC0pi 2D antinu #include "MINERvA_CC0pi_XSec_2D_antinu.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" // 2017 data update #include "MINERvA_CC1pip_XSec_1D_2017Update.h" // MINERvA CCNpi+ #include "MINERvA_CCNpip_XSec_1DEnu_nu.h" #include "MINERvA_CCNpip_XSec_1DQ2_nu.h" #include "MINERvA_CCNpip_XSec_1DTpi_nu.h" #include "MINERvA_CCNpip_XSec_1Dpmu_nu.h" #include "MINERvA_CCNpip_XSec_1Dth_nu.h" #include "MINERvA_CCNpip_XSec_1Dthmu_nu.h" // MINERvA CC1pi0 #include "MINERvA_CC1pi0_XSec_1DEnu_antinu.h" #include "MINERvA_CC1pi0_XSec_1DQ2_antinu.h" #include "MINERvA_CC1pi0_XSec_1DTpi0_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dpmu_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dppi0_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dth_antinu.h" #include "MINERvA_CC1pi0_XSec_1Dthmu_antinu.h" // MINERvA CC1pi0 neutrino #include "MINERvA_CC1pi0_XSec_1D_nu.h" // MINERvA CCINC #include "MINERvA_CCinc_XSec_1DEnu_ratio.h" #include "MINERvA_CCinc_XSec_1Dx_ratio.h" #include "MINERvA_CCinc_XSec_2DEavq3_nu.h" // MINERvA CCDIS #include "MINERvA_CCDIS_XSec_1DEnu_ratio.h" #include "MINERvA_CCDIS_XSec_1Dx_ratio.h" // MINERvA CCCOH pion #include "MINERvA_CCCOHPI_XSec_1DEnu_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_nu.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_nu.h" #include "MINERvA_CCCOHPI_XSec_1Dth_nu.h" #include "MINERvA_CCCOHPI_XSec_joint.h" #include "MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h" #include "MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h" #endif #ifndef __NO_T2K__ // T2K CC0pi 2016 #include "T2K_CC0pi_XSec_2DPcos_nu_I.h" #include "T2K_CC0pi_XSec_2DPcos_nu_II.h" // T2K CC0pi 2020 arXiv:1908.10249 #include "T2K_CC0pi_XSec_H2O_2DPcos_anu.h" // T2K CC0pi 2020 arXiv:2004.05434 #include "T2K_NuMu_CC0pi_OC_XSec_2DPcos.h" #include "T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.h" // T2K CC0pi 2020 arXiv:2002.09323 #include "T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h" #include "T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.h" // T2K CC-inclusive with full acceptance 2018 #include "T2K_CCinc_XSec_2DPcos_nu_nonuniform.h" // T2K nue CC-inclusive 2019 #include "T2K_nueCCinc_XSec_1Dpe.h" #include "T2K_nueCCinc_XSec_1Dthe.h" #include "T2K_nueCCinc_XSec_1Dpe_joint.h" #include "T2K_nueCCinc_XSec_1Dthe_joint.h" #include "T2K_nueCCinc_XSec_joint.h" // T2K STV CC0pi 2018 #include "T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h" #include "T2K_CC0pinp_STV_XSec_1Ddat_nu.h" #include "T2K_CC0pinp_STV_XSec_1Ddphit_nu.h" #include "T2K_CC0pinp_STV_XSec_1Ddpt_nu.h" #include "T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h" #include "T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h" #include "T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h" // T2K CC1pi+ on CH #include "T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.h" #include "T2K_CC1pip_CH_XSec_1DCosThAdler_nu.h" #include "T2K_CC1pip_CH_XSec_1DQ2_nu.h" #include "T2K_CC1pip_CH_XSec_1Dppi_nu.h" #include "T2K_CC1pip_CH_XSec_1Dthmupi_nu.h" #include "T2K_CC1pip_CH_XSec_1Dthpi_nu.h" #include "T2K_CC1pip_CH_XSec_2Dpmucosmu_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" // add header here #endif #ifndef __NO_SciBooNE__ // SciBooNE COH studies #include "SciBooNE_CCCOH_1TRK_1DQ2_nu.h" #include "SciBooNE_CCCOH_1TRK_1Dpmu_nu.h" #include "SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h" #include "SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h" #include "SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h" #include "SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h" #include "SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h" #include "SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h" #include "SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h" #include "SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h" #include "SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h" #include "SciBooNE_CCCOH_MuPr_1DQ2_nu.h" #include "SciBooNE_CCCOH_MuPr_1Dpmu_nu.h" #include "SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h" #include "SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h" #include "SciBooNE_CCCOH_STOP_NTrks_nu.h" #include "SciBooNE_CCInc_XSec_1DEnu_nu.h" #endif #ifndef __NO_K2K__ // K2K NC1pi0 #include "K2K_NC1pi0_Evt_1Dppi0_nu.h" #endif // MC Studies #include "ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h" #include "ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h" #include "MCStudy_CCQEHistograms.h" #include "GenericFlux_Tester.h" #include "GenericFlux_Vectors.h" #include "ElectronFlux_FlatTree.h" #include "ElectronScattering_DurhamData.h" #include "MCStudy_KaonPreSelection.h" #include "MCStudy_MuonValidation.h" #include "OfficialNIWGPlots.h" #include "T2K2017_FakeData.h" #include "SigmaEnuHists.h" #include "Simple_Osc.h" #include "Smear_SVDUnfold_Propagation_Osc.h" #include "FitWeight.h" #include "NuisConfig.h" #include "NuisKey.h" #ifdef __USE_DYNSAMPLES__ #include "TRegexp.h" #include // linux #include DynamicSampleFactory::DynamicSampleFactory() : NSamples(0), NManifests(0) { LoadPlugins(); NUIS_LOG(FIT, "Loaded " << NSamples << " from " << NManifests << " shared object libraries."); } DynamicSampleFactory *DynamicSampleFactory::glblDSF = NULL; DynamicSampleFactory::PluginManifest::~PluginManifest() { for (size_t i_it = 0; i_it < Instances.size(); ++i_it) { (*(DSF_DestroySample))(Instances[i_it]); } } std::string EnsureTrailingSlash(std::string const &inp) { if (!inp.length()) { return "/"; } if (inp[inp.length() - 1] == '/') { return inp; } return inp + "/"; } void DynamicSampleFactory::LoadPlugins() { std::vector SearchDirectories; if (Config::HasPar("dynamic_sample.path")) { SearchDirectories = GeneralUtils::ParseToStr(Config::GetParS("dynamic_sample.path"), ":"); } char const *envPath = getenv("NUISANCE_DS_PATH"); if (envPath) { std::vector envPaths = GeneralUtils::ParseToStr(envPath, ":"); for (size_t ep_it = 0; ep_it < envPaths.size(); ++ep_it) { SearchDirectories.push_back(envPaths[ep_it]); } } if (!SearchDirectories.size()) { char const *pwdPath = getenv("PWD"); if (pwdPath) { SearchDirectories.push_back(pwdPath); } } for (size_t sp_it = 0; sp_it < SearchDirectories.size(); ++sp_it) { std::string dirpath = EnsureTrailingSlash(SearchDirectories[sp_it]); NUIS_LOG(FIT, "Searching for dynamic sample manifests in: " << dirpath); Ssiz_t len = 0; DIR *dir; struct dirent *ent; dir = opendir(dirpath.c_str()); if (dir != NULL) { TRegexp matchExp("*.so", true); while ((ent = readdir(dir)) != NULL) { if (matchExp.Index(TString(ent->d_name), &len) != Ssiz_t(-1)) { NUIS_LOG(FIT, "\tFound shared object: " << ent->d_name << " checking for relevant methods..."); void *dlobj = dlopen((dirpath + ent->d_name).c_str(), RTLD_NOW | RTLD_GLOBAL); char const *dlerr_cstr = dlerror(); std::string dlerr; if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tDL Load Error: " << dlerr); continue; } PluginManifest plgManif; plgManif.dllib = dlobj; plgManif.soloc = (dirpath + ent->d_name); plgManif.DSF_NSamples = reinterpret_cast(dlsym(dlobj, "DSF_NSamples")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_NSamples\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.DSF_GetSampleName = reinterpret_cast( dlsym(dlobj, "DSF_GetSampleName")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_GetSampleName\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.DSF_GetSample = reinterpret_cast( dlsym(dlobj, "DSF_GetSample")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_GetSample\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.DSF_DestroySample = reinterpret_cast( dlsym(dlobj, "DSF_DestroySample")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "Failed to load symbol \"DSF_DestroySample\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.NSamples = (*(plgManif.DSF_NSamples))(); NUIS_LOG(FIT, "\tSuccessfully loaded dynamic sample manifest: " << plgManif.soloc << ". Contains " << plgManif.NSamples << " samples."); for (size_t smp_it = 0; smp_it < plgManif.NSamples; ++smp_it) { char const *smp_name = (*(plgManif.DSF_GetSampleName))(smp_it); if (!smp_name) { NUIS_ABORT("Could not load sample " << smp_it << " / " << plgManif.NSamples << " from " << plgManif.soloc); } if (Samples.count(smp_name)) { NUIS_ERR(WRN, "Already loaded a sample named: \"" << smp_name << "\". cannot load duplciates. This " "sample will be skipped."); continue; } plgManif.SamplesProvided.push_back(smp_name); Samples[smp_name] = std::make_pair(plgManif.soloc, smp_it); NUIS_LOG(FIT, "\t\t" << smp_name); } if (plgManif.SamplesProvided.size()) { Manifests[plgManif.soloc] = plgManif; NSamples += plgManif.SamplesProvided.size(); NManifests++; } else { dlclose(dlobj); } } } closedir(dir); } else { NUIS_ERR(WRN, "Tried to open non-existant directory."); } } } DynamicSampleFactory &DynamicSampleFactory::Get() { if (!glblDSF) { glblDSF = new DynamicSampleFactory(); } return *glblDSF; } void DynamicSampleFactory::Print() { std::map > ManifestSamples; for (std::map >::iterator smp_it = Samples.begin(); smp_it != Samples.end(); ++smp_it) { if (!ManifestSamples.count(smp_it->second.first)) { ManifestSamples[smp_it->second.first] = std::vector(); } ManifestSamples[smp_it->second.first].push_back(smp_it->first); } NUIS_LOG(FIT, "Dynamic sample manifest: "); for (std::map >::iterator m_it = ManifestSamples.begin(); m_it != ManifestSamples.end(); ++m_it) { NUIS_LOG(FIT, "\tLibrary " << m_it->first << " contains: "); for (size_t s_it = 0; s_it < m_it->second.size(); ++s_it) { NUIS_LOG(FIT, "\t\t" << m_it->second[s_it]); } } } bool DynamicSampleFactory::HasSample(std::string const &name) { return Samples.count(name); } bool DynamicSampleFactory::HasSample(nuiskey &samplekey) { return HasSample(samplekey.GetS("name")); } MeasurementBase *DynamicSampleFactory::CreateSample(nuiskey &samplekey) { if (!HasSample(samplekey)) { NUIS_ERR(WRN, "Asked to load unknown sample: \"" << samplekey.GetS("name") << "\"."); return NULL; } std::pair sample = Samples[samplekey.GetS("name")]; NUIS_LOG(SAM, "\tLoading sample " << sample.second << " from " << sample.first); return (*(Manifests[sample.first].DSF_GetSample))(sample.second, &samplekey); } DynamicSampleFactory::~DynamicSampleFactory() { Manifests.clear(); } #endif //! 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. MeasurementBase *CreateSample(std::string name, std::string file, std::string type, std::string fkdt, FitWeight *rw) { nuiskey samplekey = Config::CreateKey("sample"); samplekey.Set("name", name); samplekey.Set("input", file); samplekey.Set("type", type); return CreateSample(samplekey); } MeasurementBase *CreateSample(nuiskey samplekey) { #ifdef __USE_DYNSAMPLES__ if (DynamicSampleFactory::Get().HasSample(samplekey)) { NUIS_LOG(SAM, "Instantiating dynamic sample..."); MeasurementBase *ds = DynamicSampleFactory::Get().CreateSample(samplekey); if (ds) { NUIS_LOG(SAM, "Done."); return ds; } NUIS_ABORT("Failed to instantiate dynamic sample."); } #endif FitWeight *rw = FitBase::GetRW(); std::string name = samplekey.GetS("name"); std::string file = samplekey.GetS("input"); std::string type = samplekey.GetS("type"); std::string fkdt = ""; /* ANL CCQE Samples */ #ifndef __NO_ANL__ if (!name.compare("ANL_CCQE_XSec_1DEnu_nu") || !name.compare("ANL_CCQE_XSec_1DEnu_nu_PRD26") || !name.compare("ANL_CCQE_XSec_1DEnu_nu_PRL31") || !name.compare("ANL_CCQE_XSec_1DEnu_nu_PRD16")) { return (new ANL_CCQE_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CCQE_Evt_1DQ2_nu") || !name.compare("ANL_CCQE_Evt_1DQ2_nu_PRL31") || !name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD26") || !name.compare("ANL_CCQE_Evt_1DQ2_nu_PRD16")) { return (new ANL_CCQE_Evt_1DQ2_nu(samplekey)); /* ANL CC1ppip samples */ } else if (!name.compare("ANL_CC1ppip_XSec_1DEnu_nu") || !name.compare("ANL_CC1ppip_XSec_1DEnu_nu_W14Cut") || !name.compare("ANL_CC1ppip_XSec_1DEnu_nu_Uncorr") || !name.compare("ANL_CC1ppip_XSec_1DEnu_nu_W14Cut_Uncorr") || !name.compare("ANL_CC1ppip_XSec_1DEnu_nu_W16Cut_Uncorr")) { return (new ANL_CC1ppip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_XSec_1DQ2_nu")) { return (new ANL_CC1ppip_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1DQ2_nu") || !name.compare("ANL_CC1ppip_Evt_1DQ2_nu_W14Cut")) { return (new ANL_CC1ppip_Evt_1DQ2_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1Dppi_nu")) { return (new ANL_CC1ppip_Evt_1Dppi_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1Dthpr_nu")) { return (new ANL_CC1ppip_Evt_1Dthpr_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1DcosmuStar_nu")) { return (new ANL_CC1ppip_Evt_1DcosmuStar_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1DcosthAdler_nu")) { return (new ANL_CC1ppip_Evt_1DcosthAdler_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1Dphi_nu")) { return (new ANL_CC1ppip_Evt_1Dphi_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1DWNpi_nu")) { return (new ANL_CC1ppip_Evt_1DWNpi_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1DWNmu_nu")) { return (new ANL_CC1ppip_Evt_1DWNmu_nu(samplekey)); } else if (!name.compare("ANL_CC1ppip_Evt_1DWmupi_nu")) { return (new ANL_CC1ppip_Evt_1DWmupi_nu(samplekey)); /* ANL CC1npip sample */ } else if (!name.compare("ANL_CC1npip_XSec_1DEnu_nu") || !name.compare("ANL_CC1npip_XSec_1DEnu_nu_W14Cut") || !name.compare("ANL_CC1npip_XSec_1DEnu_nu_Uncorr") || !name.compare("ANL_CC1npip_XSec_1DEnu_nu_W14Cut_Uncorr") || !name.compare("ANL_CC1npip_XSec_1DEnu_nu_W16Cut_Uncorr")) { return (new ANL_CC1npip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CC1npip_Evt_1DQ2_nu") || !name.compare("ANL_CC1npip_Evt_1DQ2_nu_W14Cut")) { return (new ANL_CC1npip_Evt_1DQ2_nu(samplekey)); } else if (!name.compare("ANL_CC1npip_Evt_1Dppi_nu")) { return (new ANL_CC1npip_Evt_1Dppi_nu(samplekey)); } else if (!name.compare("ANL_CC1npip_Evt_1DcosmuStar_nu")) { return (new ANL_CC1npip_Evt_1DcosmuStar_nu(samplekey)); } else if (!name.compare("ANL_CC1npip_Evt_1DWNpi_nu")) { return (new ANL_CC1npip_Evt_1DWNpi_nu(samplekey)); } else if (!name.compare("ANL_CC1npip_Evt_1DWNmu_nu")) { return (new ANL_CC1npip_Evt_1DWNmu_nu(samplekey)); } else if (!name.compare("ANL_CC1npip_Evt_1DWmupi_nu")) { return (new ANL_CC1npip_Evt_1DWmupi_nu(samplekey)); /* ANL CC1pi0 sample */ } else if (!name.compare("ANL_CC1pi0_XSec_1DEnu_nu") || !name.compare("ANL_CC1pi0_XSec_1DEnu_nu_W14Cut") || !name.compare("ANL_CC1pi0_XSec_1DEnu_nu_Uncorr") || !name.compare("ANL_CC1pi0_XSec_1DEnu_nu_W14Cut_Uncorr") || !name.compare("ANL_CC1pi0_XSec_1DEnu_nu_W16Cut_Uncorr")) { return (new ANL_CC1pi0_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CC1pi0_Evt_1DQ2_nu") || !name.compare("ANL_CC1pi0_Evt_1DQ2_nu_W14Cut")) { return (new ANL_CC1pi0_Evt_1DQ2_nu(samplekey)); } else if (!name.compare("ANL_CC1pi0_Evt_1DcosmuStar_nu")) { return (new ANL_CC1pi0_Evt_1DcosmuStar_nu(samplekey)); } else if (!name.compare("ANL_CC1pi0_Evt_1DWNpi_nu")) { return (new ANL_CC1pi0_Evt_1DWNpi_nu(samplekey)); } else if (!name.compare("ANL_CC1pi0_Evt_1DWNmu_nu")) { return (new ANL_CC1pi0_Evt_1DWNmu_nu(samplekey)); } else if (!name.compare("ANL_CC1pi0_Evt_1DWmupi_nu")) { return (new ANL_CC1pi0_Evt_1DWmupi_nu(samplekey)); /* ANL NC1npip sample */ } else if (!name.compare("ANL_NC1npip_Evt_1Dppi_nu")) { return (new ANL_NC1npip_Evt_1Dppi_nu(samplekey)); /* ANL NC1ppim sample */ } else if (!name.compare("ANL_NC1ppim_XSec_1DEnu_nu")) { return (new ANL_NC1ppim_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_NC1ppim_Evt_1DcosmuStar_nu")) { return (new ANL_NC1ppim_Evt_1DcosmuStar_nu(samplekey)); /* ANL CC2pi sample */ } else if (!name.compare("ANL_CC2pi_1pim1pip_XSec_1DEnu_nu")) { return (new ANL_CC2pi_1pim1pip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu")) { return (new ANL_CC2pi_1pim1pip_Evt_1Dpmu_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dppip_nu")) { return (new ANL_CC2pi_1pim1pip_Evt_1Dppip_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dppim_nu")) { return (new ANL_CC2pi_1pim1pip_Evt_1Dppim_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu")) { return (new ANL_CC2pi_1pim1pip_Evt_1Dpprot_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pip_XSec_1DEnu_nu")) { return (new ANL_CC2pi_1pip1pip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu")) { return (new ANL_CC2pi_1pip1pip_Evt_1Dpmu_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu")) { return (new ANL_CC2pi_1pip1pip_Evt_1Dpneut_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu")) { return (new ANL_CC2pi_1pip1pip_Evt_1DppipHigh_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu")) { return (new ANL_CC2pi_1pip1pip_Evt_1DppipLow_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu")) { return (new ANL_CC2pi_1pip1pi0_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu")) { return (new ANL_CC2pi_1pip1pi0_Evt_1Dpmu_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu")) { return (new ANL_CC2pi_1pip1pi0_Evt_1Dppip_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu")) { return (new ANL_CC2pi_1pip1pi0_Evt_1Dppi0_nu(samplekey)); } else if (!name.compare("ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu")) { return (new ANL_CC2pi_1pip1pi0_Evt_1Dpprot_nu(samplekey)); /* ArgoNeut Samples */ } else #endif #ifndef __NO_ArgoNeuT__ if (!name.compare("ArgoNeuT_CCInc_XSec_1Dpmu_antinu")) { return (new ArgoNeuT_CCInc_XSec_1Dpmu_antinu(samplekey)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dpmu_nu")) { return (new ArgoNeuT_CCInc_XSec_1Dpmu_nu(samplekey)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dthetamu_antinu")) { return (new ArgoNeuT_CCInc_XSec_1Dthetamu_antinu(samplekey)); } else if (!name.compare("ArgoNeuT_CCInc_XSec_1Dthetamu_nu")) { return (new ArgoNeuT_CCInc_XSec_1Dthetamu_nu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dpmu_nu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dpmu_nu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dthetamu_nu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dthetapi_nu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dthetamupi_nu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dpmu_antinu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dthetamu_antinu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dthetapi_antinu(samplekey)); } else if (!name.compare("ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu")) { return (new ArgoNeuT_CC1Pi_XSec_1Dthetamupi_antinu(samplekey)); /* BNL Samples */ } else #endif #ifndef __NO_BNL__ if (!name.compare("BNL_CCQE_XSec_1DEnu_nu")) { return (new BNL_CCQE_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CCQE_Evt_1DQ2_nu")) { return (new BNL_CCQE_Evt_1DQ2_nu(samplekey)); /* BNL CC1ppip samples */ } else if (!name.compare("BNL_CC1ppip_XSec_1DEnu_nu") || !name.compare("BNL_CC1ppip_XSec_1DEnu_nu_Uncorr") || !name.compare("BNL_CC1ppip_XSec_1DEnu_nu_W14Cut") || !name.compare("BNL_CC1ppip_XSec_1DEnu_nu_W14Cut_Uncorr")) { return (new BNL_CC1ppip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CC1ppip_Evt_1DQ2_nu") || !name.compare("BNL_CC1ppip_Evt_1DQ2_nu_W14Cut")) { return (new BNL_CC1ppip_Evt_1DQ2_nu(samplekey)); } else if (!name.compare("BNL_CC1ppip_Evt_1DcosthAdler_nu")) { return (new BNL_CC1ppip_Evt_1DcosthAdler_nu(samplekey)); } else if (!name.compare("BNL_CC1ppip_Evt_1Dphi_nu")) { return (new BNL_CC1ppip_Evt_1Dphi_nu(samplekey)); } else if (!name.compare("BNL_CC1ppip_Evt_1DWNpi_nu")) { return (new BNL_CC1ppip_Evt_1DWNpi_nu(samplekey)); } else if (!name.compare("BNL_CC1ppip_Evt_1DWNmu_nu")) { return (new BNL_CC1ppip_Evt_1DWNmu_nu(samplekey)); } else if (!name.compare("BNL_CC1ppip_Evt_1DWmupi_nu")) { return (new BNL_CC1ppip_Evt_1DWmupi_nu(samplekey)); /* BNL CC1npip samples */ } else if (!name.compare("BNL_CC1npip_XSec_1DEnu_nu") || !name.compare("BNL_CC1npip_XSec_1DEnu_nu_Uncorr")) { return (new BNL_CC1npip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CC1npip_Evt_1DQ2_nu")) { return (new BNL_CC1npip_Evt_1DQ2_nu(samplekey)); } else if (!name.compare("BNL_CC1npip_Evt_1DWNpi_nu")) { return (new BNL_CC1npip_Evt_1DWNpi_nu(samplekey)); } else if (!name.compare("BNL_CC1npip_Evt_1DWNmu_nu")) { return (new BNL_CC1npip_Evt_1DWNmu_nu(samplekey)); } else if (!name.compare("BNL_CC1npip_Evt_1DWmupi_nu")) { return (new BNL_CC1npip_Evt_1DWmupi_nu(samplekey)); /* BNL CC1pi0 samples */ } else if (!name.compare("BNL_CC1pi0_XSec_1DEnu_nu")) { return (new BNL_CC1pi0_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CC1pi0_Evt_1DQ2_nu")) { return (new BNL_CC1pi0_Evt_1DQ2_nu(samplekey)); } else if (!name.compare("BNL_CC1pi0_Evt_1DWNpi_nu")) { return (new BNL_CC1pi0_Evt_1DWNpi_nu(samplekey)); } else if (!name.compare("BNL_CC1pi0_Evt_1DWNmu_nu")) { return (new BNL_CC1pi0_Evt_1DWNmu_nu(samplekey)); } else if (!name.compare("BNL_CC1pi0_Evt_1DWmupi_nu")) { return (new BNL_CC1pi0_Evt_1DWmupi_nu(samplekey)); /* BNL multi-pi */ } else if (!name.compare("BNL_CC2pi_1pim1pip_XSec_1DEnu_nu")) { return (new BNL_CC2pi_1pim1pip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CC3pi_1pim2pip_XSec_1DEnu_nu")) { return (new BNL_CC3pi_1pim2pip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CC4pi_2pim2pip_XSec_1DEnu_nu")) { return (new BNL_CC4pi_2pim2pip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu")) { return (new BNL_CC2pi_1pim1pip_Evt_1DWpippim_nu(samplekey)); - } else if(!name.compare("BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu")) { + } else if (!name.compare("BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu")) { return (new BNL_CC2pi_1pim1pip_Evt_1DWpippr_nu(samplekey)); /* FNAL Samples */ } else #endif #ifndef __NO_FNAL__ if (!name.compare("FNAL_CCQE_Evt_1DQ2_nu")) { return (new FNAL_CCQE_Evt_1DQ2_nu(samplekey)); /* FNAL CC1ppip */ } else if (!name.compare("FNAL_CC1ppip_XSec_1DEnu_nu")) { return (new FNAL_CC1ppip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("FNAL_CC1ppip_XSec_1DQ2_nu")) { return (new FNAL_CC1ppip_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("FNAL_CC1ppip_Evt_1DQ2_nu")) { return (new FNAL_CC1ppip_Evt_1DQ2_nu(samplekey)); /* FNAL CC1ppim */ } else if (!name.compare("FNAL_CC1ppim_XSec_1DEnu_antinu")) { return (new FNAL_CC1ppim_XSec_1DEnu_antinu(samplekey)); /* BEBC Samples */ } else #endif #ifndef __NO_BEBC__ if (!name.compare("BEBC_CCQE_XSec_1DQ2_nu")) { return (new BEBC_CCQE_XSec_1DQ2_nu(samplekey)); /* BEBC CC1ppip samples */ } else if (!name.compare("BEBC_CC1ppip_XSec_1DEnu_nu")) { return (new BEBC_CC1ppip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BEBC_CC1ppip_XSec_1DQ2_nu")) { return (new BEBC_CC1ppip_XSec_1DQ2_nu(samplekey)); /* BEBC CC1npip samples */ } else if (!name.compare("BEBC_CC1npip_XSec_1DEnu_nu")) { return (new BEBC_CC1npip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BEBC_CC1npip_XSec_1DQ2_nu")) { return (new BEBC_CC1npip_XSec_1DQ2_nu(samplekey)); /* BEBC CC1pi0 samples */ } else if (!name.compare("BEBC_CC1pi0_XSec_1DEnu_nu")) { return (new BEBC_CC1pi0_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("BEBC_CC1pi0_XSec_1DQ2_nu")) { return (new BEBC_CC1pi0_XSec_1DQ2_nu(samplekey)); /* BEBC CC1npim samples */ } else if (!name.compare("BEBC_CC1npim_XSec_1DEnu_antinu")) { return (new BEBC_CC1npim_XSec_1DEnu_antinu(samplekey)); } else if (!name.compare("BEBC_CC1npim_XSec_1DQ2_antinu")) { return (new BEBC_CC1npim_XSec_1DQ2_antinu(samplekey)); /* BEBC CC1ppim samples */ } else if (!name.compare("BEBC_CC1ppim_XSec_1DEnu_antinu")) { return (new BEBC_CC1ppim_XSec_1DEnu_antinu(samplekey)); } else if (!name.compare("BEBC_CC1ppim_XSec_1DQ2_antinu")) { return (new BEBC_CC1ppim_XSec_1DQ2_antinu(samplekey)); /* GGM CC1ppip samples */ } else #endif #ifndef __NO_GGM__ if (!name.compare("GGM_CC1ppip_XSec_1DEnu_nu")) { return (new GGM_CC1ppip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("GGM_CC1ppip_Evt_1DQ2_nu")) { return (new GGM_CC1ppip_Evt_1DQ2_nu(samplekey)); /* MiniBooNE Samples */ /* CCQE */ } else #endif #ifndef __NO_MiniBooNE__ if (!name.compare("MiniBooNE_CCQE_XSec_1DQ2_nu") || !name.compare("MiniBooNE_CCQELike_XSec_1DQ2_nu")) { return (new MiniBooNE_CCQE_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("MiniBooNE_CCQE_XSec_1DEnu_nu") || !name.compare("MiniBooNE_CCQELike_XSec_1DEnu_nu")) { return (new MiniBooNE_CCQE_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CCQE_XSec_1DQ2_antinu") || !name.compare("MiniBooNE_CCQELike_XSec_1DQ2_antinu") || !name.compare("MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu")) { return (new MiniBooNE_CCQE_XSec_1DQ2_antinu(samplekey)); } else if (!name.compare("MiniBooNE_CCQE_XSec_2DTcos_nu") || !name.compare("MiniBooNE_CCQELike_XSec_2DTcos_nu")) { return (new MiniBooNE_CCQE_XSec_2DTcos_nu(samplekey)); } else if (!name.compare("MiniBooNE_CCQE_XSec_2DTcos_antinu") || !name.compare("MiniBooNE_CCQELike_XSec_2DTcos_antinu")) { return (new MiniBooNE_CCQE_XSec_2DTcos_antinu(samplekey)); /* MiniBooNE CC1pi+ */ // 1D } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DEnu_nu")) { return (new MiniBooNE_CC1pip_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DQ2_nu")) { return (new MiniBooNE_CC1pip_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DTpi_nu")) { return (new MiniBooNE_CC1pip_XSec_1DTpi_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_1DTu_nu")) { return (new MiniBooNE_CC1pip_XSec_1DTu_nu(samplekey)); // 2D } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DQ2Enu_nu")) { return (new MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTpiCospi_nu")) { return (new MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTpiEnu_nu")) { return (new MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTuCosmu_nu")) { return (new MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pip_XSec_2DTuEnu_nu")) { return (new MiniBooNE_CC1pip_XSec_2DTuEnu_nu(samplekey)); /* MiniBooNE CC1pi0 */ } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DEnu_nu")) { return (new MiniBooNE_CC1pi0_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DQ2_nu")) { return (new MiniBooNE_CC1pi0_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1DTu_nu")) { return (new MiniBooNE_CC1pi0_XSec_1DTu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dcosmu_nu")) { return (new MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dcospi0_nu")) { return (new MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(samplekey)); } else if (!name.compare("MiniBooNE_CC1pi0_XSec_1Dppi0_nu")) { return (new MiniBooNE_CC1pi0_XSec_1Dppi0_nu(samplekey)); } else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu") || !name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_rhc")) { return (new MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu(samplekey)); } else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_nu") || !name.compare("MiniBooNE_NC1pi0_XSec_1Dcospi0_fhc")) { return (new MiniBooNE_NC1pi0_XSec_1Dcospi0_nu(samplekey)); } else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_antinu") || !name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_rhc")) { return (new MiniBooNE_NC1pi0_XSec_1Dppi0_antinu(samplekey)); } else if (!name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_nu") || !name.compare("MiniBooNE_NC1pi0_XSec_1Dppi0_fhc")) { return (new MiniBooNE_NC1pi0_XSec_1Dppi0_nu(samplekey)); /* MiniBooNE NCEL */ } else if (!name.compare("MiniBooNE_NCEL_XSec_Treco_nu")) { return (new MiniBooNE_NCEL_XSec_Treco_nu(samplekey)); } else #endif #ifndef __NO_MicroBooNE__ /* MicroBooNE Samples */ /* MicroBooNE CCinclusive */ if (!name.compare("MicroBooNE_CCInc_XSec_2DPcos_nu")) { return (new MicroBooNE_CCInc_XSec_2DPcos_nu(samplekey)); } else #endif #ifndef __NO_MINERvA__ /* MINERvA Samples */ 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")) { return (new MINERvA_CCQE_XSec_1DQ2_nu(samplekey)); } 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")) { return (new MINERvA_CCQE_XSec_1DQ2_antinu(samplekey)); } 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")) { return (new MINERvA_CCQE_XSec_1DQ2_joint(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DEe_nue")) { return (new MINERvA_CC0pi_XSec_1DEe_nue(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_nue")) { return (new MINERvA_CC0pi_XSec_1DQ2_nue(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DThetae_nue")) { return (new MINERvA_CC0pi_XSec_1DThetae_nue(samplekey)); } else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpmu_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Dthmu_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Dpprot_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Dthprot_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Dpnreco_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Ddalphat_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Ddpt_nu") || !name.compare("MINERvA_CC0pinp_STV_XSec_1Ddphit_nu")) { return (new MINERvA_CC0pinp_STV_XSec_1D_nu(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_nu_proton")) { return (new MINERvA_CC0pi_XSec_1DQ2_nu_proton(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtC_nu") || !name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtCH_nu") || !name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtFe_nu") || !name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtPb_nu")) { return (new MINERvA_CC0pi_XSec_1DQ2_Tgt_nu(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtRatioC_nu") || !name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtRatioFe_nu") || !name.compare("MINERvA_CC0pi_XSec_1DQ2_TgtRatioPb_nu")) { return (new MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu(samplekey)); // Dan Ruterbories measurements of late 2018 } else if (!name.compare("MINERvA_CC0pi_XSec_2Dptpz_nu")) { return (new MINERvA_CC0pi_XSec_2D_nu(samplekey)); // } else if (!name.compare("MINERvA_CC0pi_XSec_3DptpzTp_nu")) { // return (new MINERvA_CC0pi_XSec_3DptpzTp_nu(samplekey)); } else if (!name.compare("MINERvA_CC0pi_XSec_1Dpt_nu") || !name.compare("MINERvA_CC0pi_XSec_1Dpz_nu") || !name.compare("MINERvA_CC0pi_XSec_1DQ2QE_nu") || !name.compare("MINERvA_CC0pi_XSec_1DEnuQE_nu")) { return (new MINERvA_CC0pi_XSec_1D_2018_nu(samplekey)); // C. Patrick's early 2018 measurements } else if (!name.compare("MINERvA_CC0pi_XSec_2Dptpz_antinu") || !name.compare("MINERvA_CC0pi_XSec_2DQ2QEEnuQE_antinu") || !name.compare("MINERvA_CC0pi_XSec_2DQ2QEEnuTrue_antinu")) { return (new MINERvA_CC0pi_XSec_2D_antinu(samplekey)); /* CC1pi+ */ // DONE } else if (!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu") || !name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_20deg") || !name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_fluxcorr") || !name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_20deg_fluxcorr")) { return (new MINERvA_CC1pip_XSec_1DTpi_nu(samplekey)); // DONE } else if (!name.compare("MINERvA_CC1pip_XSec_1Dth_nu") || !name.compare("MINERvA_CC1pip_XSec_1Dth_nu_20deg") || !name.compare("MINERvA_CC1pip_XSec_1Dth_nu_fluxcorr") || !name.compare("MINERvA_CC1pip_XSec_1Dth_nu_20deg_fluxcorr")) { return (new MINERvA_CC1pip_XSec_1Dth_nu(samplekey)); } else if (!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_2017") || !name.compare("MINERvA_CC1pip_XSec_1Dth_nu_2017") || !name.compare("MINERvA_CC1pip_XSec_1Dpmu_nu_2017") || !name.compare("MINERvA_CC1pip_XSec_1Dthmu_nu_2017") || !name.compare("MINERvA_CC1pip_XSec_1DQ2_nu_2017") || !name.compare("MINERvA_CC1pip_XSec_1DEnu_nu_2017")) { return (new MINERvA_CC1pip_XSec_1D_2017Update(samplekey)); /* CCNpi+ */ } 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_2015_20deg") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015_fluxcorr") || !name.compare("MINERvA_CCNpip_XSec_1Dth_nu_2015_20deg_fluxcorr")) { return (new MINERvA_CCNpip_XSec_1Dth_nu(samplekey)); } 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_2015_20deg") || !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2015_fluxcorr") || - !name.compare( - "MINERvA_CCNpip_XSec_1DTpi_nu_2015_20deg_fluxcorr")) { + !name.compare("MINERvA_CCNpip_XSec_1DTpi_nu_2015_20deg_fluxcorr")) { return (new MINERvA_CCNpip_XSec_1DTpi_nu(samplekey)); } else if (!name.compare("MINERvA_CCNpip_XSec_1Dthmu_nu")) { return (new MINERvA_CCNpip_XSec_1Dthmu_nu(samplekey)); } else if (!name.compare("MINERvA_CCNpip_XSec_1Dpmu_nu")) { return (new MINERvA_CCNpip_XSec_1Dpmu_nu(samplekey)); } else if (!name.compare("MINERvA_CCNpip_XSec_1DQ2_nu")) { return (new MINERvA_CCNpip_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("MINERvA_CCNpip_XSec_1DEnu_nu")) { return (new MINERvA_CCNpip_XSec_1DEnu_nu(samplekey)); /* MINERvA CC1pi0 anti-nu */ // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu") || !name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2015") || !name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2016") || !name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_fluxcorr") || !name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2015_fluxcorr") || !name.compare("MINERvA_CC1pi0_XSec_1Dth_antinu_2016_fluxcorr")) { return (new MINERvA_CC1pi0_XSec_1Dth_antinu(samplekey)); } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dppi0_antinu") || !name.compare("MINERvA_CC1pi0_XSec_1Dppi0_antinu_fluxcorr")) { return (new MINERvA_CC1pi0_XSec_1Dppi0_antinu(samplekey)); } else if (!name.compare("MINERvA_CC1pi0_XSec_1DTpi0_antinu")) { return (new MINERvA_CC1pi0_XSec_1DTpi0_antinu(samplekey)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1DQ2_antinu")) { return (new MINERvA_CC1pi0_XSec_1DQ2_antinu(samplekey)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dthmu_antinu")) { return (new MINERvA_CC1pi0_XSec_1Dthmu_antinu(samplekey)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1Dpmu_antinu")) { return (new MINERvA_CC1pi0_XSec_1Dpmu_antinu(samplekey)); // Done } else if (!name.compare("MINERvA_CC1pi0_XSec_1DEnu_antinu")) { return (new MINERvA_CC1pi0_XSec_1DEnu_antinu(samplekey)); // MINERvA CC1pi0 nu } else if (!name.compare("MINERvA_CC1pi0_XSec_1DTpi_nu") || !name.compare("MINERvA_CC1pi0_XSec_1Dth_nu") || !name.compare("MINERvA_CC1pi0_XSec_1Dpmu_nu") || !name.compare("MINERvA_CC1pi0_XSec_1Dthmu_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DQ2_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DEnu_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DWexp_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DPPi0Mass_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DPPi0MassDelta_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DCosAdler_nu") || !name.compare("MINERvA_CC1pi0_XSec_1DPhiAdler_nu")) { return (new MINERvA_CC1pi0_XSec_1D_nu(samplekey)); /* CCINC */ } else if (!name.compare("MINERvA_CCinc_XSec_2DEavq3_nu")) { return (new MINERvA_CCinc_XSec_2DEavq3_nu(samplekey)); } 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")) { return (new MINERvA_CCinc_XSec_1Dx_ratio(samplekey)); } 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")) { return (new MINERvA_CCinc_XSec_1DEnu_ratio(samplekey)); /* CCDIS */ } else if (!name.compare("MINERvA_CCDIS_XSec_1Dx_ratio_C12_CH") || !name.compare("MINERvA_CCDIS_XSec_1Dx_ratio_Fe56_CH") || !name.compare("MINERvA_CCDIS_XSec_1Dx_ratio_Pb208_CH")) { return (new MINERvA_CCDIS_XSec_1Dx_ratio(samplekey)); } else if (!name.compare("MINERvA_CCDIS_XSec_1DEnu_ratio_C12_CH") || !name.compare("MINERvA_CCDIS_XSec_1DEnu_ratio_Fe56_CH") || !name.compare("MINERvA_CCDIS_XSec_1DEnu_ratio_Pb208_CH")) { return (new MINERvA_CCDIS_XSec_1DEnu_ratio(samplekey)); /* CC-COH */ } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_nu")) { return (new MINERvA_CCCOHPI_XSec_1DEnu_nu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_nu")) { return (new MINERvA_CCCOHPI_XSec_1DEpi_nu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_nu")) { return (new MINERvA_CCCOHPI_XSec_1Dth_nu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_nu")) { return (new MINERvA_CCCOHPI_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_antinu")) { return (new MINERvA_CCCOHPI_XSec_1DEnu_antinu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_antinu")) { return (new MINERvA_CCCOHPI_XSec_1DEpi_antinu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_antinu")) { return (new MINERvA_CCCOHPI_XSec_1Dth_antinu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_antinu")) { return (new MINERvA_CCCOHPI_XSec_1DQ2_antinu(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_joint")) { return (new MINERvA_CCCOHPI_XSec_joint(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_joint")) { return (new MINERvA_CCCOHPI_XSec_joint(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_joint")) { return (new MINERvA_CCCOHPI_XSec_joint(samplekey)); } else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_joint")) { return (new MINERvA_CCCOHPI_XSec_joint(samplekey)); /* T2K Samples */ } else #endif #ifndef __NO_T2K__ if (!name.compare("T2K_CC0pi_XSec_2DPcos_nu_I")) { return (new T2K_CC0pi_XSec_2DPcos_nu_I(samplekey)); } else if (!name.compare("T2K_CC0pi_XSec_2DPcos_nu_II")) { return (new T2K_CC0pi_XSec_2DPcos_nu_II(samplekey)); } else if (!name.compare("T2K_CCinc_XSec_2DPcos_nu_nonuniform")) { return (new T2K_CCinc_XSec_2DPcos_nu_nonuniform(samplekey)); } else if (!name.compare("T2K_CC0pi_XSec_H2O_2DPcos_anu")) { return (new T2K_CC0pi_XSec_H2O_2DPcos_anu(samplekey)); } else if (!name.compare("T2K_NuMu_CC0pi_O_XSec_2DPcos") || !name.compare("T2K_NuMu_CC0pi_C_XSec_2DPcos")) { return (new T2K_NuMu_CC0pi_OC_XSec_2DPcos(samplekey)); } else if (!name.compare("T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint")) { return (new T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint(samplekey)); } else if (!name.compare("T2K_NuMu_CC0pi_CH_XSec_2DPcos") || !name.compare("T2K_AntiNuMu_CC0pi_CH_XSec_2DPcos")) { return (new T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos(samplekey)); } else if (!name.compare("T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint")) { return (new T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint(samplekey)); } else if (!name.compare("T2K_nueCCinc_XSec_1Dpe_FHC") || !name.compare("T2K_nueCCinc_XSec_1Dpe_RHC") || !name.compare("T2K_nuebarCCinc_XSec_1Dpe_RHC")) { return (new T2K_nueCCinc_XSec_1Dpe(samplekey)); } else if (!name.compare("T2K_nueCCinc_XSec_1Dthe_FHC") || !name.compare("T2K_nueCCinc_XSec_1Dthe_RHC") || !name.compare("T2K_nuebarCCinc_XSec_1Dthe_RHC")) { return (new T2K_nueCCinc_XSec_1Dthe(samplekey)); } else if (!name.compare("T2K_nueCCinc_XSec_1Dpe_joint")) { return (new T2K_nueCCinc_XSec_1Dpe_joint(samplekey)); } else if (!name.compare("T2K_nueCCinc_XSec_1Dthe_joint")) { return (new T2K_nueCCinc_XSec_1Dthe_joint(samplekey)); } else if (!name.compare("T2K_nueCCinc_XSec_joint")) { return (new T2K_nueCCinc_XSec_joint(samplekey)); /* 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_2Dpmucosmu_nu")) { return (new T2K_CC1pip_CH_XSec_2Dpmucosmu_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dppi_nu")) { return (new T2K_CC1pip_CH_XSec_1Dppi_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthpi_nu")) { return (new T2K_CC1pip_CH_XSec_1Dthpi_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1Dthmupi_nu")) { return (new T2K_CC1pip_CH_XSec_1Dthmupi_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1DQ2_nu")) { return (new T2K_CC1pip_CH_XSec_1DQ2_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1DAdlerPhi_nu")) { return (new T2K_CC1pip_CH_XSec_1DAdlerPhi_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_CH_XSec_1DCosThAdler_nu")) { return (new T2K_CC1pip_CH_XSec_1DCosThAdler_nu(samplekey)); /* T2K CC1pi+ H2O samples */ } else if (!name.compare("T2K_CC1pip_H2O_XSec_1DEnuDelta_nu")) { return (new T2K_CC1pip_H2O_XSec_1DEnuDelta_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_H2O_XSec_1DEnuMB_nu")) { return (new T2K_CC1pip_H2O_XSec_1DEnuMB_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcosmu_nu")) { return (new T2K_CC1pip_H2O_XSec_1Dcosmu_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcosmupi_nu")) { return (new T2K_CC1pip_H2O_XSec_1Dcosmupi_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dcospi_nu")) { return (new T2K_CC1pip_H2O_XSec_1Dcospi_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dpmu_nu")) { return (new T2K_CC1pip_H2O_XSec_1Dpmu_nu(samplekey)); } else if (!name.compare("T2K_CC1pip_H2O_XSec_1Dppi_nu")) { return (new T2K_CC1pip_H2O_XSec_1Dppi_nu(samplekey)); /* T2K CC0pi + np CH samples */ } else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddpt_nu")) { return (new T2K_CC0pinp_STV_XSec_1Ddpt_nu(samplekey)); } else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddphit_nu")) { return (new T2K_CC0pinp_STV_XSec_1Ddphit_nu(samplekey)); } else if (!name.compare("T2K_CC0pinp_STV_XSec_1Ddat_nu")) { return (new T2K_CC0pinp_STV_XSec_1Ddat_nu(samplekey)); } else if (!name.compare("T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np") || !name.compare("T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p") || !name.compare("T2K_CC0piWithProtons_XSec_2018_multidif_0p") || !name.compare("T2K_CC0piWithProtons_XSec_2018_multidif_1p")) { return (new T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np(samplekey)); } else if (!name.compare("T2K_CC0pinp_ifk_XSec_3Dinfp_nu")) { return (new T2K_CC0pinp_ifk_XSec_3Dinfp_nu(samplekey)); } else if (!name.compare("T2K_CC0pinp_ifk_XSec_3Dinfa_nu")) { return (new T2K_CC0pinp_ifk_XSec_3Dinfa_nu(samplekey)); } else if (!name.compare("T2K_CC0pinp_ifk_XSec_3Dinfip_nu")) { return (new T2K_CC0pinp_ifk_XSec_3Dinfip_nu(samplekey)); // SciBooNE COH studies } else #endif #ifndef __NO_SciBooNE__ if (!name.compare("SciBooNE_CCCOH_STOP_NTrks_nu")) { return (new SciBooNE_CCCOH_STOP_NTrks_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_1TRK_1DQ2_nu")) { return (new SciBooNE_CCCOH_1TRK_1DQ2_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_1TRK_1Dpmu_nu")) { return (new SciBooNE_CCCOH_1TRK_1Dpmu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_1TRK_1Dthetamu_nu")) { return (new SciBooNE_CCCOH_1TRK_1Dthetamu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPr_1DQ2_nu")) { return (new SciBooNE_CCCOH_MuPr_1DQ2_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPr_1Dpmu_nu")) { return (new SciBooNE_CCCOH_MuPr_1Dpmu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPr_1Dthetamu_nu")) { return (new SciBooNE_CCCOH_MuPr_1Dthetamu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiVA_1DQ2_nu")) { return (new SciBooNE_CCCOH_MuPiVA_1DQ2_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiVA_1Dpmu_nu")) { return (new SciBooNE_CCCOH_MuPiVA_1Dpmu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu")) { return (new SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu")) { return (new SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu")) { return (new SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu")) { return (new SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu")) { return (new SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu")) { return (new SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu(samplekey)); } else if (!name.compare("SciBooNE_CCCOH_STOPFINAL_1DQ2_nu")) { return (new SciBooNE_CCCOH_STOPFINAL_1DQ2_nu(samplekey)); } else if (!name.compare("SciBooNE_CCInc_XSec_1DEnu_nu") || !name.compare("SciBooNE_CCInc_XSec_1DEnu_nu_NEUT") || !name.compare("SciBooNE_CCInc_XSec_1DEnu_nu_NUANCE")) { return (new SciBooNE_CCInc_XSec_1DEnu_nu(samplekey)); /* K2K Samples */ /* NC1pi0 */ } else #endif #ifndef __NO_K2K__ if (!name.compare("K2K_NC1pi0_Evt_1Dppi0_nu")) { return (new K2K_NC1pi0_Evt_1Dppi0_nu(samplekey)); /* Fake Studies */ } else #endif if (name.find("ExpMultDist_CCQE_XSec_1D") != std::string::npos && name.find("_FakeStudy") != std::string::npos) { return ( 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) { return ( new ExpMultDist_CCQE_XSec_2DVar_FakeStudy(name, file, rw, type, fkdt)); } else if (name.find("GenericFlux") != std::string::npos) { return (new GenericFlux_Tester(name, file, rw, type, fkdt)); } else if (name.find("GenericVectors") != std::string::npos) { return (new GenericFlux_Vectors(name, file, rw, type, fkdt)); } else if (!name.compare("T2K2017_FakeData")) { return (new T2K2017_FakeData(samplekey)); } else if (!name.compare("MCStudy_CCQE")) { return (new MCStudy_CCQEHistograms(name, file, rw, type, fkdt)); } else if (!name.compare("ElectronFlux_FlatTree")) { return (new ElectronFlux_FlatTree(name, file, rw, type, fkdt)); } else if (name.find("ElectronData_") != std::string::npos) { return new ElectronScattering_DurhamData(samplekey); } else if (name.find("MuonValidation_") != std::string::npos) { return (new MCStudy_MuonValidation(name, file, rw, type, fkdt)); } else if (!name.compare("NIWGOfficialPlots")) { return (new OfficialNIWGPlots(samplekey)); } else if ((name.find("SigmaEnuHists") != std::string::npos) || (name.find("SigmaEnuPerEHists") != std::string::npos)) { return (new SigmaEnuHists(samplekey)); } else if (!name.compare("Simple_Osc")) { return (new Simple_Osc(samplekey)); } else if (!name.compare("Smear_SVDUnfold_Propagation_Osc")) { return (new Smear_SVDUnfold_Propagation_Osc(samplekey)); } else { NUIS_ABORT("Error: No such sample: " << name << std::endl); } // Return NULL if no sample loaded. return NULL; } // namespace SampleUtils } // namespace SampleUtils diff --git a/src/FCN/SubMakefile.backup b/src/FCN/SubMakefile.backup deleted file mode 100755 index ceedc38..0000000 --- a/src/FCN/SubMakefile.backup +++ /dev/null @@ -1,25 +0,0 @@ -# Author: Callum Wilkinson - -SHELL = /bin/sh -NAME = all -MAKEFILE = Makefile - -# Include machine specific flags and locations (inc. files & libs) -# -include $(EXT_FIT)/make/Make.include - -PACKAGE = externalDataFit_base -DICTIONARY = $(EXT_FIT)/src/FitBase/_ROOT_DICT_ExternalDataFit_base -LIBNAME = libExternalDataFit_base -EXTRA_EXT_LIBS = - - -all : rootcint lib -install : install-inc install-lib - -# Include standard package makefile targets -# -include $(EXT_FIT)/make/Make.std-package-targets - -FORCE: - diff --git a/src/FCN/fullsamplelist.card b/src/FCN/fullsamplelist.card deleted file mode 100644 index 1f28ffe..0000000 --- a/src/FCN/fullsamplelist.card +++ /dev/null @@ -1,65 +0,0 @@ - -# ANL SAMPLES - -sample ANL_CCQE_XSec_1DEnu_nu -sample ANL_CCQE_XSec_1DQ2_nu - -# BNL Samples - -sample BNL_CCQE_XSec_1DEnu_nu -sample BNL_CCQE_Evt_1DQ2_nu - -# MiniBooNE Samples -sample MiniBooNE_CCQE_XSec_1DQ2_nu -sample MiniBooNE_CCQELike_XSec_1DQ2_nu -sample MiniBooNE_CCQE_XSec_1DQ2_antinu -sample MiniBooNE_CCQELike_XSec_1DQ2_antinu -sample MiniBooNE_CCQE_XSec_2DTcos_nu -sample MiniBooNE_CCQELike_XSec_2DTcos_nu -sample MiniBooNE_CCQE_XSec_2DTcos_antinu -sample MiniBooNE_CCQELike_XSec_2DTcos_antinu -sample MiniBooNE_CCpip_XSec_1DQ2_nu -sample MiniBooNE_CCpip_XSec_1DTpi_nu -sample MiniBooNE_CCpi0_XSec_1DQ2_nu -sample MiniBooNE_NCpi0_XSec_1Dppi0_nu -sample MiniBooNE_NCEL_XSec_Treco_nu - -# MINERvA Samples -sample MINERvA_CCQE_XSec_1DQ2_nu -sample MINERvA_CCQE_XSec_1DQ2_nu_20deg -sample MINERvA_CCQE_XSec_1DQ2_nu_newflux -sample MINERvA_CCQE_XSec_1DQ2_nu_20deg_newflux -sample MINERvA_CCQE_XSec_1DQ2_antinu -sample MINERvA_CCQE_XSec_1DQ2_antinu_20deg -sample MINERvA_CCQE_XSec_1DQ2_antinu_newflux -sample MINERvA_CCQE_XSec_1DQ2_antinu_20deg_newflux -sample MINERvA_CCQE_XSec_1DQ2_joint -sample MINERvA_CCQE_XSec_1DQ2_joint_20deg -sample MINERvA_CCQE_XSec_1DQ2_joint_20deg_newflux -sample MINERvA_CC0pi_XSec_1DEe_nue -sample MINERvA_CC0pi_XSec_1DQ2_nue -sample MINERvA_CC0pi_XSec_1DThetae_nue -sample MINERvA_CC0pi_XSec_1DQ2_nu_proton -sample MINERvA_CCinc_XSec_2DEavq3_nu - -# T2K Samples -sample T2K_CC0pi_XSec_2DPcos_nu - -# K2K Samples -sample K2K_CC0pi_XSec_1DCosThetaMu_nu_1trk -sample K2K_CC0pi_XSec_1DCosThetaMu_nu_2trkQE -sample K2K_CC0pi_XSec_1DCosThetaMu_nu_2trkNonQE -sample K2KI_CC0pi_XSec_1DQ2_nu_1trk -sample K2KI_CC0pi_XSec_1DQ2_nu_2trkQE -sample K2KIIa_CC0pi_XSec_1DQ2_nu_2trkNonQE -sample K2KIIa_CC0pi_XSec_1DQ2_nu_1trk -sample K2KIIa_CC0pi_XSec_1DQ2_nu_2trkQE -sample K2KIIa_CC0pi_XSec_1DQ2_nu_2trkNonQE -sample K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks -sample K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks -sample K2K_CC0pi_XSec_1DPmu_nu_Ntrks -sample K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks - -# Stat Samples - -sample parameter_pulls \ No newline at end of file diff --git a/src/FCN/sample_list.xml b/src/FCN/sample_list.xml deleted file mode 100644 index b793fa2..0000000 --- a/src/FCN/sample_list.xml +++ /dev/null @@ -1,426 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/FNAL/CMakeLists.txt b/src/FNAL/CMakeLists.txt index d5b2748..a1df2ea 100644 --- a/src/FNAL/CMakeLists.txt +++ b/src/FNAL/CMakeLists.txt @@ -1,55 +1,55 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES FNAL_CC1ppip_Evt_1DQ2_nu.cxx FNAL_CC1ppip_XSec_1DEnu_nu.cxx FNAL_CC1ppip_XSec_1DQ2_nu.cxx FNAL_CCQE_Evt_1DQ2_nu.cxx FNAL_CC1ppim_XSec_1DEnu_antinu.cxx ) set(HEADERFILES FNAL_CC1ppim_XSec_1DEnu_antinu.h FNAL_CC1ppip_Evt_1DQ2_nu.h FNAL_CC1ppip_XSec_1DEnu_nu.h FNAL_CC1ppip_XSec_1DQ2_nu.h FNAL_CCQE_Evt_1DQ2_nu.h ) set(LIBNAME expFNAL) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/FNAL) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FNAL/FNAL_CC1ppim_XSec_1DEnu_antinu.h b/src/FNAL/FNAL_CC1ppim_XSec_1DEnu_antinu.h index 9f32464..f686cd2 100644 --- a/src/FNAL/FNAL_CC1ppim_XSec_1DEnu_antinu.h +++ b/src/FNAL/FNAL_CC1ppim_XSec_1DEnu_antinu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FNAL_CC1PPIM_XSEC_1DENU_ANTINU_H_SEEN #define FNAL_CC1PPIM_XSEC_1DENU_ANTINU_H_SEEN #include "Measurement1D.h" class FNAL_CC1ppim_XSec_1DEnu_antinu : public Measurement1D { public: FNAL_CC1ppim_XSec_1DEnu_antinu(nuiskey samplekey); virtual ~FNAL_CC1ppim_XSec_1DEnu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx index 2e5edd6..81c37f8 100644 --- a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FNAL_CC1ppip_Evt_1DQ2_nu.h" //******************************************************************** FNAL_CC1ppip_Evt_1DQ2_nu::FNAL_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "FNAL_CC1ppip_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC1#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); //fSettings.SetAllowedTypes("EVT/DIAG", "EVT/DIAG"); fSettings.SetEnuRange(10.0, 100.0); fSettings.DefineAllowedTargets("D,H"); fIsDiag = true; fIsRawEvents = true; // plot information fSettings.SetTitle("FNAL_CC1ppip_Evt_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "FNAL/CC1pip_on_p/FNAL_cc1ppip_nEvent_Q2_w14_bin_edit.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = GetEventHistogram()->Integral("width")/(fNEvents+0.)*2./1.; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); } 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_Evt_1DQ2_nu.h b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.h index 6acf1fd..7eb0066 100644 --- a/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.h +++ b/src/FNAL/FNAL_CC1ppip_Evt_1DQ2_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FNAL_CC1PPIP_EVT_1DQ2_NU_H_SEEN #define FNAL_CC1PPIP_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" class FNAL_CC1ppip_Evt_1DQ2_nu : public Measurement1D { public: FNAL_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey); virtual ~FNAL_CC1ppip_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx index 8fdf7cb..2c3e84a 100644 --- a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,84 +1,84 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FNAL_CC1ppip_XSec_1DEnu_nu.h" //******************************************************************** FNAL_CC1ppip_XSec_1DEnu_nu::FNAL_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "FNAL_CC1ppip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/proton)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(10.0, 100.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("FNAL_CC1ppip_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "FNAL/CC1pip_on_p/fnal78-numu-p-to-mu-p-piplus-lowW_edges.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); } 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_1DEnu_nu.h b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.h index 0b3de02..c0557cb 100644 --- a/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.h +++ b/src/FNAL/FNAL_CC1ppip_XSec_1DEnu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FNAL_CC1PPIP_XSEC_1DENU_NU_H_SEEN #define FNAL_CC1PPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class FNAL_CC1ppip_XSec_1DEnu_nu : public Measurement1D { public: FNAL_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~FNAL_CC1ppip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx index e5128a4..225aadd 100644 --- a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx +++ b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FNAL_CC1ppip_XSec_1DQ2_nu.h" //******************************************************************** FNAL_CC1ppip_XSec_1DQ2_nu::FNAL_CC1ppip_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "FNAL_CC1ppip_XSec_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC1#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/proton)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(10.0, 100.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("FNAL_CC1ppip_XSec_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "FNAL/CC1pip_on_p/FNAL_cc1ppip_dsigdQ2_W14_edit.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = (GetEventHistogram()->Integral("width")/TotalIntegratedFlux("width"))*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); } 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_CC1ppip_XSec_1DQ2_nu.h b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.h index e642cf4..eec439d 100644 --- a/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.h +++ b/src/FNAL/FNAL_CC1ppip_XSec_1DQ2_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FNAL_CC1PPIP_XSEC_1DQ2_NU_H_SEEN #define FNAL_CC1PPIP_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class FNAL_CC1ppip_XSec_1DQ2_nu : public Measurement1D { public: FNAL_CC1ppip_XSec_1DQ2_nu(nuiskey samplekey); virtual ~FNAL_CC1ppip_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx index 717c981..a21596d 100755 --- a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx +++ b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.cxx @@ -1,146 +1,146 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FNAL_CCQE_Evt_1DQ2_nu.h" //******************************************************************** FNAL_CCQE_Evt_1DQ2_nu::FNAL_CCQE_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "FNAL_CCQE_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CCQE} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/Q2CORR/MASK"); fSettings.SetEnuRange(0.0, 600.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("FNAL #nu_mu CCQE"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "FNAL/FNAL_CCQE_Data_PRD29_436.root;FNAL_CCQE_Data_1DQ2"); // is Q2 Correction applied applyQ2correction = fSettings.Found("type", "Q2CORR"); if (applyQ2correction) { fSettings.SetS("q2correction_file", FitPar::GetDataBase() + "ANL/ANL_CCQE_Data_PRL31_844.root"); fSettings.SetS("q2correction_hist", "ANL_XSec_1DQ2_Correction"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = 1.0; // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Correction Histogram if (applyQ2correction) { // Correction Hist CorrectionHist = PlotUtils::GetTH1DFromFile( fSettings.GetS("q2correction_file"), fSettings.GetS("q2correction_hist") ); SetAutoProcessTH1(CorrectionHist, kCMD_Write); // Make uncorrected MC hist fMCHist_NoCorr = (TH1D*) fDataHist->Clone(); fMCHist_NoCorr->Reset(); fMCHist_NoCorr->SetNameTitle( (fName + "_NOCORR").c_str(), (fName + "_NOCORR").c_str()); SetAutoProcessTH1(fMCHist_NoCorr); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } //******************************************************************** void FNAL_CCQE_Evt_1DQ2_nu::FillEventVariables(FitEvent * event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; // Fill histogram with reconstructed Q2 Distribution fXVar = -999.9; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); fXVar = FitUtils::Q2QErec(Pmu, cos(ThetaMu), 0., true); GetQ2Box()->fQ2 = fXVar; return; }; //******************************************************************** bool FNAL_CCQE_Evt_1DQ2_nu::isSignal(FitEvent * event) { //******************************************************************** if (!SignalDef::isCCQE(event, 14, EnuMin, EnuMax)) return false; // Q2 cut if (GetQ2Box()->fQ2 <= 0) return false; return true; }; //******************************************************************** void FNAL_CCQE_Evt_1DQ2_nu::FillHistograms() { //******************************************************************** if (applyQ2correction) { fMCHist_NoCorr->Fill( GetQ2Box()->fQ2, Weight); if (GetQ2Box()->fQ2 < CorrectionHist->GetXaxis()->GetXmax() && GetQ2Box()->fQ2 > CorrectionHist->GetXaxis()->GetXmin()) Weight *= CorrectionHist->Interpolate(GetQ2Box()->fQ2); } Measurement1D::FillHistograms(); } //******************************************************************** void FNAL_CCQE_Evt_1DQ2_nu::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); // Flux unfold our extra histogram if (applyQ2correction) { if (fMCHist_NoCorr->Integral()) { fMCHist_NoCorr->Scale(fDataHist->Integral() / fMCHist_NoCorr->Integral()); } } } diff --git a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.h b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.h index 313ce65..bb3333b 100755 --- a/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.h +++ b/src/FNAL/FNAL_CCQE_Evt_1DQ2_nu.h @@ -1,63 +1,63 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FNAL_CCQE_Evt_1DQ2_NU_H_SEEN #define FNAL_CCQE_Evt_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "CustomVariableBoxes.h" //******************************************************************** class FNAL_CCQE_Evt_1DQ2_nu : public Measurement1D { //******************************************************************** public: FNAL_CCQE_Evt_1DQ2_nu(nuiskey samplekey); virtual ~FNAL_CCQE_Evt_1DQ2_nu() {}; /// \brief Get Q2 assuming QE void FillEventVariables(FitEvent *event); /// \brief Get True CCQE bool isSignal(FitEvent *event); /// \brief Fill main histograms and correction histograms void FillHistograms(); /// \brief scale the MC Hist and correction histograms void ScaleEvents(); /// \brief Use Q2 Box to save correction info inline Q2VariableBox1D* GetQ2Box(){ return static_cast(GetBox()); }; /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox* CreateBox(){ return new Q2VariableBox1D(); }; private: bool applyQ2correction; ///< Flag of whether deut correction applied TH1D* CorrectionHist; ///< Correction factor TH1D* fMCHist_NoCorr; ///< Uncorrected fMCHist double ThetaMu; double q2qe; }; #endif diff --git a/src/FitBase/CMakeLists.txt b/src/FitBase/CMakeLists.txt index 165b94e..16e313e 100644 --- a/src/FitBase/CMakeLists.txt +++ b/src/FitBase/CMakeLists.txt @@ -1,75 +1,75 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ParamPull.cxx EventManager.cxx Measurement1D.cxx Measurement2D.cxx JointMeas1D.cxx MeasurementBase.cxx TemplateMeas1D.cxx SampleSettings.cxx MeasurementVariableBox.cxx MeasurementVariableBox2D.cxx MeasurementVariableBox1D.cxx StandardStacks.cxx StackBase.cxx ) set(HEADERFILES ParamPull.h JointMeas1D.h Measurement2D.h EventManager.h MeasurementBase.h Measurement1D.h TemplateMeas1D.h SampleSettings.h MeasurementVariableBox.h MeasurementVariableBox2D.h MeasurementVariableBox1D.h CustomVariableBoxes.h StandardStacks.h StackBase.h ) set(LIBNAME FitBase) 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(${MINIMUM_INCLUDE_DIRECTORIES}) cmessage(DEBUG "FitBase includes: ${MINIMUM_INCLUDE_DIRECTORIES}") set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/FitBase) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/FitBase/EventManager.cxx b/src/FitBase/EventManager.cxx index 771a4ba..17341e1 100644 --- a/src/FitBase/EventManager.cxx +++ b/src/FitBase/EventManager.cxx @@ -1,140 +1,140 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "EventManager.h" EventManager* EventManager::m_evtmgrInstance = NULL; EventManager& EventManager::Get(void) { if (!m_evtmgrInstance) { m_evtmgrInstance = new EventManager; } return *m_evtmgrInstance; } FitWeight* EventManager::GetRW() { return fRW; }; InputHandlerBase* EventManager::GetInput(int infile) { return finputs[infile]; }; FitEvent* EventManager::GetEvent(int infile, int i) { /* finputs[infile]->ReadEvent(i); FitEvent* evtpt = finputs[infile]->GetEventPointer(); // If we don't need a full reweight if (!frwneeded[infile][i]) { evtpt->Weight = calc_rw[infile][i]; // if we do need a full reweight } else { evtpt->RWWeight = fRW->CalcWeight(evtpt); evtpt->Weight = evtpt->RWWeight * evtpt->InputWeight; calc_rw[infile][i] = evtpt->Weight; frwneeded[infile][i] = false; } */ return NULL; } double EventManager::GetEventWeight(int infile, int i) { /* if (!frwneeded[infile][i]) { return calc_rw[infile][i]; } finputs[infile]->GetTreeEntry(i); FitEvent* evtpt = finputs[infile]->GetEventPointer(); double Weight = fRW->CalcWeight(evtpt) * evtpt->InputWeight; calc_rw[infile][i] = Weight; frwneeded[infile][i] = false; */ double Weight = 1.0; return Weight; } std::map EventManager::GetInputs() { return finputs; } InputHandlerBase* EventManager::AddInput(std::string handle, std::string infile) { // Expect INPUTTYPE:FileLocation(s) std::vector file_descriptor = GeneralUtils::ParseToStr(infile, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << infile << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inpType = InputUtils::ParseInputType(file_descriptor[0]); int id = GetInputID(file_descriptor[1]); if ((uint)id != fid.size()) { NUIS_LOG(SAM,"Event manager already contains " << file_descriptor[1]); return finputs[id]; } fid[file_descriptor[1]] = id; finputs[id] = InputUtils::CreateInputHandler(handle, inpType, file_descriptor[1]); frwneeded[id] = std::vector(finputs[id]->GetNEvents(), true); calc_rw[id] = std::vector(finputs[id]->GetNEvents(), 0.0); NUIS_LOG(SAM,"Registered " << handle << " with EventManager."); return finputs[id]; } // Reset the weight flags // Should be called for every succesful event loop void EventManager::ResetWeightFlags() { /* // Loop over the inpts for (std::map::iterator iter = finputs.begin(); iter != finputs.end(); iter++) { int id = iter->first; frwneeded[id].clear(); // Reset so that all events need the reweight frwneeded[id] = std::vector(finputs[id]->GetNEvents(), true); } */ } EventManager::EventManager() { fRW = new FitWeight("FitWeight"); finputs.clear(); }; EventManager::~EventManager() { delete fRW; finputs.clear(); }; int EventManager::GetInputID(std::string infile) { if (fid.find(infile) == fid.end()) { return fid.size(); } return fid[infile]; } void EventManager::SetRW(FitWeight* rw){ fRW = rw; } diff --git a/src/FitBase/EventManager.h b/src/FitBase/EventManager.h index 0cc246f..7cf43c2 100644 --- a/src/FitBase/EventManager.h +++ b/src/FitBase/EventManager.h @@ -1,76 +1,76 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef EVENTMANAGER_H #define EVENTMANAGER_H #include "InputHandler.h" #include "FitWeight.h" #include "InputUtils.h" #include "InputFactory.h" // This class is meant to manage one input file for many distributions class EventManager { public: static EventManager& Get(void); FitWeight* GetRW(); void SetRW(FitWeight* rw); InputHandlerBase* GetInput(int id); FitEvent* GetEvent(int id, int i); double GetEventWeight(int id, int i); InputHandlerBase* AddInput(std::string handle, std::string infile); void ResetWeightFlags(); int GetInputID(std::string infile); std::map< int, InputHandlerBase* > GetInputs(); protected: EventManager(); ~EventManager(); static EventManager* m_evtmgrInstance; FitWeight* fRW; std::map< std::string, int > fid; std::map< int, InputHandlerBase* > finputs; std::map< int, std::vector< bool > > frwneeded; std::map< int, std::vector< double > > calc_rw; }; namespace FitBase { inline EventManager& EvtManager(){ return EventManager::Get(); }; inline FitWeight* GetRW(){ return EvtManager().GetRW(); }; inline void SetRW(FitWeight* rw){ EvtManager().SetRW(rw); }; inline int GetInputID(std::string infile){ return EvtManager().GetInputID(infile); }; inline InputHandlerBase* GetInput(int infile){ return EvtManager().GetInput(infile); }; inline InputHandlerBase* AddInput(std::string handle, std::string infile){ return EvtManager().AddInput(handle, infile); }; } #endif diff --git a/src/FitBase/JointMeas1D.cxx b/src/FitBase/JointMeas1D.cxx index c68e674..ca79582 100644 --- a/src/FitBase/JointMeas1D.cxx +++ b/src/FitBase/JointMeas1D.cxx @@ -1,2222 +1,2220 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This ile 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 . *******************************************************************************/ #include "JointMeas1D.h" //******************************************************************** JointMeas1D::JointMeas1D(void) { //******************************************************************** // XSec Scalings fScaleFactor = -1.0; fCurrentNorm = 1.0; // Histograms fDataHist = NULL; fDataTrue = NULL; fMCHist = NULL; fMCFine = NULL; fMCWeighted = NULL; fMaskHist = NULL; // Covar covar = NULL; fFullCovar = NULL; fCovar = NULL; fInvert = NULL; fDecomp = NULL; // Fake Data fFakeDataInput = ""; fFakeDataFile = NULL; // Options 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; + fSaveFine = true; // Inputs fInput = NULL; fRW = NULL; // Extra Histograms fMCHist_Modes = NULL; for (std::vector::const_iterator iter = fSubChain.begin(); iter != fSubChain.end(); iter++) { MeasurementBase *exp = *iter; if (exp) delete exp; } fSubChain.clear(); // Flags for Joint Measurements fIsRatio = false; fIsSummed = false; fSaveSubMeas = false; fIsJoint = true; } //******************************************************************** void JointMeas1D::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); } fMCHist_Modes = new TrueModeStack((fName + "_MODES").c_str(), ("True Channels"), fMCHist); SetAutoProcessTH1(fMCHist_Modes); return; } //******************************************************************** JointMeas1D::~JointMeas1D(void) { //******************************************************************** if (fDataHist) delete fDataHist; if (fDataTrue) delete fDataTrue; if (fMCHist) delete fMCHist; if (fMCFine) delete fMCFine; if (fMCWeighted) delete fMCWeighted; if (fMaskHist) delete fMaskHist; if (covar) delete covar; if (fFullCovar) delete fFullCovar; if (fCovar) delete fCovar; if (fInvert) delete fInvert; if (fDecomp) delete fDecomp; for (std::vector::const_iterator iter = fSubChain.begin(); iter != fSubChain.end(); iter++) { MeasurementBase *exp = *iter; if (exp) delete exp; } fSubChain.clear(); } //******************************************************************** SampleSettings JointMeas1D::LoadSampleSettings(nuiskey samplekey) { //******************************************************************** SampleSettings s = MeasurementBase::LoadSampleSettings(samplekey); // Parse Inputs fSubInFiles.clear(); std::vector entries = GeneralUtils::ParseToStr(s.GetS("input"), ";"); if (entries.size() < 2) { NUIS_ABORT("Joint measurement expected to recieve at least two semi-colon " "separated input files, but recieved: \"" << s.GetS("input") << "\""); } std::vector first_file_descriptor = GeneralUtils::ParseToStr(entries.front(), ":"); if (first_file_descriptor.size() != 2) { NUIS_ABORT("Found Joint measurement where the input file had no type: \"" << s.GetS("input") << "\", expected \"INPUTTYPE:File.root;File2.root\"."); } std::string inpType = first_file_descriptor[0]; for (std::vector::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); } } return s; } //******************************************************************** void JointMeas1D::FinaliseSampleSettings() { //******************************************************************** // Setup naming + renaming fName = fSettings.GetName(); fSettings.SetS("originalname", fName); if (fSettings.Has("rename")) { fName = fSettings.GetS("rename"); fSettings.SetS("name", fName); } // Setup all other options NUIS_LOG(SAM, "Finalising Sample Settings: " << fName); if ((fSettings.GetS("originalname").find("Evt") != std::string::npos)) { fIsRawEvents = true; NUIS_LOG(SAM, "Found event rate measurement but using poisson likelihoods."); } if (fSettings.GetS("originalname").find("XSec_1DEnu") != std::string::npos) { fIsEnu1D = true; - NUIS_LOG(SAM, "::" << fName << "::"); NUIS_LOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, " << "not flux averaged!"); } if (fIsEnu1D && fIsRawEvents) { NUIS_LOG(SAM, "Found 1D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!"); NUIS_LOG(SAM, "Check experiment constructor for " << fName << " and correct this!"); NUIS_LOG(SAM, "I live in " << __FILE__ << ":" << __LINE__); exit(-1); } // Parse Inputs fSubInFiles.clear(); std::vector entries = GeneralUtils::ParseToStr(fSettings.GetS("input"), ";"); if (entries.size() < 2) { NUIS_ABORT("Joint measurement expected to recieve at least two semi-colon " "separated input files, but recieved: \"" << fSettings.GetS("input") << "\""); } std::vector first_file_descriptor = GeneralUtils::ParseToStr(entries.front(), ":"); if (first_file_descriptor.size() != 2) { NUIS_ABORT("Found Joint measurement where the input file had no type: \"" << fSettings.GetS("input") << "\", expected \"INPUTTYPE:File.root;File2.root\"."); } std::string inpType = first_file_descriptor[0]; for (std::vector::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); } } // Setup options SetFitOptions(fDefaultTypes); // defaults SetFitOptions(fSettings.GetS("type")); // user specified EnuMin = GeneralUtils::StrToDbl(fSettings.GetS("enu_min")); EnuMax = GeneralUtils::StrToDbl(fSettings.GetS("enu_max")); if (fAddNormPen) { if (fNormError <= 0.0) { NUIS_ERR(FTL, "Norm error for class " << fName << " is 0.0!"); NUIS_ERR(FTL, "If you want to use it please add fNormError=VAL"); throw; } } if (!fRW) fRW = FitBase::GetRW(); - - NUIS_LOG(SAM, "Finalised Sample Settings"); } //******************************************************************** void JointMeas1D::SetDataFromTextFile(std::string datafile) { //******************************************************************** NUIS_LOG(SAM, "Reading data from text file: " << datafile); fDataHist = PlotUtils::GetTH1DFromFile( datafile, fSettings.GetName() + "_data", fSettings.GetFullTitles()); } //******************************************************************** void JointMeas1D::SetDataFromRootFile(std::string datafile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading data from root file: " << datafile << ";" << histname); fDataHist = PlotUtils::GetTH1DFromRootFile(datafile, histname); fDataHist->SetNameTitle((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str()); return; }; //******************************************************************** void JointMeas1D::SetPoissonErrors() { //******************************************************************** if (!fDataHist) { NUIS_ERR(FTL, "Need a data hist to setup possion errors! "); NUIS_ABORT("Setup Data First!"); } for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i + 1, sqrt(fDataHist->GetBinContent(i + 1))); } } //******************************************************************** void JointMeas1D::SetCovarFromDiagonal(TH1D *data) { //******************************************************************** if (!data and fDataHist) { data = fDataHist; } if (data) { NUIS_LOG(SAM, "Setting diagonal covariance for: " << data->GetName()); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(data); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } else { NUIS_ERR(FTL, "No data input provided to set diagonal covar from!"); } if (!fIsDiag) { NUIS_ERR(FTL, "SetCovarMatrixFromDiag called for measurement " << "that is not set as diagonal."); throw; } } //******************************************************************** void JointMeas1D::SetCovarFromTextFile(std::string covfile, int dim) { //******************************************************************** NUIS_LOG(SAM, "Reading covariance from text file: " << covfile); fFullCovar = StatUtils::GetCovarFromTextFile(covfile, dim); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void JointMeas1D::SetCovarFromMultipleTextFiles(std::string covfiles, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } std::vector covList = GeneralUtils::ParseToStr(covfiles, ";"); fFullCovar = new TMatrixDSym(dim); for (uint i = 0; i < covList.size(); ++i) { NUIS_LOG(SAM, "Reading covariance from text file: " << covList[i]); TMatrixDSym *temp_cov = StatUtils::GetCovarFromTextFile(covList[i], dim); (*fFullCovar) += (*temp_cov); delete temp_cov; } covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void JointMeas1D::SetCovarFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading covariance from text file: " << covfile << ";" << histname); fFullCovar = StatUtils::GetCovarFromRootFile(covfile, histname); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void JointMeas1D::SetCovarInvertFromTextFile(std::string covfile, int dim) { //******************************************************************** NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile); covar = StatUtils::GetCovarFromTextFile(covfile, dim); fFullCovar = StatUtils::GetInvert(covar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void JointMeas1D::SetCovarInvertFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile << ";" << histname); covar = StatUtils::GetCovarFromRootFile(covfile, histname); fFullCovar = StatUtils::GetInvert(covar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void JointMeas1D::SetCorrelationFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) dim = fDataHist->GetNbinsX(); NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";" << dim); TMatrixDSym *correlation = StatUtils::GetCovarFromTextFile(covfile, dim); if (!fDataHist) { NUIS_ABORT("Trying to set correlations from text file but there is no " "data to build it from. \n" << "In constructor make sure data is set before " "SetCorrelationFromTextFile is called. \n"); } // Fill covar from data errors and correlations fFullCovar = new TMatrixDSym(dim); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = (*correlation)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } // Fill other covars. covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete correlation; } //******************************************************************** void JointMeas1D::SetCorrelationFromMultipleTextFiles(std::string corrfiles, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } std::vector corrList = GeneralUtils::ParseToStr(corrfiles, ";"); fFullCovar = new TMatrixDSym(dim); for (uint i = 0; i < corrList.size(); ++i) { NUIS_LOG(SAM, "Reading covariance from text file: " << corrList[i]); TMatrixDSym *temp_cov = StatUtils::GetCovarFromTextFile(corrList[i], dim); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { // Note that there is a factor of 1E76 here. It is very silly indeed. // However, if you remove it, you also need to fix the factors of 1E38 // added to the chi2 calculations! (*temp_cov)(i, j) = (*temp_cov)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1E76; } } (*fFullCovar) += (*temp_cov); delete temp_cov; } covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void JointMeas1D::SetCorrelationFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";" << histname); TMatrixDSym *correlation = StatUtils::GetCovarFromRootFile(covfile, histname); if (!fDataHist) { NUIS_ABORT("Trying to set correlations from text file but there is no " "data to build it from. \n" << "In constructor make sure data is set before " "SetCorrelationFromTextFile is called. \n"); } // Fill covar from data errors and correlations fFullCovar = new TMatrixDSym(fDataHist->GetNbinsX()); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = (*correlation)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } // Fill other covars. covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete correlation; } void JointMeas1D::SetShapeCovar() { // Return if this is missing any pre-requisites if (!fFullCovar) return; if (!fDataHist) return; // Also return if it's bloody stupid under the circumstances if (fIsDiag) return; fShapeCovar = StatUtils::ExtractShapeOnlyCovar(fFullCovar, fDataHist); return; } //******************************************************************** void JointMeas1D::SetCholDecompFromTextFile(std::string covfile, int dim) { //******************************************************************** NUIS_LOG(SAM, "Reading cholesky from text file: " << covfile); TMatrixD *temp = StatUtils::GetMatrixFromTextFile(covfile, dim, dim); TMatrixD *trans = (TMatrixD *)temp->Clone(); trans->T(); (*trans) *= (*temp); fFullCovar = new TMatrixDSym(dim, trans->GetMatrixArray(), ""); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete temp; delete trans; } //******************************************************************** void JointMeas1D::SetCholDecompFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading cholesky decomp from root file: " << covfile << ";" << histname); TMatrixD *temp = StatUtils::GetMatrixFromRootFile(covfile, histname); TMatrixD *trans = (TMatrixD *)temp->Clone(); trans->T(); (*trans) *= (*temp); fFullCovar = new TMatrixDSym(temp->GetNrows(), trans->GetMatrixArray(), ""); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete temp; delete trans; } //******************************************************************** void JointMeas1D::ScaleData(double scale) { //******************************************************************** fDataHist->Scale(scale); } //******************************************************************** void JointMeas1D::ScaleCovar(double scale) { //******************************************************************** (*fFullCovar) *= scale; (*covar) *= 1.0 / scale; (*fDecomp) *= sqrt(scale); } //******************************************************************** void JointMeas1D::SetBinMask(std::string maskfile) { //******************************************************************** if (!fIsMask) return; NUIS_LOG(SAM, "Reading bin mask from file: " << maskfile); // Create a mask histogram with dim of data int nbins = fDataHist->GetNbinsX(); fMaskHist = new TH1I((fSettings.GetName() + "_BINMASK").c_str(), (fSettings.GetName() + "_BINMASK; Bin; Mask?").c_str(), nbins, 0, nbins); std::string line; std::ifstream mask(maskfile.c_str(), std::ifstream::in); if (!mask.is_open()) { NUIS_ABORT(" Cannot find mask file: " << maskfile); } while (std::getline(mask >> std::ws, line, '\n')) { std::vector entries = GeneralUtils::ParseToInt(line, " "); // Skip lines with poorly formatted lines if (entries.size() < 2) { NUIS_LOG(WRN, "JointMeas1D::SetBinMask(), couldn't parse line: " << line); continue; } // The first index should be the bin number, the second should be the mask // value. int val = 0; if (entries[1] > 0) val = 1; fMaskHist->SetBinContent(entries[0], val); } // Apply masking by setting masked data bins to zero PlotUtils::MaskBins(fDataHist, fMaskHist); return; } //******************************************************************** void JointMeas1D::FinaliseMeasurement() { //******************************************************************** NUIS_LOG(SAM, "Finalising Measurement: " << fName); // Make sure data is setup if (!fDataHist) { NUIS_ABORT("No data has been setup inside " << fName << " constructor!"); } // Make sure covariances are setup if (!fFullCovar) { fIsDiag = true; SetCovarFromDiagonal(fDataHist); } if (!covar) { covar = StatUtils::GetInvert(fFullCovar,true); } if (!fDecomp) { fDecomp = StatUtils::GetDecomp(fFullCovar); } // Push the diagonals of fFullCovar onto the data histogram // Comment out until scaling is used consistently... StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38); // Setup fMCHist from data fMCHist = (TH1D *)fDataHist->Clone(); fMCHist->SetNameTitle((fSettings.GetName() + "_MC").c_str(), (fSettings.GetFullTitles()).c_str()); fMCHist->Reset(); // Setup fMCFine fMCFine = new TH1D("mcfine", "mcfine", fDataHist->GetNbinsX(), fMCHist->GetBinLowEdge(1), fMCHist->GetBinLowEdge(fDataHist->GetNbinsX() + 1)); fMCFine->SetNameTitle((fSettings.GetName() + "_MC_FINE").c_str(), (fSettings.GetFullTitles()).c_str()); fMCFine->Reset(); // Setup MC Stat fMCStat = (TH1D *)fMCHist->Clone(); fMCStat->Reset(); // Search drawopts for possible types to include by default std::string drawopts = FitPar::Config().GetParS("drawopts"); if (drawopts.find("MODES") != std::string::npos) { fMCHist_Modes = new TrueModeStack((fSettings.GetName() + "_MODES").c_str(), ("True Channels"), fMCHist); SetAutoProcessTH1(fMCHist_Modes); } // Setup bin masks using sample name if (fIsMask) { std::string curname = fName; std::string origname = fSettings.GetS("originalname"); // Check rename.mask std::string maskloc = FitPar::Config().GetParDIR(curname + ".mask"); // Check origname.mask if (maskloc.empty()) maskloc = FitPar::Config().GetParDIR(origname + ".mask"); // Check database if (maskloc.empty()) { maskloc = FitPar::GetDataBase() + "/masks/" + origname + ".mask"; } // Setup Bin Mask SetBinMask(maskloc); } /* 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; throw; } */ // Create and fill Weighted Histogram if (!fMCWeighted) { fMCWeighted = (TH1D *)fMCHist->Clone(); fMCWeighted->SetNameTitle((fName + "_MCWGHTS").c_str(), (fName + "_MCWGHTS" + fPlotTitles).c_str()); fMCWeighted->GetYaxis()->SetTitle("Weighted Events"); } } //******************************************************************** void JointMeas1D::SetFitOptions(std::string opt) { //******************************************************************** // Do nothing if default given if (opt == "DEFAULT") return; // CHECK Conflicting Fit Options std::vector fit_option_allow = GeneralUtils::ParseToStr(fAllowedTypes, "/"); for (UInt_t i = 0; i < fit_option_allow.size(); i++) { std::vector 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) { NUIS_ABORT("ERROR: Conflicting fit options provided: " << opt << std::endl << "Conflicting group = " << fit_option_section.at(i) << std::endl << "You should only supply one of these options in card file."); } } } // Check all options are allowed std::vector 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) { NUIS_ERR(FTL, "ERROR: Fit Option '" << fit_options_input.at(i) << "' Provided is not allowed for this measurement."); NUIS_ERR(FTL, "Fit Options should be provided as a '/' separated list " "(e.g. FREE/DIAG/NORM)"); NUIS_ERR(FTL, "Available options for " << fName << " are '" << fAllowedTypes << "'"); throw; } } // 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; NUIS_ERR(FTL, "No other LIKELIHOODS properly supported!"); NUIS_ERR(FTL, "Try to use a chi2!"); throw; } 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 JointMeas1D::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(), std::ifstream::in); // Note that the smearing matrix may be rectangular. fSmearMatrix = new TMatrixD(truedim, recodim); if (smear.is_open()) { NUIS_LOG(SAM, "Reading smearing matrix from file: " << smearfile); } else { NUIS_ABORT("Smearing matrix provided is incorrect: " << smearfile); } while (std::getline(smear >> std::ws, line, '\n')) { int column = 0; std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { (*fSmearMatrix)(row, column) = (*iter) / 100.; // Convert to fraction from // percentage (this may not be // general enough) column++; } row++; } return; } //******************************************************************** void JointMeas1D::ApplySmearingMatrix() { //******************************************************************** if (!fSmearMatrix) { NUIS_ERR(WRN, fName << ": attempted to apply smearing matrix, but none was set"); 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); } smeared->SetBinContent(rbin + 1, rBinVal); } fMCHist = (TH1D *)smeared->Clone(); return; } /* Reconfigure LOOP */ //******************************************************************** void JointMeas1D::ResetAll() { //******************************************************************** fMCHist->Reset(); fMCFine->Reset(); fMCStat->Reset(); return; }; //******************************************************************** void JointMeas1D::FillHistograms() { //******************************************************************** if (Signal) { fMCHist->Fill(fXVar, Weight); fMCFine->Fill(fXVar, Weight); fMCStat->Fill(fXVar, 1.0); if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, fXVar, Weight); } return; }; //******************************************************************** void JointMeas1D::ScaleEvents() { //******************************************************************** NUIS_LOG(FIT, "Scaling JointMeas1D"); // Fill MCWeighted; for (int i = 0; i < fMCHist->GetNbinsX(); i++) { fMCWeighted->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1)); fMCWeighted->SetBinError(i + 1, fMCHist->GetBinError(i + 1)); } // Setup Stat ratios for MC and MC Fine double *statratio = new double[fMCHist->GetNbinsX()]; for (int i = 0; i < fMCHist->GetNbinsX(); i++) { if (fMCHist->GetBinContent(i + 1) != 0) { statratio[i] = fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1); } else { statratio[i] = 0.0; } } double *statratiofine = new double[fMCFine->GetNbinsX()]; for (int i = 0; i < fMCFine->GetNbinsX(); i++) { if (fMCFine->GetBinContent(i + 1) != 0) { statratiofine[i] = fMCFine->GetBinError(i + 1) / fMCFine->GetBinContent(i + 1); } else { statratiofine[i] = 0.0; } } // Scaling for raw event rates if (fIsRawEvents) { double datamcratio = fDataHist->Integral() / fMCHist->Integral(); fMCHist->Scale(datamcratio); fMCFine->Scale(datamcratio); if (fMCHist_Modes) fMCHist_Modes->Scale(datamcratio); // Scaling for XSec as function of Enu } else if (fIsEnu1D) { PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); // if (fMCHist_Modes) { // PlotUtils::FluxUnfoldedScaling(fMCHist_Modes, GetFluxHistogram(), // GetEventHistogram(), fScaleFactor, // fNEvents); // } // Any other differential scaling } else { fMCHist->Scale(fScaleFactor, "width"); fMCFine->Scale(fScaleFactor, "width"); if (fMCHist_Modes) { fMCHist_Modes->Scale(fScaleFactor, "width"); } } // Proper error scaling - ROOT Freaks out with xsec weights sometimes for (int i = 0; i < fMCStat->GetNbinsX(); i++) { fMCHist->SetBinError(i + 1, fMCHist->GetBinContent(i + 1) * statratio[i]); } for (int i = 0; i < fMCFine->GetNbinsX(); i++) { fMCFine->SetBinError(i + 1, fMCFine->GetBinContent(i + 1) * statratiofine[i]); } // Clean up delete statratio; delete statratiofine; return; }; //******************************************************************** void JointMeas1D::ApplyNormScale(double norm) { //******************************************************************** fCurrentNorm = norm; fMCHist->Scale(1.0 / norm); fMCFine->Scale(1.0 / norm); return; }; /* Statistic Functions - Outsources to StatUtils */ //******************************************************************** int JointMeas1D::GetNDOF() { //******************************************************************** int ndof = fDataHist->GetNbinsX(); if (fMaskHist) ndof -= fMaskHist->Integral(); return ndof; } //******************************************************************** double JointMeas1D::GetLikelihood() { //******************************************************************** // If this is for a ratio, there is no data histogram to compare to! if (fNoData || !fDataHist) return 0.; // Apply Masking to MC if Required. if (fIsMask and fMaskHist) { PlotUtils::MaskBins(fMCHist, fMaskHist); } // Sort Shape Scaling double scaleF = 0.0; if (fIsShape) { if (fMCHist->Integral(1, fMCHist->GetNbinsX(), "width")) { scaleF = fDataHist->Integral(1, fDataHist->GetNbinsX(), "width") / fMCHist->Integral(1, fMCHist->GetNbinsX(), "width"); fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); } } // Likelihood Calculation double stat = 0.; if (fIsChi2) { if (fIsRawEvents) { stat = StatUtils::GetChi2FromEventRate(fDataHist, fMCHist, fMaskHist); } else if (fIsDiag) { stat = StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMaskHist); } else if (!fIsDiag and !fIsRawEvents) { stat = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMaskHist); } } // Sort Penalty Terms if (fAddNormPen) { double penalty = (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); } fLikelihood = stat; return stat; } /* Fake Data Functions */ //******************************************************************** void JointMeas1D::SetFakeDataValues(std::string fakeOption) { //******************************************************************** // Setup original/datatrue TH1D *tempdata = (TH1D *)fDataHist->Clone(); if (!fIsFakeData) { fIsFakeData = true; // Make a copy of the original data histogram. if (!fDataOrig) fDataOrig = (TH1D *)fDataHist->Clone((fName + "_data_original").c_str()); } else { ResetFakeData(); } // Setup Inputs fFakeDataInput = fakeOption; NUIS_LOG(SAM, "Setting fake data from : " << fFakeDataInput); // From MC if (fFakeDataInput.compare("MC") == 0) { fDataHist = (TH1D *)fMCHist->Clone((fName + "_MC").c_str()); // Fake File } else { if (!fFakeDataFile) fFakeDataFile = new TFile(fFakeDataInput.c_str(), "READ"); fDataHist = (TH1D *)fFakeDataFile->Get((fName + "_MC").c_str()); } // Setup Data Hist fDataHist->SetNameTitle((fName + "_FAKE").c_str(), (fName + fPlotTitles).c_str()); // Replace Data True if (fDataTrue) delete fDataTrue; fDataTrue = (TH1D *)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_FAKE_TRUE").c_str(), (fName + fPlotTitles).c_str()); // Make a new covariance for fake data hist. 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); alpha_j = fDataHist->GetBinContent(j + 1) / tempdata->GetBinContent(j + 1); (*fFullCovar)(i, j) = alpha_i * alpha_j * (*fFullCovar)(i, j); } } // Setup Covariances if (covar) delete covar; covar = StatUtils::GetInvert(fFullCovar,true); if (fDecomp) delete fDecomp; fDecomp = StatUtils::GetDecomp(fFullCovar); delete tempdata; return; }; //******************************************************************** void JointMeas1D::ResetFakeData() { //******************************************************************** if (fIsFakeData) { if (fDataHist) delete fDataHist; fDataHist = (TH1D *)fDataTrue->Clone((fSettings.GetName() + "_FKDAT").c_str()); } } //******************************************************************** void JointMeas1D::ResetData() { //******************************************************************** if (fIsFakeData) { if (fDataHist) delete fDataHist; fDataHist = (TH1D *)fDataOrig->Clone((fSettings.GetName() + "_data").c_str()); } fIsFakeData = false; } //******************************************************************** void JointMeas1D::ThrowCovariance() { //******************************************************************** // Take a fDecomposition and use it to throw the current dataset. // Requires fDataTrue also be set incase used repeatedly. if (fDataHist) delete fDataHist; fDataHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); return; }; //******************************************************************** void JointMeas1D::ThrowDataToy() { //******************************************************************** if (!fDataTrue) fDataTrue = (TH1D *)fDataHist->Clone(); if (fMCHist) delete fMCHist; fMCHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); } /* Access Functions */ //******************************************************************** TH1D *JointMeas1D::GetMCHistogram() { //******************************************************************** if (!fMCHist) return fMCHist; std::ostringstream chi2; chi2 << "#chi^{2}=" << std::setprecision(5) << this->GetLikelihood(); int linecolor = kRed; int linestyle = 1; int linewidth = 1; int fillcolor = 0; int fillstyle = 1001; if (fSettings.Has("linecolor")) linecolor = fSettings.GetI("linecolor"); if (fSettings.Has("linestyle")) linestyle = fSettings.GetI("linestyle"); if (fSettings.Has("linewidth")) linewidth = fSettings.GetI("linewidth"); if (fSettings.Has("fillcolor")) fillcolor = fSettings.GetI("fillcolor"); if (fSettings.Has("fillstyle")) fillstyle = fSettings.GetI("fillstyle"); fMCHist->SetTitle(chi2.str().c_str()); fMCHist->SetLineColor(linecolor); fMCHist->SetLineStyle(linestyle); fMCHist->SetLineWidth(linewidth); fMCHist->SetFillColor(fillcolor); fMCHist->SetFillStyle(fillstyle); return fMCHist; }; //******************************************************************** TH1D *JointMeas1D::GetDataHistogram() { //******************************************************************** if (!fDataHist) return fDataHist; int datacolor = kBlack; int datastyle = 1; int datawidth = 1; if (fSettings.Has("datacolor")) datacolor = fSettings.GetI("datacolor"); if (fSettings.Has("datastyle")) datastyle = fSettings.GetI("datastyle"); if (fSettings.Has("datawidth")) datawidth = fSettings.GetI("datawidth"); fDataHist->SetLineColor(datacolor); fDataHist->SetLineWidth(datawidth); fDataHist->SetMarkerStyle(datastyle); return fDataHist; }; /* Write Functions */ // Save all the histograms at once //******************************************************************** void JointMeas1D::Write(std::string drawOpt) { //******************************************************************** // Get Draw Options drawOpt = FitPar::Config().GetParS("drawopts"); // Write Settigns if (drawOpt.find("SETTINGS") != std::string::npos) { fSettings.Set("#chi^{2}", fLikelihood); fSettings.Set("NDOF", this->GetNDOF()); fSettings.Set("#chi^{2}/NDOF", fLikelihood / this->GetNDOF()); fSettings.Write(); } // Write Data/MC GetDataHistogram()->Write(); GetMCHistogram()->Write(); // Write Fine Histogram - if (drawOpt.find("FINE") != std::string::npos) + if (fSaveFine && drawOpt.find("FINE") != std::string::npos) GetFineList().at(0)->Write(); // Write Weighted Histogram if (drawOpt.find("WEIGHTS") != std::string::npos && fMCWeighted) fMCWeighted->Write(); // Save Flux/Evt if no event manager if (!FitPar::Config().GetParB("EventManager")) { if (drawOpt.find("FLUX") != std::string::npos && GetFluxHistogram()) GetFluxHistogram()->Write(); if (drawOpt.find("EVT") != std::string::npos && GetEventHistogram()) GetEventHistogram()->Write(); if (drawOpt.find("XSEC") != std::string::npos && GetEventHistogram()) GetEventHistogram()->Write(); } // Write Mask if (fIsMask && (drawOpt.find("MASK") != std::string::npos)) { fMaskHist->Write(); } // Write Covariances if (drawOpt.find("COV") != std::string::npos && fFullCovar) { PlotUtils::GetFullCovarPlot(fFullCovar, fSettings.GetName())->Write(); } if (drawOpt.find("INVCOV") != std::string::npos && covar) { PlotUtils::GetInvCovarPlot(covar, fSettings.GetName())->Write(); } if (drawOpt.find("DECOMP") != std::string::npos && fDecomp) { PlotUtils::GetDecompCovarPlot(fDecomp, fSettings.GetName())->Write(); } // // Likelihood residual plots // if (drawOpt.find("RESIDUAL") != std::string::npos) { // WriteResidualPlots(); // } // Ratio and Shape Plots if (drawOpt.find("RATIO") != std::string::npos) { WriteRatioPlot(); } if (drawOpt.find("SHAPE") != std::string::npos) { WriteShapePlot(); if (drawOpt.find("RATIO") != std::string::npos) WriteShapeRatioPlot(); } // // RATIO // if (drawOpt.find("CANVMC") != std::string::npos) { // TCanvas* c1 = WriteMCCanvas(fDataHist, fMCHist); // c1->Write(); // delete c1; // } // // PDG // if (drawOpt.find("CANVPDG") != std::string::npos && fMCHist_Modes) { // TCanvas* c2 = WritePDGCanvas(fDataHist, fMCHist, fMCHist_Modes); // c2->Write(); // delete c2; // } // Write Extra Histograms AutoWriteExtraTH1(); WriteExtraHistograms(); if (fSaveSubMeas) { for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; exp->Write(drawOpt); } } // Returning NUIS_LOG(SAM, "Written Histograms: " << fName); return; } //******************************************************************** void JointMeas1D::WriteRatioPlot() { //******************************************************************** // Setup mc data ratios TH1D *dataRatio = (TH1D *)fDataHist->Clone((fName + "_data_RATIO").c_str()); TH1D *mcRatio = (TH1D *)fMCHist->Clone((fName + "_MC_RATIO").c_str()); // Extra MC Data Ratios for (int i = 0; i < mcRatio->GetNbinsX(); i++) { dataRatio->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) / fMCHist->GetBinContent(i + 1)); dataRatio->SetBinError(i + 1, fDataHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1)); mcRatio->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1) / fMCHist->GetBinContent(i + 1)); mcRatio->SetBinError(i + 1, fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1)); } // Write ratios mcRatio->Write(); dataRatio->Write(); delete mcRatio; delete dataRatio; } //******************************************************************** void JointMeas1D::WriteShapePlot() { //******************************************************************** TH1D *mcShape = (TH1D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); double shapeScale = 1.0; if (fIsRawEvents) { shapeScale = fDataHist->Integral() / fMCHist->Integral(); } else { shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); } mcShape->Scale(shapeScale); std::stringstream ss; ss << "Scale=" << shapeScale; mcShape->SetTitle(ss.str().c_str()); mcShape->SetLineWidth(3); mcShape->SetLineStyle(7); mcShape->Write(); delete mcShape; } //******************************************************************** void JointMeas1D::WriteShapeRatioPlot() { //******************************************************************** // Get a mcshape histogram TH1D *mcShape = (TH1D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); double shapeScale = 1.0; if (fIsRawEvents) { shapeScale = fDataHist->Integral() / fMCHist->Integral(); } else { shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); } mcShape->Scale(shapeScale); // Create shape ratio histograms TH1D *mcShapeRatio = (TH1D *)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str()); TH1D *dataShapeRatio = (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); mcShapeRatio->Write(); dataShapeRatio->Write(); delete mcShapeRatio; delete dataShapeRatio; } /* 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 separated list. // Parse this list and save it for later, and set up the types etc. if (FitPar::Config().GetParB("EventManager")) { NUIS_ERR(FTL, "Event Manager does not yet work with JointMeas1D Samples"); NUIS_ERR(FTL, "If you want good predictions for " << fName << " then run with it turned off! (-q EventManager=0)"); } fSubInFiles.clear(); std::vector entries = GeneralUtils::ParseToStr(input, ";"); if (entries.size() < 2) { NUIS_ABORT("Joint measurement expected to recieve at least two semi-colon " "separated input files, but recieved: \"" << input << "\""); } std::vector first_file_descriptor = GeneralUtils::ParseToStr(entries.front(), ":"); if (first_file_descriptor.size() != 2) { NUIS_ABORT("Found Joint measurement where the input file had no type: \"" << input << "\", expected \"INPUTTYPE:File.root;File2.root\"."); } std::string inpType = first_file_descriptor[0]; for (std::vector::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; fFakeDataInput = 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::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() { //******************************************************************** for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; exp->Reconfigure(); } ConvertEventRates(); return; } //******************************************************************** void JointMeas1D::ConvertEventRates() { //******************************************************************** // Apply Event Scaling for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); exp->ScaleEvents(); } // Joint function called by top level class MakePlots(); // Do Final Normalisation ApplyNormScale(fRW->GetSampleNorm(this->fName)); } //******************************************************************** void JointMeas1D::MakePlots() { //******************************************************************** // Reset the 1D histograms but not the subClasses ResetAll(); // If Summed if (fIsSummed) { for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*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::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 JointMeas1D::GetMCList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(this->fMCHist); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector subTempVect = exp->GetMCList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector JointMeas1D::GetDataList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(this->fDataHist); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector subTempVect = exp->GetDataList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector JointMeas1D::GetFineList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(this->fMCFine); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector subTempVect = exp->GetFineList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector JointMeas1D::GetMaskList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(this->fMaskHist); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector subTempVect = exp->GetMaskList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector JointMeas1D::GetFluxList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(MeasurementBase::GetFluxHistogram()); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector subTempVect = exp->GetFluxList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector JointMeas1D::GetEventRateList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(MeasurementBase::GetEventHistogram()); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector subTempVect = exp->GetEventRateList(); for (UInt_t i = 0; i < subTempVect.size(); i++) { tempVect.push_back(subTempVect.at(i)); } } return tempVect; } //******************************************************************** std::vector JointMeas1D::GetXSecList() { //******************************************************************** // Make Default Vector std::vector tempVect; tempVect.push_back(MeasurementBase::GetXSecHistogram()); // Return vector from all sub samples for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; std::vector 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 = NULL; int sample = 0; for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; // Get flux from experiment std::vector 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++; } } if (!newflux) { NUIS_ABORT("No combined flux setup in JointMeas1D"); } return newflux; } //******************************************************************** TH1D *JointMeas1D::GetCombinedEventRate() { //******************************************************************** TH1D *newflux = NULL; int sample = 0; for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = *expIter; // Get flux from experiment std::vector 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++; } } if (!newflux) { NUIS_ABORT("No combined event rate setup in JointMeas1D"); } return newflux; } //******************************************************************** std::vector JointMeas1D::GetSubSamples() { //******************************************************************** std::vector exps; for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { exps.push_back(*expIter); } return exps; } //// CRAP TO BE REMOVED //******************************************************************** void JointMeas1D::SetDataValues(std::string dataFile) { //******************************************************************** // Override this function if the input file isn't in a suitable format NUIS_LOG(SAM, "Reading data from: " << dataFile.c_str()); 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 JointMeas1D::SetDataFromDatabase(std::string inhistfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Filling histogram from " << inhistfile << "->" << histname); fDataHist = PlotUtils::GetTH1DFromRootFile( (GeneralUtils::GetTopLevelDir() + "/data/" + inhistfile), histname); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data").c_str()); return; }; //******************************************************************** void JointMeas1D::SetDataFromFile(std::string inhistfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Filling histogram from " << inhistfile << "->" << histname); fDataHist = PlotUtils::GetTH1DFromRootFile((inhistfile), histname); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data").c_str()); return; }; //******************************************************************** void JointMeas1D::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 *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()); if (!covOption.compare("SUB")) fFullCovarPlot = (TH2D *)tempFile->Get((covName + "cov").c_str()); else if (!covOption.compare("FULL")) fFullCovarPlot = (TH2D *)tempFile->Get("fullcov"); else { NUIS_ERR(WRN, "Incorrect thrown_covariance option in parameters."); } 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 JointMeas1D::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(), std::ifstream::in); this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); if (covarread.is_open()) { NUIS_LOG(SAM, "Reading covariance matrix from file: " << covarFile); } else { NUIS_ERR(FTL, "Covariance matrix provided is incorrect: " << covarFile); } // 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 entries = GeneralUtils::ParseToDbl(line, " "); if (entries.size() <= 1) { NUIS_ERR(WRN, "SetCovarMatrixFromText -> Covariance matrix only has <= 1 " "entries on this line: " << row); } for (std::vector::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); return; }; //******************************************************************** void JointMeas1D::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(), std::ifstream::in); this->covar = new TMatrixDSym(dim); this->fFullCovar = new TMatrixDSym(dim); if (corr.is_open()) { NUIS_LOG(SAM, "Reading and converting correlation matrix from file: " << corrFile); } else { NUIS_ERR(FTL, "Correlation matrix provided is incorrect: " << corrFile); 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 std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { double val = (*iter) * this->fDataHist->GetBinError(row + 1) * 1E38 * this->fDataHist->GetBinError(column + 1) * 1E38; if (val == 0) { NUIS_ERR(FTL, "Found a zero value in the covariance matrix, assuming " "this is an error!"); 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(), ""); 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 JointMeas1D::SetCovarFromDataFile(std::string covarFile, std::string covName, bool FullUnits) { //******************************************************************** NUIS_LOG(SAM, "Getting covariance from " << covarFile << "->" << covName); 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; }; // std::vector JointMeas1D::GetMCList(void){ // std::vector temp; // return temp; // } // std::vector JointMeas1D::GetDataList(void){ // std::vector temp; // return temp; // } // std::vector JointMeas1D::GetMaskList(void){ // std::vector temp; // return temp; // } // std::vector JointMeas1D::GetFineList(void){ // std::vector temp; // return temp; // } diff --git a/src/FitBase/JointMeas1D.h b/src/FitBase/JointMeas1D.h index 71543ad..a175832 100644 --- a/src/FitBase/JointMeas1D.h +++ b/src/FitBase/JointMeas1D.h @@ -1,650 +1,651 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef JOINTMEASUREMENT_1D_H_SEEN #define JOINTMEASUREMENT_1D_H_SEEN /*! * \addtogroup FitBase * @{ */ #include #include #include #include #include #include #include #include #include // ROOT includes #include "Measurement1D.h" #include #include #include #include #include #include #include #include #include #include #include #include // External data fit includes #include "FitEvent.h" #include "FitUtils.h" #include "MeasurementBase.h" #include "PlotUtils.h" #include "StatUtils.h" //******************************************************************** /// 1D Measurement base class. Histogram handling is done in this base layer. class JointMeas1D : public MeasurementBase { //******************************************************************** public: /* Constructor/Deconstuctor */ JointMeas1D(void); virtual ~JointMeas1D(void); /* Setup Functions */ SampleSettings LoadSampleSettings(nuiskey samplekey); /// \brief Setup all configs once initialised /// /// Should be called after all configs have been setup inside fSettings /// container. Handles the processing of inputs and setting up of types. /// Replaces the old 'SetupMeasurement' function. void FinaliseSampleSettings(); /// \brief Read 1D data inputs from a text file. /// /// Inputfile should have the format: \n /// low_binedge_1 bin_content_1 bin_error_1 \n /// low_binedge_2 bin_content_2 bin_error_2 \n /// .... .... .... \n /// high_bin_edge_N 0.0 0.0 virtual void SetDataFromTextFile(std::string datafile); /// \brief Read 1D data inputs from a root file. /// /// inhistfile specifies the path to the root file /// histname specifies the name of the histogram. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ';' so that: \n /// 'myhistfile.root;myhistname' \n /// will also work. virtual void SetDataFromRootFile(std::string inhistfile, std::string histname = ""); /// \brief Set data bin errors to sqrt(entries) /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Sets the data errors as the sqrt of the bin contents /// Should be use for counting experiments virtual void SetPoissonErrors(); /// \brief Make diagonal covariance from data /// /// \warning If no histogram passed, data must be setup first! /// Setup the covariance inputs by taking the data histogram /// errors and setting up a diagonal covariance matrix. /// /// If no data is supplied, fDataHist is used if already set. virtual void SetCovarFromDiagonal(TH1D *data = NULL); /// \brief Read the data covariance from a text file. /// /// Inputfile should have the format: \n /// covariance_11 covariance_12 covariance_13 ... \n /// covariance_21 covariance_22 covariance_23 ... \n /// ... ... ... ... \n /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCovarFromTextFile(std::string covfile, int dim = -1); virtual void SetCovarFromMultipleTextFiles(std::string covfiles, int dim = -1); /// \brief Read the data covariance from a ROOT file. /// /// - covfile specifies the full path to the file /// - histname specifies the name of the covariance object. Both TMatrixDSym /// and TH2D are supported. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCovarFromRootFile(std::string covfile, std::string histname); /// \brief Read the inverted data covariance from a text file. /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCovarInvertFromTextFile(std::string covfile, int dim = -1); /// \brief Read the inverted data covariance from a ROOT file. /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCovarInvertFromRootFile(std::string covfile, std::string histname); /// \brief Read the data correlations from a text file. /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCorrelationFromTextFile(std::string covfile, int dim = -1); /// \brief Read the data correlations from multiple text files. /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of first covfile. virtual void SetCorrelationFromMultipleTextFiles(std::string corrfiles, int dim = -1); /// \brief Read the data correlations from a ROOT file. /// /// \warning REQUIRES DATA TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCorrelationFromRootFile(std::string covfile, std::string histname); /// \brief Try to extract a shape-only matrix from the existing covariance virtual void SetShapeCovar(); /// \brief Read the cholesky decomposed covariance from a text file and turn /// it into a covariance /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCholDecompFromTextFile(std::string covfile, int dim = -1); /// \brief Read the cholesky decomposed covariance from a ROOT file and turn /// it into a covariance /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCholDecompFromRootFile(std::string covfile, std::string histname); /// \brief Scale the data by some scale factor virtual void ScaleData(double scale); /// \brief Scale the covariaince and its invert/decomp by some scale factor. virtual void ScaleCovar(double scale); /// \brief Setup a bin masking histogram and apply masking to data /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Reads in a list of bins in a text file to be masked. Format is: \n /// bin_index_1 1 \n /// bin_index_2 1 \n /// bin_index_3 1 \n /// /// If 0 is given then a bin entry will NOT be masked. So for example: \n\n /// 1 1 \n /// 2 1 \n /// 3 0 \n /// 4 1 \n\n /// Will mask only the 1st, 2nd, and 4th bins. /// /// Masking can be turned on by specifiying the MASK option when creating a /// sample. When this is passed NUISANCE will look in the following locations /// for the mask file: /// - FitPar::Config().GetParS(fName + ".mask") /// - "data/masks/" + fName + ".mask"; virtual void SetBinMask(std::string maskfile); /// \brief Final constructor setup /// \warning Should be called right at the end of the constructor. /// /// Contains a series of checks to ensure the data and inputs have been setup. /// Also creates the MC histograms needed for fitting. virtual void FinaliseMeasurement(); /// \brief Set the current fit options from a string. /// /// This is called twice for each sample, once to set the default /// and once to set the current setting (if anything other than default given) /// /// For this to work properly it requires the default and allowed types to be /// set correctly. These should be specified as a string listing options. /// /// To split up options so that NUISANCE can automatically detect ones that /// are conflicting. Any options separated with the '/' symbol are non /// conflicting and can be given together, whereas any separated with the ',' /// symbol cannot be specified by the end user at the same time. /// /// Default Type Examples: /// - DIAG/FIX = Default option will be a diagonal covariance, with FIXED /// norm. /// - MASK/SHAPE = Default option will be a masked hist, with SHAPE always on. /// /// Allowed Type examples: /// - 'FULL/DIAG/NORM/MASK' = Any of these options can be specified. /// - 'FULL,FREE,SHAPE/MASK/NORM' = User can give either FULL, FREE, or SHAPE /// as on option. MASK and NORM can also be included as options. virtual void SetFitOptions(std::string opt); /* Smearing */ /// \brief Read in smearing matrix from file /// /// Set the smearing matrix from a text file given the size of the matrix virtual void SetSmearingMatrix(std::string smearfile, int truedim, int recodim); /// \brief Apply smearing to MC true to get MC reco /// /// Apply smearing matrix to fMCHist using fSmearingMatrix virtual void ApplySmearingMatrix(void); /* Reconfigure Functions */ /// \brief Create a Measurement1D box /// /// Creates a new 1D variable box containing just fXVar. /// /// This box is the bare minimum required by the JointFCN when /// running fast reconfigures during a routine. /// If for some reason a sample needs extra variables to be saved then /// it should override this function creating its own MeasurementVariableBox /// that contains the extra variables. virtual MeasurementVariableBox *CreateBox() { return new MeasurementVariableBox1D(); }; /// \brief Reset all MC histograms /// /// Resets all standard histograms and those registered to auto /// process to zero. /// /// If extra histograms are not included in auto processing, then they must be /// reset by overriding this function and doing it manually if required. virtual void ResetAll(void); /// \brief Fill MC Histograms from XVar /// /// Fill standard histograms using fXVar, Weight read from the variable box. /// /// WARNING : Any extra MC histograms need to be filled by overriding this /// function, even if they have been set to auto process. virtual void FillHistograms(void); // \brief Convert event rates to final histogram /// /// Apply standard scaling procedure to standard mc histograms to convert from /// raw events to xsec prediction. /// /// If any distributions have been set to auto process /// that is done during this function call, and a differential xsec is /// assumed. If that is not the case this function must be overriden. virtual void ScaleEvents(void); /// \brief Scale MC by a factor=1/norm /// /// Apply a simple normalisation scaling if the option FREE or a /// norm_parameter has been specified in the NUISANCE routine. virtual void ApplyNormScale(double norm); /* Statistical Functions */ /// \brief Get Number of degrees of freedom /// /// Returns the number bins inside the data histogram accounting for /// any bin masking applied. virtual int GetNDOF(void); /// \brief Return Data/MC Likelihood at current state /// /// Returns the likelihood of the data given the current MC prediction. /// Diferent likelihoods definitions are used depending on the FitOptions. virtual double GetLikelihood(void); /* Fake Data */ /// \brief Set the fake data values from either a file, or MC /// /// - Setting from a file "path": \n /// When reading from a file the full path must be given to a standard /// nuisance output. The standard MC histogram should have a name that matches /// this sample for it to be read in. /// \n\n /// - Setting from "MC": \n /// If the MC option is given the current MC prediction is used as fake data. virtual void SetFakeDataValues(std::string fakeOption); /// \brief Reset fake data back to starting fake data /// /// Reset the fake data back to original fake data (Reset back to before /// ThrowCovariance was first called) virtual void ResetFakeData(void); /// \brief Reset fake data back to original data /// /// Reset the data histogram back to the true original dataset for this sample /// before any fake data was defined. virtual void ResetData(void); /// \brief Generate fake data by throwing the covariance. /// /// Can be used on fake MC data or just the original dataset. /// Call ResetFakeData or ResetData to return to values before the throw. virtual void ThrowCovariance(void); /// \brief Throw the data by its assigned errors and assign this to MC /// /// Used when creating data toys by assign the MC to this thrown data /// so that the likelihood is calculated between data and thrown data virtual void ThrowDataToy(void); /* Access Functions */ /// \brief Returns nicely formatted MC Histogram /// /// Format options can also be given in the samplesettings: /// - linecolor /// - linestyle /// - linewidth /// - fillcolor /// - fillstyle /// /// So to have a sample line colored differently in the xml cardfile put: \n /// virtual TH1D *GetMCHistogram(void); /// \brief Returns nicely formatted data Histogram /// /// Format options can also be given in the samplesettings: /// - datacolor /// - datastyle /// - datawidth /// /// So to have a sample data colored differently in the xml cardfile put: \n /// virtual TH1D *GetDataHistogram(void); /// \brief Returns a list of all MC histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. virtual std::vector GetMCList(void); /// \brief Returns a list of all Data histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. virtual std::vector GetDataList(void); /// \brief Returns a list of all Mask histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. virtual std::vector GetMaskList(void); /// \brief Returns a list of all Fine histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. virtual std::vector GetFineList(void); /* Write Functions */ /// \brief Save the current state to the current TFile directory \n /// /// Data/MC are both saved by default. /// A range of other histograms can be saved by setting the /// config option 'drawopts'. /// /// Possible options: \n /// - FINE = Write Fine Histogram \n /// - WEIGHTS = Write Weighted MC Histogram (before scaling) \n /// - FLUX = Write Flux Histogram from MC Input \n /// - EVT = Write Event Histogram from MC Input \n /// - XSEC = Write XSec Histogram from MC Input \n /// - MASK = Write Mask Histogram \n /// - COV = Write Covariance Histogram \n /// - INVCOV = Write Inverted Covariance Histogram \n /// - DECMOP = Write Decomp. Covariance Histogram \n /// - RESIDUAL= Write Resudial Histograms \n /// - RATIO = Write Data/MC Ratio Histograms \n /// - SHAPE = Write MC Shape Histograms norm. to Data \n /// - CANVMC = Build MC Canvas Showing Data, MC, Shape \n /// - MODES = Write PDG Stack \n /// - CANVPDG = Build MC Canvas Showing Data, PDGStack \n /// /// So to save a range of these in parameters/config.xml set: \n /// virtual void Write(std::string drawOpt); virtual void WriteRatioPlot(); virtual void WriteShapePlot(); virtual void WriteShapeRatioPlot(); double TotalIntegratedFlux(std::string intOpt, double low, double high); //* // OLD DEFUNCTIONS // /// OLD FUNCTION virtual void SetupMeasurement(std::string input, std::string type, FitWeight *rw, std::string fkdt); /// OLD FUNCTION virtual void SetupDefaultHist(void); /// OLD FUNCTION virtual void SetDataValues(std::string dataFile); /// OLD FUNCTION virtual void SetDataFromFile(std::string inhistfile, std::string histname); /// OLD FUNCTION virtual void SetDataFromDatabase(std::string inhistfile, std::string histname); /// OLD FUNCTION virtual void SetCovarMatrix(std::string covarFile); /// OLD FUNCTION virtual void SetCovarMatrixFromText(std::string covarFile, int dim, double scale = 1.0); /// OLD FUNCTION virtual void SetCovarMatrixFromCorrText(std::string covarFile, int dim); /// OLD FUNCTION virtual void SetCovarFromDataFile(std::string covarFile, std::string covName, bool FullUnits = false); ////// JOINT MEAS1D Functions ////// /* Reconfigure Functions */ /// Call reconfigure on every sub sample virtual void Reconfigure(); /// Stitch the sub sample plots together to make a final fMCHist after /// reconfigure has been called virtual void MakePlots(); virtual std::vector GetSubSamples(); virtual void ConvertEventRates(); /* Access Functions */ virtual std::vector GetFluxList(); virtual std::vector GetEventRateList(); virtual std::vector 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() { NUIS_ERR(WRN, "XSec histogram not properly implemented for joint measurements."); return MeasurementBase::GetXSecHistogram(); }; virtual TH1D *GetFluxHistogram() { return GetCombinedFlux(); }; protected: // Data TH1D *fDataHist; ///< default data histogram TH1D *fDataOrig; ///< histogram to store original data before throws. TH1D *fDataTrue; ///< histogram to store true dataset std::string fPlotTitles; ///< Plot title x and y for the histograms // MC 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 TH1D *fMCWeighted; ///< Weighted histogram before xsec scaling TH1I *fMaskHist; ///< Mask histogram for neglecting specific bins TMatrixD *fSmearMatrix; ///< Smearing matrix (note, this is not symmetric) TrueModeStack *fMCHist_Modes; ///< Optional True Mode Stack // Statistical TMatrixDSym *covar; ///< Inverted Covariance TMatrixDSym *fFullCovar; ///< Full Covariance TMatrixDSym *fDecomp; ///< Decomposed Covariance TMatrixDSym *fCorrel; ///< Correlation Matrix TMatrixDSym *fShapeCovar; ///< Shape-only covariance TMatrixDSym *fCovar; ///< New FullCovar TMatrixDSym *fInvert; ///< New covar double fNormError; ///< Sample norm error // Fake Data bool fIsFakeData; ///< Flag: is the current data fake from MC std::string fFakeDataInput; ///< Input fake data file path TFile *fFakeDataFile; ///< Input fake data file // Fit specific flags std::string fFitType; ///< Current fit type std::string fAllowedTypes; ///< Fit Types Possible std::string fDefaultTypes; ///< Starting Default Fit Types 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 : keeping norm fixed bool fIsFull; ///< Flag : using full covariaince bool fIsDifXSec; ///< Flag : creating a dif xsec bool fIsChi2; ///< Flag : using Chi2 over LL methods bool fIsSmeared; ///< Flag : Apply smearing? + bool fSaveFine; ///< Flag : Save the MC FINE histogram or not /// OLD STUFF TO REMOVE TH1D *fMCHist_PDG[61]; ///< REMOVE OLD MC PDG Plot // Arrays for data entries Double_t *fXBins; ///< REMOVE xBin edges Double_t *fDataValues; ///< REMOVE data bin contents Double_t *fDataErrors; ///< REMOVE data bin errors Int_t fNDataPointsX; ///< REMOVE number of data points //// JOINT MEAS1D OBJECTS //// std::vector fSubChain; //!< Vector of experimental classes //! that are the sub measurements std::vector fSubInFiles; //!< vector of input files for each of the sub measurements. 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 double fLikelihood; }; /*! @} */ #endif diff --git a/src/FitBase/Measurement1D.cxx b/src/FitBase/Measurement1D.cxx index 1c8487c..2fc8679 100644 --- a/src/FitBase/Measurement1D.cxx +++ b/src/FitBase/Measurement1D.cxx @@ -1,2026 +1,2019 @@ -// Copyright 2016 L. Pickering, P. Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 L. Pickering, P. Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This ile 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 . *******************************************************************************/ #include "Measurement1D.h" //******************************************************************** Measurement1D::Measurement1D(void) { //******************************************************************** // XSec Scalings fScaleFactor = -1.0; fCurrentNorm = 1.0; // Histograms fDataHist = NULL; fDataTrue = NULL; fMCHist = NULL; fMCFine = NULL; fMCWeighted = NULL; fMaskHist = NULL; // Covar covar = NULL; fFullCovar = NULL; fShapeCovar = NULL; fCovar = NULL; fInvert = NULL; fDecomp = NULL; fResidualHist = NULL; fChi2LessBinHist = NULL; // Fake Data fFakeDataInput = ""; fFakeDataFile = NULL; // Options fDefaultTypes = "FIX/FULL/CHI2"; fAllowedTypes = "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/MASK/NOWIDTH"; fIsFix = false; fIsShape = false; fIsFree = false; fIsDiag = false; fIsFull = false; fAddNormPen = false; fIsMask = false; fIsChi2SVD = false; fIsRawEvents = false; fIsNoWidth = false; fIsDifXSec = false; fIsEnu1D = false; fIsWriting = false; + fSaveFine = true; // Inputs fInput = NULL; fRW = NULL; // Extra Histograms fMCHist_Modes = NULL; } //******************************************************************** Measurement1D::~Measurement1D(void) { //******************************************************************** if (fDataHist) delete fDataHist; if (fDataTrue) delete fDataTrue; if (fMCHist) delete fMCHist; if (fMCFine) delete fMCFine; if (fMCWeighted) delete fMCWeighted; if (fMaskHist) delete fMaskHist; if (covar) delete covar; if (fFullCovar) delete fFullCovar; if (fShapeCovar) delete fShapeCovar; if (fCovar) delete fCovar; if (fInvert) delete fInvert; if (fDecomp) delete fDecomp; delete fResidualHist; delete fChi2LessBinHist; } //******************************************************************** void Measurement1D::FinaliseSampleSettings() { //******************************************************************** MeasurementBase::FinaliseSampleSettings(); // Setup naming + renaming fName = fSettings.GetName(); fSettings.SetS("originalname", fName); if (fSettings.Has("rename")) { fName = fSettings.GetS("rename"); fSettings.SetS("name", fName); } // Setup all other options NUIS_LOG(SAM, "Finalising Sample Settings: " << fName); if ((fSettings.GetS("originalname").find("Evt") != std::string::npos)) { fIsRawEvents = true; NUIS_LOG(SAM, "Found event rate measurement but using poisson likelihoods."); } if (fSettings.GetS("originalname").find("XSec_1DEnu") != std::string::npos) { fIsEnu1D = true; - NUIS_LOG(SAM, "::" << fName << "::"); NUIS_LOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, " << "not flux averaged!"); } if (fIsEnu1D && fIsRawEvents) { NUIS_ERR(FTL, "Found 1D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!"); NUIS_ERR(FTL, "Check experiment constructor for " << fName << " and correct this!"); NUIS_ERR(FTL, "I live in " << __FILE__ << ":" << __LINE__); throw; } if (!fRW) fRW = FitBase::GetRW(); if (!fInput and !fIsJoint) SetupInputs(fSettings.GetS("input")); // Setup options SetFitOptions(fDefaultTypes); // defaults SetFitOptions(fSettings.GetS("type")); // user specified EnuMin = GeneralUtils::StrToDbl(fSettings.GetS("enu_min")); EnuMax = GeneralUtils::StrToDbl(fSettings.GetS("enu_max")); } //******************************************************************** void Measurement1D::CreateDataHistogram(int dimx, double *binx) { //******************************************************************** if (fDataHist) delete fDataHist; fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), dimx, binx); } //******************************************************************** void Measurement1D::SetDataFromTextFile(std::string datafile) { //******************************************************************** NUIS_LOG(SAM, "Reading data from text file: " << datafile); fDataHist = PlotUtils::GetTH1DFromFile( datafile, fSettings.GetName() + "_data", fSettings.GetFullTitles()); } //******************************************************************** void Measurement1D::SetDataFromRootFile(std::string datafile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading data from root file: " << datafile << ";" << histname); fDataHist = PlotUtils::GetTH1DFromRootFile(datafile, histname); fDataHist->SetNameTitle((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str()); return; }; //******************************************************************** void Measurement1D::SetEmptyData() { //******************************************************************** fDataHist = new TH1D("EMPTY_DATA", "EMPTY_DATA", 1, 0.0, 1.0); } //******************************************************************** void Measurement1D::SetPoissonErrors() { //******************************************************************** if (!fDataHist) { NUIS_ERR(FTL, "Need a data hist to setup possion errors! "); NUIS_ERR(FTL, "Setup Data First!"); throw; } for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i + 1, sqrt(fDataHist->GetBinContent(i + 1))); } } //******************************************************************** void Measurement1D::SetCovarFromDiagonal(TH1D *data) { //******************************************************************** if (!data and fDataHist) { data = fDataHist; } if (data) { NUIS_LOG(SAM, "Setting diagonal covariance for: " << data->GetName()); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(data); covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } else { NUIS_ABORT("No data input provided to set diagonal covar from!"); } - - // if (!fIsDiag) { - // ERR(FTL) << "SetCovarMatrixFromDiag called for measurement " - // << "that is not set as diagonal." ); - // throw; - // } } //******************************************************************** void Measurement1D::SetCovarFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } NUIS_LOG(SAM, "Reading covariance from text file: " << covfile); fFullCovar = StatUtils::GetCovarFromTextFile(covfile, dim); covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement1D::SetCovarFromMultipleTextFiles(std::string covfiles, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } std::vector covList = GeneralUtils::ParseToStr(covfiles, ";"); fFullCovar = new TMatrixDSym(dim); for (uint i = 0; i < covList.size(); ++i) { NUIS_LOG(SAM, "Reading covariance from text file: " << covList[i]); TMatrixDSym *temp_cov = StatUtils::GetCovarFromTextFile(covList[i], dim); (*fFullCovar) += (*temp_cov); delete temp_cov; } covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement1D::SetCovarFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading covariance from text file: " << covfile << ";" << histname); fFullCovar = StatUtils::GetCovarFromRootFile(covfile, histname); covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement1D::SetCovarInvertFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile); covar = StatUtils::GetCovarFromTextFile(covfile, dim); fFullCovar = StatUtils::GetInvert(covar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement1D::SetCovarInvertFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile << ";" << histname); covar = StatUtils::GetCovarFromRootFile(covfile, histname); fFullCovar = StatUtils::GetInvert(covar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement1D::SetCorrelationFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) dim = fDataHist->GetNbinsX(); NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";" << dim); TMatrixDSym *correlation = StatUtils::GetCovarFromTextFile(covfile, dim); if (!fDataHist) { NUIS_ABORT("Trying to set correlations from text file but there is no " "data to build it from. \n" << "In constructor make sure data is set before " "SetCorrelationFromTextFile is called. \n"); } // Fill covar from data errors and correlations fFullCovar = new TMatrixDSym(dim); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = (*correlation)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } // Fill other covars. covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete correlation; } //******************************************************************** void Measurement1D::SetCorrelationFromMultipleTextFiles(std::string corrfiles, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } std::vector corrList = GeneralUtils::ParseToStr(corrfiles, ";"); fFullCovar = new TMatrixDSym(dim); for (uint i = 0; i < corrList.size(); ++i) { NUIS_LOG(SAM, "Reading covariance from text file: " << corrList[i]); TMatrixDSym *temp_cov = StatUtils::GetCovarFromTextFile(corrList[i], dim); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*temp_cov)(i, j) = (*temp_cov)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } (*fFullCovar) += (*temp_cov); delete temp_cov; } covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement1D::SetCorrelationFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";" << histname); TMatrixDSym *correlation = StatUtils::GetCovarFromRootFile(covfile, histname); if (!fDataHist) { NUIS_ABORT("Trying to set correlations from text file but there is no " "data to build it from. \n" << "In constructor make sure data is set before " "SetCorrelationFromTextFile is called. \n"); } // Fill covar from data errors and correlations fFullCovar = new TMatrixDSym(fDataHist->GetNbinsX()); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = (*correlation)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } // Fill other covars. covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete correlation; } //******************************************************************** void Measurement1D::SetCholDecompFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) { dim = fDataHist->GetNbinsX(); } NUIS_LOG(SAM, "Reading cholesky from text file: " << covfile); TMatrixD *temp = StatUtils::GetMatrixFromTextFile(covfile, dim, dim); TMatrixD *trans = (TMatrixD *)temp->Clone(); trans->T(); (*trans) *= (*temp); fFullCovar = new TMatrixDSym(dim, trans->GetMatrixArray(), ""); covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete temp; delete trans; } //******************************************************************** void Measurement1D::SetCholDecompFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading cholesky decomp from root file: " << covfile << ";" << histname); TMatrixD *temp = StatUtils::GetMatrixFromRootFile(covfile, histname); TMatrixD *trans = (TMatrixD *)temp->Clone(); trans->T(); (*trans) *= (*temp); fFullCovar = new TMatrixDSym(temp->GetNrows(), trans->GetMatrixArray(), ""); covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete temp; delete trans; } void Measurement1D::SetShapeCovar() { // Return if this is missing any pre-requisites if (!fFullCovar) return; if (!fDataHist) return; // Also return if it's bloody stupid under the circumstances if (fIsDiag) return; fShapeCovar = StatUtils::ExtractShapeOnlyCovar(fFullCovar, fDataHist); return; } //******************************************************************** void Measurement1D::ScaleData(double scale) { //******************************************************************** fDataHist->Scale(scale); } //******************************************************************** void Measurement1D::ScaleDataErrors(double scale) { //******************************************************************** for (int i = 0; i < fDataHist->GetNbinsX(); i++) { fDataHist->SetBinError(i + 1, fDataHist->GetBinError(i + 1) * scale); } } //******************************************************************** void Measurement1D::ScaleCovar(double scale) { //******************************************************************** (*fFullCovar) *= scale; (*covar) *= 1.0 / scale; (*fDecomp) *= sqrt(scale); } //******************************************************************** void Measurement1D::SetBinMask(std::string maskfile) { //******************************************************************** if (!fIsMask) return; NUIS_LOG(SAM, "Reading bin mask from file: " << maskfile); // Create a mask histogram with dim of data int nbins = fDataHist->GetNbinsX(); fMaskHist = new TH1I((fSettings.GetName() + "_BINMASK").c_str(), (fSettings.GetName() + "_BINMASK; Bin; Mask?").c_str(), nbins, 0, nbins); std::string line; std::ifstream mask(maskfile.c_str(), std::ifstream::in); if (!mask.is_open()) { NUIS_ABORT("Cannot find mask file."); } while (std::getline(mask >> std::ws, line, '\n')) { std::vector entries = GeneralUtils::ParseToInt(line, " "); // Skip lines with poorly formatted lines if (entries.size() < 2) { NUIS_LOG(WRN, "Measurement1D::SetBinMask(), couldn't parse line: " << line); continue; } // The first index should be the bin number, the second should be the mask // value. int val = 0; if (entries[1] > 0) val = 1; fMaskHist->SetBinContent(entries[0], val); } // Apply masking by setting masked data bins to zero PlotUtils::MaskBins(fDataHist, fMaskHist); return; } //******************************************************************** void Measurement1D::FinaliseMeasurement() { //******************************************************************** NUIS_LOG(SAM, "Finalising Measurement: " << fName); if (fSettings.GetB("onlymc")) { if (fDataHist) delete fDataHist; fDataHist = new TH1D("empty_data", "empty_data", 1, 0.0, 1.0); } // Make sure data is setup if (!fDataHist) { NUIS_ABORT("No data has been setup inside " << fName << " constructor!"); } // Make sure covariances are setup if (!fFullCovar) { fIsDiag = true; SetCovarFromDiagonal(fDataHist); } else if (fIsDiag) { // Have covariance but also set Diag NUIS_LOG(SAM, "Have full covariance for sample " << GetName() << " but only using diagonal elements for likelihood"); int nbins = fFullCovar->GetNcols(); for (int i = 0; i < nbins; ++i) { for (int j = 0; j < nbins; ++j) { if (i != j) { (*fFullCovar)[i][j] = 0; } } } delete covar; covar = NULL; delete fDecomp; fDecomp = NULL; } if (!covar) { covar = StatUtils::GetInvert(fFullCovar, true); } if (!fDecomp) { fDecomp = StatUtils::GetDecomp(fFullCovar); } // Push the diagonals of fFullCovar onto the data histogram // Comment this out until the covariance/data scaling is consistent! StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38); // If shape only, set covar and fDecomp using the shape-only matrix (if set) if (fIsShape && fShapeCovar && FitPar::Config().GetParB("UseShapeCovar")) { if (covar) delete covar; covar = StatUtils::GetInvert(fShapeCovar, true); if (fDecomp) delete fDecomp; fDecomp = StatUtils::GetDecomp(fFullCovar); fUseShapeNormDecomp = FitPar::Config().GetParB("UseShapeNormDecomp"); if (fUseShapeNormDecomp) { fNormError = 0; // From https://arxiv.org/pdf/2003.00088.pdf for (int i = 0; i < fFullCovar->GetNcols(); ++i) { for (int j = 0; j < fFullCovar->GetNcols(); ++j) { fNormError += (*fFullCovar)[i][j]; } } NUIS_LOG(SAM, "Sample: " << fName << ", using shape/norm decomp with norm error: " << fNormError); } } // Setup fMCHist from data fMCHist = (TH1D *)fDataHist->Clone(); fMCHist->SetNameTitle((fSettings.GetName() + "_MC").c_str(), (fSettings.GetFullTitles()).c_str()); fMCHist->Reset(); // Setup fMCFine fMCFine = new TH1D("mcfine", "mcfine", fDataHist->GetNbinsX() * 8, fMCHist->GetBinLowEdge(1), fMCHist->GetBinLowEdge(fDataHist->GetNbinsX() + 1)); fMCFine->SetNameTitle((fSettings.GetName() + "_MC_FINE").c_str(), (fSettings.GetFullTitles()).c_str()); fMCFine->Reset(); // Setup MC Stat fMCStat = (TH1D *)fMCHist->Clone(); fMCStat->Reset(); // Search drawopts for possible types to include by default std::string drawopts = FitPar::Config().GetParS("drawopts"); if (drawopts.find("MODES") != std::string::npos) { fMCHist_Modes = new TrueModeStack((fSettings.GetName() + "_MODES").c_str(), ("True Channels"), fMCHist); fMCHist_Modes ->SetTitleX(fDataHist->GetXaxis()->GetTitle()); fMCHist_Modes ->SetTitleY(fDataHist->GetYaxis()->GetTitle()); SetAutoProcessTH1(fMCHist_Modes, kCMD_Reset, kCMD_Norm, kCMD_Write); } if (fSettings.Has("maskfile") && fSettings.Has("maskhist")) { fMaskHist = dynamic_cast(PlotUtils::GetTH1FromRootFile( fSettings.GetS("maskfile"), fSettings.GetS("maskhist"))); fIsMask = bool(fMaskHist); NUIS_LOG(SAM, "Loaded mask histogram: " << fSettings.GetS("maskhist") << " from " << fSettings.GetS("maskfile")); } else if (fIsMask) { // Setup bin masks using sample name std::string curname = fName; std::string origname = fSettings.GetS("originalname"); // Check rename.mask std::string maskloc = FitPar::Config().GetParDIR(curname + ".mask"); // Check origname.mask if (maskloc.empty()) maskloc = FitPar::Config().GetParDIR(origname + ".mask"); // Check database if (maskloc.empty()) { maskloc = FitPar::GetDataBase() + "/masks/" + origname + ".mask"; } // Setup Bin Mask SetBinMask(maskloc); } if (fScaleFactor < 0) { NUIS_ERR(FTL, "I found a negative fScaleFactor in " << __FILE__ << ":" << __LINE__); NUIS_ERR(FTL, "fScaleFactor = " << fScaleFactor); NUIS_ERR(FTL, "EXITING"); throw; } if (fAddNormPen) { if (!fUseShapeNormDecomp) { fNormError = fSettings.GetNormError(); } if (fNormError <= 0.0) { NUIS_ERR(FTL, "Norm error for class " << fName << " is 0.0!"); NUIS_ERR(FTL, "If you want to use it please add fNormError=VAL"); throw; } } // Create and fill Weighted Histogram if (!fMCWeighted) { fMCWeighted = (TH1D *)fMCHist->Clone(); fMCWeighted->SetNameTitle((fName + "_MCWGHTS").c_str(), (fName + "_MCWGHTS" + fPlotTitles).c_str()); fMCWeighted->GetYaxis()->SetTitle("Weighted Events"); } } //******************************************************************** void Measurement1D::SetFitOptions(std::string opt) { //******************************************************************** // Do nothing if default given if (opt == "DEFAULT") return; // CHECK Conflicting Fit Options std::vector fit_option_allow = GeneralUtils::ParseToStr(fAllowedTypes, "/"); for (UInt_t i = 0; i < fit_option_allow.size(); i++) { std::vector 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) { NUIS_ABORT( "ERROR: Conflicting fit options provided: " << opt << std::endl << "Conflicting group = " << fit_option_section.at(i) << std::endl << "You should only supply one of these options in card file."); } } } // Check all options are allowed std::vector 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) { NUIS_ERR(WRN, "ERROR: Fit Option '" << fit_options_input.at(i) << "' Provided is not allowed for this measurement."); NUIS_ERR(WRN, "Fit Options should be provided as a '/' separated list " "(e.g. FREE/DIAG/NORM)"); NUIS_ABORT("Available options for " << fName << " are '" << fAllowedTypes << "'"); } } // 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; NUIS_ERR(FTL, "No other LIKELIHOODS properly supported!"); NUIS_ERR(FTL, "Try to use a chi2!"); throw; } else { fIsChi2 = true; } // EXTRAS if (opt.find("RAW") != std::string::npos) fIsRawEvents = true; if (opt.find("NOWIDTH") != std::string::npos) fIsNoWidth = 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::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(), std::ifstream::in); // Note that the smearing matrix may be rectangular. fSmearMatrix = new TMatrixD(truedim, recodim); if (smear.is_open()) { NUIS_LOG(SAM, "Reading smearing matrix from file: " << smearfile); } else { NUIS_ABORT("Smearing matrix provided is incorrect: " << smearfile); } while (std::getline(smear >> std::ws, line, '\n')) { int column = 0; std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { (*fSmearMatrix)(row, column) = (*iter) / 100.; // Convert to fraction from // percentage (this may not be // general enough) column++; } row++; } return; } //******************************************************************** void Measurement1D::ApplySmearingMatrix() { //******************************************************************** if (!fSmearMatrix) { NUIS_ERR(WRN, fName << ": attempted to apply smearing matrix, but none was set"); 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); } smeared->SetBinContent(rbin + 1, rBinVal); } fMCHist = (TH1D *)smeared->Clone(); return; } /* Reconfigure LOOP */ //******************************************************************** void Measurement1D::ResetAll() { //******************************************************************** fMCHist->Reset(); fMCFine->Reset(); fMCStat->Reset(); return; }; //******************************************************************** void Measurement1D::FillHistograms() { //******************************************************************** if (Signal) { NUIS_LOG(DEB, "Fill MCHist: " << fXVar << ", " << Weight); fMCHist->Fill(fXVar, Weight); fMCFine->Fill(fXVar, Weight); fMCStat->Fill(fXVar, 1.0); if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, fXVar, Weight); } return; }; //******************************************************************** void Measurement1D::ScaleEvents() { //******************************************************************** // Fill MCWeighted; // for (int i = 0; i < fMCHist->GetNbinsX(); i++) { // fMCWeighted->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1)); // fMCWeighted->SetBinError(i + 1, fMCHist->GetBinError(i + 1)); // } // Setup Stat ratios for MC and MC Fine double *statratio = new double[fMCHist->GetNbinsX()]; for (int i = 0; i < fMCHist->GetNbinsX(); i++) { if (fMCHist->GetBinContent(i + 1) != 0) { statratio[i] = fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1); } else { statratio[i] = 0.0; } } double *statratiofine = new double[fMCFine->GetNbinsX()]; for (int i = 0; i < fMCFine->GetNbinsX(); i++) { if (fMCFine->GetBinContent(i + 1) != 0) { statratiofine[i] = fMCFine->GetBinError(i + 1) / fMCFine->GetBinContent(i + 1); } else { statratiofine[i] = 0.0; } } // Scaling for raw event rates if (fIsRawEvents) { double datamcratio = fDataHist->Integral() / fMCHist->Integral(); fMCHist->Scale(datamcratio); fMCFine->Scale(datamcratio); if (fMCHist_Modes) fMCHist_Modes->Scale(datamcratio); // Scaling for XSec as function of Enu } else if (fIsEnu1D) { PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); if (fMCHist_Modes) { // Loop over the modes fMCHist_Modes->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); // PlotUtils::FluxUnfoldedScaling(fMCHist_Modes, GetFluxHistogram(), // GetEventHistogram(), fScaleFactor, // fNEvents); } } else if (fIsNoWidth) { fMCHist->Scale(fScaleFactor); fMCFine->Scale(fScaleFactor); if (fMCHist_Modes) fMCHist_Modes->Scale(fScaleFactor); // Any other differential scaling } else { fMCHist->Scale(fScaleFactor, "width"); fMCFine->Scale(fScaleFactor, "width"); if (fMCHist_Modes) fMCHist_Modes->Scale(fScaleFactor, "width"); } // Proper error scaling - ROOT Freaks out with xsec weights sometimes for (int i = 0; i < fMCStat->GetNbinsX(); i++) { fMCHist->SetBinError(i + 1, fMCHist->GetBinContent(i + 1) * statratio[i]); } for (int i = 0; i < fMCFine->GetNbinsX(); i++) { fMCFine->SetBinError(i + 1, fMCFine->GetBinContent(i + 1) * statratiofine[i]); } // Clean up delete[] statratio; delete[] statratiofine; return; }; //******************************************************************** void Measurement1D::ApplyNormScale(double norm) { //******************************************************************** fCurrentNorm = norm; fMCHist->Scale(1.0 / norm); fMCFine->Scale(1.0 / norm); return; }; /* Statistic Functions - Outsources to StatUtils */ //******************************************************************** int Measurement1D::GetNDOF() { //******************************************************************** int ndof = fDataHist->GetNbinsX(); if (fMaskHist and fIsMask) ndof -= fMaskHist->Integral(); return ndof; } //******************************************************************** double Measurement1D::GetLikelihood() { //******************************************************************** // If this is for a ratio, there is no data histogram to compare to! if (fNoData || !fDataHist) return 0.; // Apply Masking to MC if Required. if (fIsMask and fMaskHist) { PlotUtils::MaskBins(fMCHist, fMaskHist); } // Sort Shape Scaling double scaleF = 0.0; // TODO Include !fIsRawEvents if (fIsShape) { // Don't renorm based on width if we are using ShapeNormDecomp if (fUseShapeNormDecomp) { if (fMCHist->Integral(1, fMCHist->GetNbinsX())) { scaleF = fDataHist->Integral(1, fDataHist->GetNbinsX()) / fMCHist->Integral(1, fMCHist->GetNbinsX()); fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); } } else { if (fMCHist->Integral(1, fMCHist->GetNbinsX(), "width")) { scaleF = fDataHist->Integral(1, fDataHist->GetNbinsX(), "width") / fMCHist->Integral(1, fMCHist->GetNbinsX(), "width"); fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); } } } // Likelihood Calculation double stat = 0.; if (fIsChi2) { if (fIsRawEvents) { stat = StatUtils::GetChi2FromEventRate(fDataHist, fMCHist, fMaskHist); } else if (fIsDiag) { stat = StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMaskHist); } else if (!fIsDiag and !fIsRawEvents) { stat = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMaskHist, 1, 1E76, fIsWriting ? fResidualHist : NULL); if (fChi2LessBinHist && fIsWriting) { for (int xi = 0; xi < fDataHist->GetNbinsX(); ++xi) { TH1I *binmask = fMaskHist ? static_cast(fMaskHist->Clone("mask")) : new TH1I("mask", "", fDataHist->GetNbinsX(), 0, fDataHist->GetNbinsX()); binmask->SetDirectory(NULL); binmask->SetBinContent(xi + 1, 1); fChi2LessBinHist->SetBinContent( xi + 1, StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, binmask)); delete binmask; } } } } // Sort Penalty Terms if (fAddNormPen) { if (fUseShapeNormDecomp) { // if shape norm, then add the norm penalty from // https://arxiv.org/pdf/2003.00088.pdf TH1 *masked_data = StatUtils::ApplyHistogramMasking(fDataHist, fMaskHist); TH1 *masked_mc = StatUtils::ApplyHistogramMasking(fMCHist, fMaskHist); masked_mc->Scale(scaleF); NUIS_LOG(REC, "Shape Norm Decomp mcinteg: " << masked_mc->Integral() * 1E38 << ", datainteg: " << masked_data->Integral() * 1E38 << ", normerror: " << fNormError); double normpen = std::pow((masked_data->Integral() - masked_mc->Integral()) * 1E38, 2) / fNormError; masked_data->SetDirectory(NULL); delete masked_data; masked_mc->SetDirectory(NULL); delete masked_mc; NUIS_LOG(SAM, "Using Shape/Norm decomposition: Norm penalty " << normpen << " on shape penalty of " << stat); stat += normpen; } else { double penalty = (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); } fLikelihood = stat; return stat; } /* Fake Data Functions */ //******************************************************************** void Measurement1D::SetFakeDataValues(std::string fakeOption) { //******************************************************************** // Setup original/datatrue TH1D *tempdata = (TH1D *)fDataHist->Clone(); if (!fIsFakeData) { fIsFakeData = true; // Make a copy of the original data histogram. if (!fDataOrig) fDataOrig = (TH1D *)fDataHist->Clone((fName + "_data_original").c_str()); } else { ResetFakeData(); } // Setup Inputs fFakeDataInput = fakeOption; NUIS_LOG(SAM, "Setting fake data from : " << fFakeDataInput); // From MC if (fFakeDataInput.compare("MC") == 0) { fDataHist = (TH1D *)fMCHist->Clone((fName + "_MC").c_str()); // Fake File } else { if (!fFakeDataFile) fFakeDataFile = new TFile(fFakeDataInput.c_str(), "READ"); fDataHist = (TH1D *)fFakeDataFile->Get((fName + "_MC").c_str()); } // Setup Data Hist fDataHist->SetNameTitle((fName + "_FAKE").c_str(), (fName + fPlotTitles).c_str()); // Replace Data True if (fDataTrue) delete fDataTrue; fDataTrue = (TH1D *)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_FAKE_TRUE").c_str(), (fName + fPlotTitles).c_str()); // Make a new covariance for fake data hist. 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); alpha_j = fDataHist->GetBinContent(j + 1) / tempdata->GetBinContent(j + 1); (*fFullCovar)(i, j) = alpha_i * alpha_j * (*fFullCovar)(i, j); } } // Setup Covariances if (covar) delete covar; covar = StatUtils::GetInvert(fFullCovar, true); if (fDecomp) delete fDecomp; fDecomp = StatUtils::GetDecomp(fFullCovar); delete tempdata; return; }; //******************************************************************** void Measurement1D::ResetFakeData() { //******************************************************************** if (fIsFakeData) { if (fDataHist) delete fDataHist; fDataHist = (TH1D *)fDataTrue->Clone((fSettings.GetName() + "_FKDAT").c_str()); } } //******************************************************************** void Measurement1D::ResetData() { //******************************************************************** if (fIsFakeData) { if (fDataHist) delete fDataHist; fDataHist = (TH1D *)fDataOrig->Clone((fSettings.GetName() + "_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. if (!fDataTrue) fDataTrue = (TH1D *)fDataHist->Clone(); if (fDataHist) delete fDataHist; fDataHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); return; }; //******************************************************************** void Measurement1D::ThrowDataToy() { //******************************************************************** if (!fDataTrue) fDataTrue = (TH1D *)fDataHist->Clone(); if (fMCHist) delete fMCHist; fMCHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); } /* Access Functions */ //******************************************************************** TH1D *Measurement1D::GetMCHistogram() { //******************************************************************** if (!fMCHist) return fMCHist; std::ostringstream chi2; chi2 << std::setprecision(5) << this->GetLikelihood(); int linecolor = kRed; int linestyle = 1; int linewidth = 1; int fillcolor = 0; int fillstyle = 1001; // if (fSettings.Has("linecolor")) linecolor = fSettings.GetI("linecolor"); // if (fSettings.Has("linestyle")) linestyle = fSettings.GetI("linestyle"); // if (fSettings.Has("linewidth")) linewidth = fSettings.GetI("linewidth"); // if (fSettings.Has("fillcolor")) fillcolor = fSettings.GetI("fillcolor"); // if (fSettings.Has("fillstyle")) fillstyle = fSettings.GetI("fillstyle"); fMCHist->SetTitle(chi2.str().c_str()); fMCHist->SetLineColor(linecolor); fMCHist->SetLineStyle(linestyle); fMCHist->SetLineWidth(linewidth); fMCHist->SetFillColor(fillcolor); fMCHist->SetFillStyle(fillstyle); return fMCHist; }; //******************************************************************** TH1D *Measurement1D::GetDataHistogram() { //******************************************************************** if (!fDataHist) return fDataHist; int datacolor = kBlack; int datastyle = 1; int datawidth = 1; // if (fSettings.Has("datacolor")) datacolor = fSettings.GetI("datacolor"); // if (fSettings.Has("datastyle")) datastyle = fSettings.GetI("datastyle"); // if (fSettings.Has("datawidth")) datawidth = fSettings.GetI("datawidth"); fDataHist->SetLineColor(datacolor); fDataHist->SetLineWidth(datawidth); fDataHist->SetMarkerStyle(datastyle); return fDataHist; }; /* Write Functions */ // Save all the histograms at once //******************************************************************** void Measurement1D::Write(std::string drawOpt) { //******************************************************************** // Get Draw Options drawOpt = FitPar::Config().GetParS("drawopts"); // Write Settigns if (drawOpt.find("SETTINGS") != std::string::npos) { fSettings.Set("#chi^{2}", fLikelihood); fSettings.Set("NDOF", this->GetNDOF()); fSettings.Set("#chi^{2}/NDOF", fLikelihood / this->GetNDOF()); fSettings.Write(); } // Write Data/MC if (drawOpt.find("DATA") != std::string::npos) GetDataList().at(0)->Write(); if (drawOpt.find("MC") != std::string::npos) { GetMCList().at(0)->Write(); if ((fEvtRateScaleFactor != 0xdeadbeef) && GetMCList().at(0)) { TH1D *PredictedEvtRate = static_cast(GetMCList().at(0)->Clone()); PredictedEvtRate->Scale(fEvtRateScaleFactor); PredictedEvtRate->GetYaxis()->SetTitle("Predicted event rate"); PredictedEvtRate->Write(); } } // Write Fine Histogram - if (drawOpt.find("FINE") != std::string::npos) + if (fSaveFine && drawOpt.find("FINE") != std::string::npos) GetFineList().at(0)->Write(); // Write Weighted Histogram if (drawOpt.find("WEIGHTS") != std::string::npos && fMCWeighted) fMCWeighted->Write(); // Save Flux/Evt if no event manager if (!FitPar::Config().GetParB("EventManager")) { if (drawOpt.find("FLUX") != std::string::npos && GetFluxHistogram()) GetFluxHistogram()->Write(); if (drawOpt.find("EVT") != std::string::npos && GetEventHistogram()) GetEventHistogram()->Write(); if (drawOpt.find("XSEC") != std::string::npos && GetEventHistogram()) GetXSecHistogram()->Write(); } // Write Mask if (fIsMask && (drawOpt.find("MASK") != std::string::npos)) { fMaskHist->Write(); } // Write Covariances if (drawOpt.find("COV") != std::string::npos && fFullCovar) { PlotUtils::GetFullCovarPlot(fFullCovar, fSettings.GetName())->Write(); } if (drawOpt.find("INVCOV") != std::string::npos && covar) { PlotUtils::GetInvCovarPlot(covar, fSettings.GetName())->Write(); } if (drawOpt.find("DECOMP") != std::string::npos && fDecomp) { PlotUtils::GetDecompCovarPlot(fDecomp, fSettings.GetName())->Write(); } // // Likelihood residual plots // if (drawOpt.find("RESIDUAL") != std::string::npos) { // WriteResidualPlots(); // } // Ratio and Shape Plots if (drawOpt.find("RATIO") != std::string::npos) { WriteRatioPlot(); } if (drawOpt.find("SHAPE") != std::string::npos) { WriteShapePlot(); if (drawOpt.find("RATIO") != std::string::npos) WriteShapeRatioPlot(); } // // RATIO // if (drawOpt.find("CANVMC") != std::string::npos) { // TCanvas* c1 = WriteMCCanvas(fDataHist, fMCHist); // c1->Write(); // delete c1; // } // // PDG // if (drawOpt.find("CANVPDG") != std::string::npos && fMCHist_Modes) { // TCanvas* c2 = WritePDGCanvas(fDataHist, fMCHist, fMCHist_Modes); // c2->Write(); // delete c2; // } if (fIsChi2 && !fIsDiag) { fResidualHist = (TH1D *)fMCHist->Clone((fName + "_RESIDUAL").c_str()); fResidualHist->GetYaxis()->SetTitle("#Delta#chi^{2}"); fResidualHist->Reset(); fChi2LessBinHist = (TH1D *)fMCHist->Clone((fName + "_Chi2NMinusOne").c_str()); fChi2LessBinHist->GetYaxis()->SetTitle("Total #chi^{2} without bin_{i}"); fChi2LessBinHist->Reset(); fIsWriting = true; (void)GetLikelihood(); fIsWriting = false; fResidualHist->Write((fName + "_RESIDUAL").c_str()); fChi2LessBinHist->Write((fName + "_Chi2NMinusOne").c_str()); } // Write Extra Histograms AutoWriteExtraTH1(); WriteExtraHistograms(); // Returning NUIS_LOG(SAM, "Written Histograms: " << fName); return; } //******************************************************************** void Measurement1D::WriteRatioPlot() { //******************************************************************** // Setup mc data ratios TH1D *dataRatio = (TH1D *)fDataHist->Clone((fName + "_data_RATIO").c_str()); TH1D *mcRatio = (TH1D *)fMCHist->Clone((fName + "_MC_RATIO").c_str()); // Extra MC Data Ratios for (int i = 0; i < mcRatio->GetNbinsX(); i++) { dataRatio->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) / fMCHist->GetBinContent(i + 1)); dataRatio->SetBinError(i + 1, fDataHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1)); mcRatio->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1) / fMCHist->GetBinContent(i + 1)); mcRatio->SetBinError(i + 1, fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1)); } // Write ratios mcRatio->Write(); dataRatio->Write(); delete mcRatio; delete dataRatio; } //******************************************************************** void Measurement1D::WriteShapePlot() { //******************************************************************** TH1D *mcShape = (TH1D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); TH1D *dataShape = (TH1D *)fDataHist->Clone((fName + "_data_SHAPE").c_str()); // Set the shape covariance to calculate the chi2 if (!fShapeCovar) SetShapeCovar(); // Don't check error if (fShapeCovar) StatUtils::SetDataErrorFromCov(dataShape, fShapeCovar, 1E-38, false); double shapeScale = 1.0; 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); mcShape->Write(); dataShape->Write(); delete mcShape; } //******************************************************************** void Measurement1D::WriteShapeRatioPlot() { //******************************************************************** // Get a mcshape histogram TH1D *mcShape = (TH1D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); double shapeScale = 1.0; if (fIsRawEvents) { shapeScale = fDataHist->Integral() / fMCHist->Integral(); } else { shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); } mcShape->Scale(shapeScale); // Create shape ratio histograms TH1D *mcShapeRatio = (TH1D *)mcShape->Clone((fName + "_MC_SHAPE_RATIO").c_str()); TH1D *dataShapeRatio = (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); mcShapeRatio->Write(); dataShapeRatio->Write(); delete mcShapeRatio; delete dataShapeRatio; } //// CRAP TO BE REMOVED //******************************************************************** void Measurement1D::SetupMeasurement(std::string inputfile, std::string type, FitWeight *rw, std::string fkdt) { //******************************************************************** nuiskey samplekey = Config::CreateKey("sample"); samplekey.Set("name", fName); samplekey.Set("type", type); samplekey.Set("input", inputfile); fSettings = LoadSampleSettings(samplekey); // 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; NUIS_LOG(SAM, "Found event rate measurement but fIsRawEvents == false!"); NUIS_LOG(SAM, "Overriding this and setting fIsRawEvents == true!"); } fIsEnu1D = false; if (fName.find("XSec_1DEnu") != std::string::npos) { fIsEnu1D = true; - NUIS_LOG(SAM, "::" << fName << "::"); NUIS_LOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, " "not flux averaged!"); } if (fIsEnu1D && fIsRawEvents) { NUIS_ERR(FTL, "Found 1D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!"); NUIS_ERR(FTL, "Check experiment constructor for " << fName << " and correct this!"); NUIS_ERR(FTL, "I live in " << __FILE__ << ":" << __LINE__); throw; } fRW = rw; if (!fInput and !fIsJoint) 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 ); // FinaliseMeasurement(); } //******************************************************************** 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); } fMCHist_Modes = new TrueModeStack((fName + "_MODES").c_str(), ("True Channels"), fMCHist); SetAutoProcessTH1(fMCHist_Modes, kCMD_Reset, kCMD_Norm, kCMD_Write); return; } //******************************************************************** void Measurement1D::SetDataValues(std::string dataFile) { //******************************************************************** // Override this function if the input file isn't in a suitable format NUIS_LOG(SAM, "Reading data from: " << dataFile.c_str()); 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) { //******************************************************************** NUIS_LOG(SAM, "Filling histogram from " << inhistfile << "->" << histname); 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) { //******************************************************************** NUIS_LOG(SAM, "Filling histogram from " << inhistfile << "->" << histname); 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 *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()); if (!covOption.compare("SUB")) fFullCovarPlot = (TH2D *)tempFile->Get((covName + "cov").c_str()); else if (!covOption.compare("FULL")) fFullCovarPlot = (TH2D *)tempFile->Get("fullcov"); else { NUIS_ERR(WRN, "Incorrect thrown_covariance option in parameters."); } 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) { //******************************************************************** // Make a counter to track the line number int row = 0; std::string line; std::ifstream covarread(covarFile.c_str(), std::ifstream::in); this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); if (covarread.is_open()) { NUIS_LOG(SAM, "Reading covariance matrix from file: " << covarFile); } else { NUIS_ABORT("Covariance matrix provided is incorrect: " << covarFile); } // 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 entries = GeneralUtils::ParseToDbl(line, " "); if (entries.size() <= 1) { NUIS_ERR(WRN, "SetCovarMatrixFromText -> Covariance matrix only has <= 1 " "entries on this line: " << row); } for (std::vector::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); return; }; //******************************************************************** 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(), std::ifstream::in); this->covar = new TMatrixDSym(dim); this->fFullCovar = new TMatrixDSym(dim); if (corr.is_open()) { NUIS_LOG(SAM, "Reading and converting correlation matrix from file: " << corrFile); } else { NUIS_ABORT("Correlation matrix provided is incorrect: " << corrFile); } 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 std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { double val = (*iter) * this->fDataHist->GetBinError(row + 1) * 1E38 * this->fDataHist->GetBinError(column + 1) * 1E38; if (val == 0) { NUIS_ABORT("Found a zero value in the covariance matrix, assuming " "this is an error!"); } (*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(), ""); 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, bool FullUnits) { //******************************************************************** NUIS_LOG(SAM, "Getting covariance from " << covarFile << "->" << covName); 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); // std::string line; // std::ifstream mask(maskFile.c_str(), std::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 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; // continue; // } // // 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; // } // //******************************************************************** // void Measurement1D::GetBinContents(std::vector& cont, // std::vector& 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; // }; /* XSec Functions */ // //******************************************************************** // 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; // 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); // Double_t* yVal = f.GetY(); // 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 (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); // // Get integral over custom range // double integral = fFluxHist->Integral(minBin, maxBin + 1, intOpt.c_str()); // return integral; // }; diff --git a/src/FitBase/Measurement1D.h b/src/FitBase/Measurement1D.h index db4b55a..ef53680 100644 --- a/src/FitBase/Measurement1D.h +++ b/src/FitBase/Measurement1D.h @@ -1,659 +1,659 @@ -// Copyright 2016 L. Pickering, P towell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 L. Pickering, P towell, 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 . *******************************************************************************/ #ifndef MEASUREMENT_1D_H_SEEN #define MEASUREMENT_1D_H_SEEN /*! * \addtogroup FitBase * @{ */ #include #include #include #include #include #include #include #include // ROOT includes #include #include #include #include #include #include #include #include #include #include #include #include // External data fit includes #include "FitEvent.h" #include "FitUtils.h" #include "MeasurementBase.h" #include "PlotUtils.h" #include "StatUtils.h" #include "SignalDef.h" #include "MeasurementVariableBox.h" #include "MeasurementVariableBox1D.h" namespace NUISANCE { namespace FitBase { } } //******************************************************************** /// 1D Measurement base class. Histogram handling is done in this base layer. class Measurement1D : public MeasurementBase { //******************************************************************** public: /* Constructor/Deconstuctor */ Measurement1D(void); virtual ~Measurement1D(void); /* Setup Functions */ /// \brief Setup all configs once initialised /// /// Should be called after all configs have been setup inside fSettings container. /// Handles the processing of inputs and setting up of types. /// Replaces the old 'SetupMeasurement' function. void FinaliseSampleSettings(); /// \brief Creates the 1D data distribution given the binning provided. virtual void CreateDataHistogram(int dimx, double* binx); /// \brief Read 1D data inputs from a text file. /// /// Inputfile should have the format: \n /// low_binedge_1 bin_content_1 bin_error_1 \n /// low_binedge_2 bin_content_2 bin_error_2 \n /// .... .... .... \n /// high_bin_edge_N 0.0 0.0 virtual void SetDataFromTextFile(std::string datafile); /// \brief Read 1D data inputs from a root file. /// /// inhistfile specifies the path to the root file /// histname specifies the name of the histogram. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ';' so that: \n /// 'myhistfile.root;myhistname' \n /// will also work. virtual void SetDataFromRootFile(std::string inhistfile, std::string histname = ""); /// \brief Setup a default empty data histogram /// /// Only used for flattree creators. virtual void SetEmptyData(); /// \brief Set data bin errors to sqrt(entries) /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Sets the data errors as the sqrt of the bin contents /// Should be use for counting experiments virtual void SetPoissonErrors(); /// \brief Make diagonal covariance from data /// /// \warning If no histogram passed, data must be setup first! /// Setup the covariance inputs by taking the data histogram /// errors and setting up a diagonal covariance matrix. /// /// If no data is supplied, fDataHist is used if already set. virtual void SetCovarFromDiagonal(TH1D* data = NULL); /// \brief Read the data covariance from a text file. /// /// Inputfile should have the format: \n /// covariance_11 covariance_12 covariance_13 ... \n /// covariance_21 covariance_22 covariance_23 ... \n /// ... ... ... ... \n /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCovarFromTextFile(std::string covfile, int dim = -1); virtual void SetCovarFromMultipleTextFiles(std::string covfiles, int dim = -1); /// \brief Read the data covariance from a ROOT file. /// /// - covfile specifies the full path to the file /// - histname specifies the name of the covariance object. Both TMatrixDSym and TH2D are supported. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCovarFromRootFile(std::string covfile, std::string histname=""); /// \brief Read the inverted data covariance from a text file. /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCovarInvertFromTextFile(std::string covfile, int dim = -1); /// \brief Read the inverted data covariance from a ROOT file. /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCovarInvertFromRootFile(std::string covfile, std::string histname=""); /// \brief Read the data correlations from a text file. /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCorrelationFromTextFile(std::string covfile, int dim = -1); /// \brief Read the data correlations from multiple text files. /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of the first corrfile. virtual void SetCorrelationFromMultipleTextFiles(std::string corrfiles, int dim = -1); /// \brief Read the data correlations from a ROOT file. /// /// \warning REQUIRES DATA TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCorrelationFromRootFile(std::string covfile, std::string histname=""); /// \brief Read the cholesky decomposed covariance from a text file and turn it into a covariance /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCholDecompFromTextFile(std::string covfile, int dim = -1); /// \brief Read the cholesky decomposed covariance from a ROOT file and turn it into a covariance /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCholDecompFromRootFile(std::string covfile, std::string histname=""); /// \brief Try to extract a shape-only matrix from the existing covariance virtual void SetShapeCovar(); /// \brief Scale the data by some scale factor virtual void ScaleData(double scale); /// \brief Scale the data error bars by some scale factor virtual void ScaleDataErrors(double scale); /// \brief Scale the covariaince and its invert/decomp by some scale factor. virtual void ScaleCovar(double scale); /// \brief Setup a bin masking histogram and apply masking to data /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Reads in a list of bins in a text file to be masked. Format is: \n /// bin_index_1 1 \n /// bin_index_2 1 \n /// bin_index_3 1 \n /// /// If 0 is given then a bin entry will NOT be masked. So for example: \n\n /// 1 1 \n /// 2 1 \n /// 3 0 \n /// 4 1 \n\n /// Will mask only the 1st, 2nd, and 4th bins. /// /// Masking can be turned on by specifiying the MASK option when creating a sample. /// When this is passed NUISANCE will look in the following locations for the mask file: /// - FitPar::Config().GetParS(fName + ".mask") /// - "data/masks/" + fName + ".mask"; virtual void SetBinMask(std::string maskfile); /// \brief Set the current fit options from a string. /// /// This is called twice for each sample, once to set the default /// and once to set the current setting (if anything other than default given) /// /// For this to work properly it requires the default and allowed types to be /// set correctly. These should be specified as a string listing options. /// /// To split up options so that NUISANCE can automatically detect ones that /// are conflicting. Any options separated with the '/' symbol are non conflicting /// and can be given together, whereas any separated with the ',' symbol cannot /// be specified by the end user at the same time. /// /// Default Type Examples: /// - DIAG/FIX = Default option will be a diagonal covariance, with FIXED norm. /// - MASK/SHAPE = Default option will be a masked hist, with SHAPE always on. /// /// Allowed Type examples: /// - 'FULL/DIAG/NORM/MASK' = Any of these options can be specified. /// - 'FULL,FREE,SHAPE/MASK/NORM' = User can give either FULL, FREE, or SHAPE as on option. /// MASK and NORM can also be included as options. virtual void SetFitOptions(std::string opt); /// \brief Final constructor setup /// \warning Should be called right at the end of the constructor. /// /// Contains a series of checks to ensure the data and inputs have been setup. /// Also creates the MC histograms needed for fitting. void FinaliseMeasurement(); /* Smearing */ /// \brief Read in smearing matrix from file /// /// Set the smearing matrix from a text file given the size of the matrix virtual void SetSmearingMatrix(std::string smearfile, int truedim, int recodim); /// \brief Apply smearing to MC true to get MC reco /// /// Apply smearing matrix to fMCHist using fSmearingMatrix virtual void ApplySmearingMatrix(void); /* Reconfigure Functions */ /// \brief Create a Measurement1D box /// /// Creates a new 1D variable box containing just fXVar. /// /// This box is the bare minimum required by the JointFCN when /// running fast reconfigures during a routine. /// If for some reason a sample needs extra variables to be saved then /// it should override this function creating its own MeasurementVariableBox /// that contains the extra variables. virtual MeasurementVariableBox* CreateBox() {return new MeasurementVariableBox1D();}; /// \brief Reset all MC histograms /// /// Resets all standard histograms and those registered to auto /// process to zero. /// /// If extra histograms are not included in auto processing, then they must be reset /// by overriding this function and doing it manually if required. virtual void ResetAll(void); /// \brief Fill MC Histograms from XVar /// /// Fill standard histograms using fXVar, Weight read from the variable box. /// /// WARNING : Any extra MC histograms need to be filled by overriding this function, /// even if they have been set to auto process. virtual void FillHistograms(void); // \brief Convert event rates to final histogram /// /// Apply standard scaling procedure to standard mc histograms to convert from /// raw events to xsec prediction. /// /// If any distributions have been set to auto process /// that is done during this function call, and a differential xsec is assumed. /// If that is not the case this function must be overriden. virtual void ScaleEvents(void); /// \brief Scale MC by a factor=1/norm /// /// Apply a simple normalisation scaling if the option FREE or a norm_parameter /// has been specified in the NUISANCE routine. virtual void ApplyNormScale(double norm); /* Statistical Functions */ /// \brief Get Number of degrees of freedom /// /// Returns the number bins inside the data histogram accounting for /// any bin masking applied. virtual int GetNDOF(void); /// \brief Return Data/MC Likelihood at current state /// /// Returns the likelihood of the data given the current MC prediction. /// Diferent likelihoods definitions are used depending on the FitOptions. virtual double GetLikelihood(void); /* Fake Data */ /// \brief Set the fake data values from either a file, or MC /// /// - Setting from a file "path": \n /// When reading from a file the full path must be given to a standard /// nuisance output. The standard MC histogram should have a name that matches /// this sample for it to be read in. /// \n\n /// - Setting from "MC": \n /// If the MC option is given the current MC prediction is used as fake data. virtual void SetFakeDataValues(std::string fakeOption); /// \brief Reset fake data back to starting fake data /// /// Reset the fake data back to original fake data (Reset back to before /// ThrowCovariance was first called) virtual void ResetFakeData(void); /// \brief Reset fake data back to original data /// /// Reset the data histogram back to the true original dataset for this sample /// before any fake data was defined. virtual void ResetData(void); /// \brief Generate fake data by throwing the covariance. /// /// Can be used on fake MC data or just the original dataset. /// Call ResetFakeData or ResetData to return to values before the throw. virtual void ThrowCovariance(void); /// \brief Throw the data by its assigned errors and assign this to MC /// /// Used when creating data toys by assign the MC to this thrown data /// so that the likelihood is calculated between data and thrown data virtual void ThrowDataToy(void); /* Access Functions */ /// \brief Returns nicely formatted MC Histogram /// /// Format options can also be given in the samplesettings: /// - linecolor /// - linestyle /// - linewidth /// - fillcolor /// - fillstyle /// /// So to have a sample line colored differently in the xml cardfile put: \n /// virtual TH1D* GetMCHistogram(void); /// \brief Returns nicely formatted data Histogram /// /// Format options can also be given in the samplesettings: /// - datacolor /// - datastyle /// - datawidth /// /// So to have a sample data colored differently in the xml cardfile put: \n /// virtual TH1D* GetDataHistogram(void); /// \brief Returns a list of all MC histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetMCList(void) { return std::vector(1, GetMCHistogram()); } /// \brief Returns a list of all Data histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetDataList(void) { return std::vector(1, GetDataHistogram()); } /// \brief Returns a list of all Mask histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetMaskList(void) { return std::vector(1, fMaskHist); }; /// \brief Returns a list of all Fine histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetFineList(void) { return std::vector(1, fMCFine); }; /* Write Functions */ /// \brief Save the current state to the current TFile directory \n /// /// Data/MC are both saved by default. /// A range of other histograms can be saved by setting the /// config option 'drawopts'. /// /// Possible options: \n /// - FINE = Write Fine Histogram \n /// - WEIGHTS = Write Weighted MC Histogram (before scaling) \n /// - FLUX = Write Flux Histogram from MC Input \n /// - EVT = Write Event Histogram from MC Input \n /// - XSEC = Write XSec Histogram from MC Input \n /// - MASK = Write Mask Histogram \n /// - COV = Write Covariance Histogram \n /// - INVCOV = Write Inverted Covariance Histogram \n /// - DECMOP = Write Decomp. Covariance Histogram \n /// - RESIDUAL= Write Resudial Histograms \n /// - RATIO = Write Data/MC Ratio Histograms \n /// - SHAPE = Write MC Shape Histograms norm. to Data \n /// - CANVMC = Build MC Canvas Showing Data, MC, Shape \n /// - MODES = Write PDG Stack \n /// - CANVPDG = Build MC Canvas Showing Data, PDGStack \n /// /// So to save a range of these in parameters/config.xml set: \n /// virtual void Write(std::string drawOpt); virtual void WriteRatioPlot(); virtual void WriteShapePlot(); virtual void WriteShapeRatioPlot(); //* // OLD DEFUNCTIONS // /// OLD FUNCTION virtual void SetupMeasurement(std::string input, std::string type, FitWeight* rw, std::string fkdt); /// OLD FUNCTION virtual void SetupDefaultHist(void); /// OLD FUNCTION virtual void SetDataValues(std::string dataFile); /// OLD FUNCTION virtual void SetDataFromFile(std::string inhistfile, std::string histname); /// OLD FUNCTION virtual void SetDataFromDatabase(std::string inhistfile, std::string histname); /// OLD FUNCTION virtual void SetCovarMatrix(std::string covarFile); /// OLD FUNCTION virtual void SetCovarMatrixFromText(std::string covarFile, int dim, double scale = 1.0); /// OLD FUNCTION virtual void SetCovarMatrixFromCorrText(std::string covarFile, int dim); /// OLD FUNCTION virtual void SetCovarFromDataFile(std::string covarFile, std::string covName, bool FullUnits = false); /// OLD FUNCTION // virtual THStack GetModeStack(void); protected: // Data TH1D* fDataHist; ///< default data histogram TH1D* fDataOrig; ///< histogram to store original data before throws. TH1D* fDataTrue; ///< histogram to store true dataset std::string fPlotTitles; ///< Plot title x and y for the histograms // MC 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 TH1D* fMCWeighted; ///< Weighted histogram before xsec scaling TH1I* fMaskHist; ///< Mask histogram for neglecting specific bins TMatrixD* fSmearMatrix; ///< Smearing matrix (note, this is not symmetric) TH1D *fResidualHist; TH1D *fChi2LessBinHist; TrueModeStack* fMCHist_Modes; ///< Optional True Mode Stack // Statistical TMatrixDSym* covar; ///< Inverted Covariance TMatrixDSym* fFullCovar; ///< Full Covariance TMatrixDSym* fDecomp; ///< Decomposed Covariance TMatrixDSym* fCorrel; ///< Correlation Matrix TMatrixDSym* fShapeCovar; ///< Shape-only covariance TMatrixDSym* fShapeDecomp; ///< Decomposed shape-only covariance TMatrixDSym* fShapeInvert; ///< Inverted shape-only covariance TMatrixDSym* fCovar; ///< New FullCovar TMatrixDSym* fInvert; ///< New covar double fNormError; ///< Sample norm error double fLikelihood; ///< Likelihood value // Fake Data bool fIsFakeData; ///< Flag: is the current data fake from MC std::string fFakeDataInput; ///< Input fake data file path TFile* fFakeDataFile; ///< Input fake data file // Fit specific flags std::string fFitType; ///< Current fit type std::string fAllowedTypes; ///< Fit Types Possible std::string fDefaultTypes; ///< Starting Default Fit Types bool fIsShape; ///< Flag : Perform Shape-only fit bool fUseShapeNormDecomp; 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 : keeping norm fixed bool fIsFull; ///< Flag : using full covariaince bool fIsDifXSec; ///< Flag : creating a dif xsec bool fIsChi2; ///< Flag : using Chi2 over LL methods bool fIsSmeared; ///< Flag : Apply smearing? bool fIsWriting; - + bool fSaveFine; /// OLD STUFF TO REMOVE TH1D* fMCHist_PDG[61]; ///< REMOVE OLD MC PDG Plot // Arrays for data entries Double_t* fXBins; ///< REMOVE xBin edges Double_t* fDataValues; ///< REMOVE data bin contents Double_t* fDataErrors; ///< REMOVE data bin errors Int_t fNDataPointsX; ///< REMOVE number of data points }; /*! @} */ #endif diff --git a/src/FitBase/Measurement2D.cxx b/src/FitBase/Measurement2D.cxx index 75ffeef..2336a27 100644 --- a/src/FitBase/Measurement2D.cxx +++ b/src/FitBase/Measurement2D.cxx @@ -1,2143 +1,2088 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "Measurement2D.h" #include "TDecompChol.h" //******************************************************************** Measurement2D::Measurement2D(void) { //******************************************************************** covar = NULL; + fInvert = 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; fResidualHist = NULL; fChi2LessBinHist = NULL; fDefaultTypes = "FIX/FULL/CHI2"; fAllowedTypes = "FIX,FREE,SHAPE/FULL,DIAG/CHI2/NORM/ENUCORR/Q2CORR/ENU1D/FITPROJX/" "FITPROJY"; - fIsFix = false; - fIsShape = false; - fIsFree = false; - - fIsDiag = false; - fIsFull = false; - - fAddNormPen = false; - fIsMask = false; - fIsChi2SVD = false; - - fIsRawEvents = false; - fIsDifXSec = false; - fIsEnu = false; - // XSec Scalings fScaleFactor = -1.0; fCurrentNorm = 1.0; - // Histograms - fDataHist = NULL; - fDataTrue = NULL; - - fMCHist = NULL; - fMCFine = NULL; - fMCWeighted = NULL; - - fMaskHist = NULL; - - // Covar - covar = NULL; - fFullCovar = NULL; - - fCovar = NULL; - fInvert = NULL; - fDecomp = NULL; - // Fake Data fFakeDataInput = ""; fFakeDataFile = NULL; // Options 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; fIsWriting = false; // Inputs fInput = NULL; fRW = NULL; // Extra Histograms fMCHist_Modes = NULL; } //******************************************************************** Measurement2D::~Measurement2D(void) { //******************************************************************** if (fDataHist) delete fDataHist; if (fDataTrue) delete fDataTrue; if (fMCHist) delete fMCHist; if (fMCFine) delete fMCFine; if (fMCWeighted) delete fMCWeighted; if (fMaskHist) delete fMaskHist; if (covar) delete covar; if (fFullCovar) delete fFullCovar; if (fCovar) delete fCovar; if (fInvert) delete fInvert; if (fDecomp) delete fDecomp; delete fResidualHist; delete fChi2LessBinHist; } //******************************************************************** void Measurement2D::FinaliseSampleSettings() { //******************************************************************** MeasurementBase::FinaliseSampleSettings(); // Setup naming + renaming fName = fSettings.GetName(); fSettings.SetS("originalname", fName); if (fSettings.Has("rename")) { fName = fSettings.GetS("rename"); fSettings.SetS("name", fName); } // Setup all other options NUIS_LOG(SAM, "Finalising Sample Settings: " << fName); if ((fSettings.GetS("originalname").find("Evt") != std::string::npos)) { fIsRawEvents = true; NUIS_LOG(SAM, "Found event rate measurement but using poisson likelihoods."); } if (fSettings.GetS("originalname").find("Enu") != std::string::npos) { fIsEnu1D = true; - NUIS_LOG(SAM, "::" << fName << "::"); NUIS_LOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, " << "not flux averaged!"); } if (fIsEnu1D && fIsRawEvents) { NUIS_ERR(FTL, "Found 2D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!"); NUIS_ERR(FTL, "Check experiment constructor for " << fName << " and correct this!"); NUIS_ABORT("I live in " << __FILE__ << ":" << __LINE__); } if (!fRW) fRW = FitBase::GetRW(); if (!fInput) SetupInputs(fSettings.GetS("input")); // Setup options SetFitOptions(fDefaultTypes); // defaults SetFitOptions(fSettings.GetS("type")); // user specified EnuMin = GeneralUtils::StrToDbl(fSettings.GetS("enu_min")); EnuMax = GeneralUtils::StrToDbl(fSettings.GetS("enu_max")); } void Measurement2D::CreateDataHistogram(int dimx, double *binx, int dimy, double *biny) { if (fDataHist) delete fDataHist; NUIS_LOG(SAM, "Creating Data Histogram dim : " << dimx << " " << dimy); fDataHist = new TH2D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), dimx - 1, binx, dimy - 1, biny); } void Measurement2D::SetDataFromTextFile(std::string data, std::string binx, std::string biny) { // Get the data hist fDataHist = PlotUtils::GetTH2DFromTextFile(data, binx, biny); // Set the name properly fDataHist->SetName((fSettings.GetName() + "_data").c_str()); fDataHist->SetTitle(fSettings.GetFullTitles().c_str()); } void Measurement2D::SetDataFromRootFile(std::string datfile, std::string histname) { NUIS_LOG(SAM, "Reading data from root file: " << datfile << ";" << histname); fDataHist = PlotUtils::GetTH2DFromRootFile(datfile, histname); fDataHist->SetNameTitle((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str()); } void Measurement2D::SetDataValuesFromTextFile(std::string datfile, TH2D *hist) { NUIS_LOG(SAM, "Setting data values from text file"); if (!hist) hist = fDataHist; // Read TH2D From textfile TH2D *valhist = (TH2D *)hist->Clone(); valhist->Reset(); PlotUtils::Set2DHistFromText(datfile, valhist, 1.0, true); - NUIS_LOG(SAM, " -> Filling values from read hist."); + NUIS_LOG(DEB, " -> Filling values from read hist."); for (int i = 0; i < valhist->GetNbinsX(); i++) { for (int j = 0; j < valhist->GetNbinsY(); j++) { hist->SetBinContent(i + 1, j + 1, valhist->GetBinContent(i + 1, j + 1)); } } - NUIS_LOG(SAM, " --> Done"); + NUIS_LOG(DEB, " --> Done"); } void Measurement2D::SetDataErrorsFromTextFile(std::string datfile, TH2D *hist) { NUIS_LOG(SAM, "Setting data errors from text file"); if (!hist) hist = fDataHist; // Read TH2D From textfile TH2D *valhist = (TH2D *)hist->Clone(); valhist->Reset(); PlotUtils::Set2DHistFromText(datfile, valhist, 1.0); // Fill Errors - NUIS_LOG(SAM, " -> Filling errors from read hist."); + NUIS_LOG(DEB, " -> Filling errors from read hist."); for (int i = 0; i < valhist->GetNbinsX(); i++) { for (int j = 0; j < valhist->GetNbinsY(); j++) { hist->SetBinError(i + 1, j + 1, valhist->GetBinContent(i + 1, j + 1)); } } - NUIS_LOG(SAM, " --> Done"); + NUIS_LOG(DEB, " --> Done"); } void Measurement2D::SetMapValuesFromText(std::string dataFile) { TH2D *hist = fDataHist; std::vector edgex; std::vector edgey; for (int i = 0; i <= hist->GetNbinsX(); i++) edgex.push_back(hist->GetXaxis()->GetBinLowEdge(i + 1)); for (int i = 0; i <= hist->GetNbinsY(); i++) edgey.push_back(hist->GetYaxis()->GetBinLowEdge(i + 1)); fMapHist = new TH2I((fName + "_map").c_str(), (fName + fPlotTitles).c_str(), edgex.size() - 1, &edgex[0], edgey.size() - 1, &edgey[0]); NUIS_LOG(SAM, "Reading map from: " << dataFile); PlotUtils::Set2DHistFromText(dataFile, fMapHist, 1.0); } //******************************************************************** void Measurement2D::SetPoissonErrors() { //******************************************************************** if (!fDataHist) { NUIS_ERR(FTL, "Need a data hist to setup possion errors! "); NUIS_ABORT("Setup Data First!"); } for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i + 1, sqrt(fDataHist->GetBinContent(i + 1))); } } //******************************************************************** void Measurement2D::SetCovarFromDiagonal(TH2D *data) { //******************************************************************** if (!data and fDataHist) { data = fDataHist; } if (data) { NUIS_LOG(SAM, "Setting diagonal covariance for: " << data->GetName()); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(data); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } else { NUIS_ABORT("No data input provided to set diagonal covar from!"); } // if (!fIsDiag) { // ERR(FTL) << "SetCovarMatrixFromDiag called for measurement " // << "that is not set as diagonal." << std::endl; // throw; // } } //******************************************************************** void Measurement2D::SetCovarFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) { dim = this->GetNDOF(); } NUIS_LOG(SAM, "Reading covariance from text file: " << covfile << " " << dim); fFullCovar = StatUtils::GetCovarFromTextFile(covfile, dim); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement2D::SetCovarFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading covariance from text file: " << covfile << ";" << histname); fFullCovar = StatUtils::GetCovarFromRootFile(covfile, histname); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement2D::SetCovarInvertFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) { dim = this->GetNDOF(); } NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile); covar = StatUtils::GetCovarFromTextFile(covfile, dim); fFullCovar = StatUtils::GetInvert(covar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement2D::SetCovarInvertFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading inverted covariance from text file: " << covfile << ";" << histname); covar = StatUtils::GetCovarFromRootFile(covfile, histname); fFullCovar = StatUtils::GetInvert(covar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void Measurement2D::SetCorrelationFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) dim = this->GetNDOF(); NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";" << dim); TMatrixDSym *correlation = StatUtils::GetCovarFromTextFile(covfile, dim); if (!fDataHist) { NUIS_ABORT("Trying to set correlations from text file but there is no " "data to build it from. \n" << "In constructor make sure data is set before " "SetCorrelationFromTextFile is called. \n"); } // Fill covar from data errors and correlations fFullCovar = new TMatrixDSym(dim); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = (*correlation)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } // Fill other covars. covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete correlation; } //******************************************************************** void Measurement2D::SetCorrelationFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading data correlations from text file: " << covfile << ";" << histname); TMatrixDSym *correlation = StatUtils::GetCovarFromRootFile(covfile, histname); if (!fDataHist) { NUIS_ABORT("Trying to set correlations from text file but there is no " "data to build it from. \n" << "In constructor make sure data is set before " "SetCorrelationFromTextFile is called. \n"); } // Fill covar from data errors and correlations fFullCovar = new TMatrixDSym(fDataHist->GetNbinsX()); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = (*correlation)(i, j) * fDataHist->GetBinError(i + 1) * fDataHist->GetBinError(j + 1) * 1.E76; } } // Fill other covars. covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete correlation; } //******************************************************************** void Measurement2D::SetCholDecompFromTextFile(std::string covfile, int dim) { //******************************************************************** if (dim == -1) { dim = this->GetNDOF(); } NUIS_LOG(SAM, "Reading cholesky from text file: " << covfile << " " << dim); TMatrixD *temp = StatUtils::GetMatrixFromTextFile(covfile, dim, dim); TMatrixD *trans = (TMatrixD *)temp->Clone(); trans->T(); (*trans) *= (*temp); fFullCovar = new TMatrixDSym(dim, trans->GetMatrixArray(), ""); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete temp; delete trans; } //******************************************************************** void Measurement2D::SetCholDecompFromRootFile(std::string covfile, std::string histname) { //******************************************************************** NUIS_LOG(SAM, "Reading cholesky decomp from root file: " << covfile << ";" << histname); TMatrixD *temp = StatUtils::GetMatrixFromRootFile(covfile, histname); TMatrixD *trans = (TMatrixD *)temp->Clone(); trans->T(); (*trans) *= (*temp); fFullCovar = new TMatrixDSym(temp->GetNrows(), trans->GetMatrixArray(), ""); covar = StatUtils::GetInvert(fFullCovar,true); fDecomp = StatUtils::GetDecomp(fFullCovar); delete temp; delete trans; } void Measurement2D::SetShapeCovar() { // Return if this is missing any pre-requisites if (!fFullCovar) return; if (!fDataHist) return; // Also return if it's bloody stupid under the circumstances if (fIsDiag) return; fShapeCovar = StatUtils::ExtractShapeOnlyCovar(fFullCovar, fDataHist, fMapHist); return; } //******************************************************************** void Measurement2D::ScaleData(double scale) { //******************************************************************** fDataHist->Scale(scale); } //******************************************************************** void Measurement2D::ScaleDataErrors(double scale) { //******************************************************************** for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsY(); j++) { fDataHist->SetBinError(i + 1, j + 1, fDataHist->GetBinError(i + 1, j + 1) * scale); } } } //******************************************************************** void Measurement2D::ScaleCovar(double scale) { //******************************************************************** (*fFullCovar) *= scale; (*covar) *= 1.0 / scale; (*fDecomp) *= sqrt(scale); } //******************************************************************** void Measurement2D::SetBinMask(std::string maskfile) { //******************************************************************** if (!fIsMask) return; NUIS_LOG(SAM, "Reading bin mask from file: " << maskfile); // Create a mask histogram with dim of data int nbinsx = fDataHist->GetNbinsX(); int nbinxy = fDataHist->GetNbinsY(); fMaskHist = new TH2I((fSettings.GetName() + "_BINMASK").c_str(), (fSettings.GetName() + "_BINMASK; Bin; Mask?").c_str(), nbinsx, 0, nbinsx, nbinxy, 0, nbinxy); std::string line; std::ifstream mask(maskfile.c_str(), std::ifstream::in); if (!mask.is_open()) { NUIS_LOG(FTL, " Cannot find mask file."); throw; } while (std::getline(mask >> std::ws, line, '\n')) { std::vector entries = GeneralUtils::ParseToInt(line, " "); // Skip lines with poorly formatted lines if (entries.size() < 2) { NUIS_LOG(WRN, "Measurement2D::SetBinMask(), couldn't parse line: " << line); continue; } // The first index should be the bin number, the second should be the mask // value. int val = 0; if (entries[2] > 0) val = 1; fMaskHist->SetBinContent(entries[0], entries[1], val); } // Apply masking by setting masked data bins to zero PlotUtils::MaskBins(fDataHist, fMaskHist); return; } //******************************************************************** void Measurement2D::FinaliseMeasurement() { //******************************************************************** NUIS_LOG(SAM, "Finalising Measurement: " << fName); if (fSettings.GetB("onlymc")) { if (fDataHist) delete fDataHist; fDataHist = new TH2D("empty_data", "empty_data", 1, 0.0, 1.0, 1, 0.0, 1.0); } // Make sure data is setup if (!fDataHist) { NUIS_ABORT("No data has been setup inside " << fName << " constructor!"); } // Make sure covariances are setup if (!fFullCovar) { fIsDiag = true; SetCovarFromDiagonal(fDataHist); } else if (fIsDiag) { // Have covariance but also set Diag NUIS_LOG(SAM, "Have full covariance for sample " << GetName() << " but only using diagonal elements for likelihood"); size_t nbins = fFullCovar->GetNcols(); for (size_t i = 0; i < nbins; ++i) { for (size_t j = 0; j < nbins; ++j) { if (i != j) { (*fFullCovar)[i][j] = 0; } } } delete covar; covar = NULL; delete fDecomp; fDecomp = NULL; } if (!covar) { covar = StatUtils::GetInvert(fFullCovar,true); } if (!fDecomp) { fDecomp = StatUtils::GetDecomp(fFullCovar); } // If shape only, set covar and fDecomp using the shape-only matrix (if set) if (fIsShape && fShapeCovar && FitPar::Config().GetParB("UseShapeCovar")) { if (covar) delete covar; covar = StatUtils::GetInvert(fShapeCovar,true); if (fDecomp) delete fDecomp; fDecomp = StatUtils::GetDecomp(fFullCovar); fUseShapeNormDecomp = FitPar::Config().GetParB("UseShapeNormDecomp"); if (fUseShapeNormDecomp) { fNormError = 0; // From https://arxiv.org/pdf/2003.00088.pdf for (int i = 0; i < fFullCovar->GetNcols(); ++i) { for (int j = 0; j < fFullCovar->GetNcols(); ++j) { fNormError += (*fFullCovar)[i][j]; } } NUIS_LOG(SAM, "Sample: " << fName << ", using shape/norm decomp with norm error: " << fNormError); } } // Setup fMCHist from data fMCHist = (TH2D *)fDataHist->Clone(); fMCHist->SetNameTitle((fSettings.GetName() + "_MC").c_str(), (fSettings.GetFullTitles()).c_str()); fMCHist->Reset(); // Setup fMCFine fMCFine = new TH2D( "mcfine", "mcfine", fDataHist->GetNbinsX() * 6, fMCHist->GetXaxis()->GetBinLowEdge(1), fMCHist->GetXaxis()->GetBinLowEdge(fDataHist->GetNbinsX() + 1), fDataHist->GetNbinsY() * 6, fMCHist->GetYaxis()->GetBinLowEdge(1), fMCHist->GetYaxis()->GetBinLowEdge(fDataHist->GetNbinsY() + 1)); fMCFine->SetNameTitle((fSettings.GetName() + "_MC_FINE").c_str(), (fSettings.GetFullTitles()).c_str()); fMCFine->Reset(); // Setup MC Stat fMCStat = (TH2D *)fMCHist->Clone(); fMCStat->Reset(); // Search drawopts for possible types to include by default std::string drawopts = FitPar::Config().GetParS("drawopts"); if (drawopts.find("MODES") != std::string::npos) { fMCHist_Modes = new TrueModeStack((fSettings.GetName() + "_MODES").c_str(), ("True Channels"), fMCHist); fMCHist_Modes ->SetTitleX(fDataHist->GetXaxis()->GetTitle()); fMCHist_Modes ->SetTitleY(fDataHist->GetYaxis()->GetTitle()); fMCHist_Modes ->SetTitleZ(fDataHist->GetZaxis()->GetTitle()); SetAutoProcessTH1(fMCHist_Modes); } if (fSettings.Has("maskfile") && fSettings.Has("maskhist")) { fMaskHist = PlotUtils::GetTH2FromRootFile(fSettings.GetS("maskfile"), fSettings.GetS("maskhist")); fIsMask = bool(fMaskHist); NUIS_LOG(SAM, "Loaded mask histogram: " << fSettings.GetS("maskhist") << " from " << fSettings.GetS("maskfile")); } else if (fIsMask) { // Setup bin masks using sample name std::string curname = fName; std::string origname = fSettings.GetS("originalname"); // Check rename.mask std::string maskloc = FitPar::Config().GetParDIR(curname + ".mask"); // Check origname.mask if (maskloc.empty()) maskloc = FitPar::Config().GetParDIR(origname + ".mask"); // Check database if (maskloc.empty()) { maskloc = FitPar::GetDataBase() + "/masks/" + origname + ".mask"; } // Setup Bin Mask SetBinMask(maskloc); } if (fScaleFactor < 0) { NUIS_ERR(FTL, "I found a negative fScaleFactor in " << __FILE__ << ":" << __LINE__); NUIS_ERR(FTL, "fScaleFactor = " << fScaleFactor); NUIS_ABORT("EXITING"); } if (fAddNormPen) { if (!fUseShapeNormDecomp) { fNormError = fSettings.GetNormError(); } if (fNormError <= 0.0) { NUIS_ERR(FTL, "Norm error for class " << fName << " is 0.0!"); NUIS_ABORT("If you want to use it please add fNormError=VAL"); } } // Create and fill Weighted Histogram if (!fMCWeighted) { fMCWeighted = (TH2D *)fMCHist->Clone(); fMCWeighted->SetNameTitle((fName + "_MCWGHTS").c_str(), (fName + "_MCWGHTS" + fPlotTitles).c_str()); fMCWeighted->GetYaxis()->SetTitle("Weighted Events"); } if (!fMapHist) fMapHist = StatUtils::GenerateMap(fDataHist); } //******************************************************************** void Measurement2D::SetFitOptions(std::string opt) { //******************************************************************** // Do nothing if default given if (opt == "DEFAULT") return; // CHECK Conflicting Fit Options std::vector fit_option_allow = GeneralUtils::ParseToStr(fAllowedTypes, "/"); for (UInt_t i = 0; i < fit_option_allow.size(); i++) { std::vector 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) { NUIS_ABORT( "ERROR: Conflicting fit options provided: " << opt << std::endl << "Conflicting group = " << fit_option_section.at(i) << std::endl << "You should only supply one of these options in card file."); } } } // Check all options are allowed std::vector 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) { NUIS_ERR(FTL, "ERROR: Fit Option '" << fit_options_input.at(i) << "' Provided is not allowed for this measurement."); NUIS_ERR(FTL, "Fit Options should be provided as a '/' separated list " "(e.g. FREE/DIAG/NORM)"); NUIS_ABORT("Available options for " << fName << " are '" << fAllowedTypes << "'"); } } // 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; NUIS_ERR(FTL, "No other LIKELIHOODS properly supported!"); NUIS_ABORT("Try to use a chi2!"); } 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; // 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) 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); return; }; /* Reconfigure LOOP */ //******************************************************************** void Measurement2D::ResetAll() { //******************************************************************** fMCHist->Reset(); fMCFine->Reset(); fMCStat->Reset(); return; }; //******************************************************************** void Measurement2D::FillHistograms() { //******************************************************************** if (Signal) { fMCHist->Fill(fXVar, fYVar, Weight); fMCFine->Fill(fXVar, fYVar, Weight); fMCStat->Fill(fXVar, fYVar, 1.0); if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, fXVar, fYVar, Weight); } return; }; //******************************************************************** void Measurement2D::ScaleEvents() { //******************************************************************** // Fill MCWeighted; // for (int i = 0; i < fMCHist->GetNbinsX(); i++) { // fMCWeighted->SetBinContent(i + 1, fMCHist->GetBinContent(i + 1)); // fMCWeighted->SetBinError(i + 1, fMCHist->GetBinError(i + 1)); // } // Setup Stat ratios for MC and MC Fine double *statratio = new double[fMCHist->GetNbinsX()]; for (int i = 0; i < fMCHist->GetNbinsX(); i++) { if (fMCHist->GetBinContent(i + 1) != 0) { statratio[i] = fMCHist->GetBinError(i + 1) / fMCHist->GetBinContent(i + 1); } else { statratio[i] = 0.0; } } double *statratiofine = new double[fMCFine->GetNbinsX()]; for (int i = 0; i < fMCFine->GetNbinsX(); i++) { if (fMCFine->GetBinContent(i + 1) != 0) { statratiofine[i] = fMCFine->GetBinError(i + 1) / fMCFine->GetBinContent(i + 1); } else { statratiofine[i] = 0.0; } } // Scaling for raw event rates if (fIsRawEvents) { double datamcratio = fDataHist->Integral() / fMCHist->Integral(); fMCHist->Scale(datamcratio); fMCFine->Scale(datamcratio); if (fMCHist_Modes) fMCHist_Modes->Scale(datamcratio); // Scaling for XSec as function of Enu } else if (fIsEnu1D) { PlotUtils::FluxUnfoldedScaling(fMCHist, GetFluxHistogram(), GetEventHistogram(), fScaleFactor); PlotUtils::FluxUnfoldedScaling(fMCFine, GetFluxHistogram(), GetEventHistogram(), fScaleFactor); // if (fMCHist_Modes) { // PlotUtils::FluxUnfoldedScaling(fMCHist_Modes, GetFluxHistogram(), // GetEventHistogram(), fScaleFactor, // fNEvents); // } // Any other differential scaling } else { fMCHist->Scale(fScaleFactor, "width"); fMCFine->Scale(fScaleFactor, "width"); // if (fMCHist_Modes) fMCHist_Modes->Scale(fScaleFactor, "width"); } // Proper error scaling - ROOT Freaks out with xsec weights sometimes for (int i = 0; i < fMCStat->GetNbinsX(); i++) { fMCHist->SetBinError(i + 1, fMCHist->GetBinContent(i + 1) * statratio[i]); } for (int i = 0; i < fMCFine->GetNbinsX(); i++) { fMCFine->SetBinError(i + 1, fMCFine->GetBinContent(i + 1) * statratiofine[i]); } // Clean up delete statratio; delete statratiofine; return; }; //******************************************************************** void Measurement2D::ApplyNormScale(double norm) { //******************************************************************** fCurrentNorm = norm; fMCHist->Scale(1.0 / norm); fMCFine->Scale(1.0 / norm); return; }; /* Statistic Functions - Outsources to StatUtils */ //******************************************************************** int Measurement2D::GetNDOF() { //******************************************************************** // Just incase it has gone... if (!fDataHist) return -1; 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(); ++xBin) { for (int yBin = 0; yBin < fDataHist->GetNbinsY(); ++yBin) { if (fDataHist->GetBinError(xBin + 1, yBin + 1) != 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; // Take away those masked DOF if (fIsMask) { nDOF -= nMasked; } return nDOF; } //******************************************************************** double Measurement2D::GetLikelihood() { //******************************************************************** // 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); } } // 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) { fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_PDG, scaleF); } if (!fMapHist) { fMapHist = StatUtils::GenerateMap(fDataHist); } // Get the chi2 from either covar or diagonals double chi2 = 0.0; if (fIsChi2) { if (fIsDiag) { chi2 = StatUtils::GetChi2FromDiag(fDataHist, fMCHist, fMapHist, fMaskHist); } else { chi2 = StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMapHist, fMaskHist, fIsWriting ? fResidualHist : NULL); if (fChi2LessBinHist && fIsWriting) { NUIS_LOG(SAM, "Building n-1 chi2 contribution plot for " << GetName()); for (int xi = 0; xi < fDataHist->GetNbinsX(); ++xi) { for (int yi = 0; yi < fDataHist->GetNbinsY(); ++yi) { TH2I *binmask = fMaskHist ? static_cast(fMaskHist->Clone("mask")) : new TH2I("mask", "", fDataHist->GetNbinsX(), 0, fDataHist->GetNbinsX(), fDataHist->GetNbinsY(), 0, fDataHist->GetNbinsY()); binmask->SetDirectory(NULL); binmask->SetBinContent(xi + 1, yi + 1, 1); fChi2LessBinHist->SetBinContent( xi + 1, yi + 1, StatUtils::GetChi2FromCov(fDataHist, fMCHist, covar, fMapHist, binmask)); delete binmask; } } } } } // Add a normal penalty term if (fAddNormPen) { if (fUseShapeNormDecomp) { // if shape norm, then add the norm penalty from // https://arxiv.org/pdf/2003.00088.pdf TH2 *masked_data = StatUtils::ApplyHistogramMasking(fDataHist, fMaskHist); TH2 *masked_mc = StatUtils::ApplyHistogramMasking(fMCHist, fMaskHist); masked_mc->Scale(scaleF); NUIS_LOG(REC, "ShapeNormDecomp: mcinteg: " << masked_mc->Integral() * 1E38 << ", datainteg: " << masked_data->Integral() * 1E38 << ", normerror: " << fNormError); double normpen = std::pow((masked_data->Integral() - masked_mc->Integral()) * 1E38, 2) / fNormError; masked_data->SetDirectory(NULL); delete masked_data; masked_mc->SetDirectory(NULL); delete masked_mc; NUIS_LOG(REC, "Using Shape/Norm decomposition: Norm penalty " << normpen << " on shape penalty of " << chi2); chi2 += normpen; } else { chi2 += (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / (fNormError * fNormError); NUIS_LOG(SAM, "Norm penalty = " << (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / (fNormError * fNormError)); } } // Adjust the shape back to where it was. if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")) { fMCHist->Scale(1. / scaleF); fMCFine->Scale(1. / scaleF); } fLikelihood = chi2; return chi2; } /* Fake Data Functions */ //******************************************************************** void Measurement2D::SetFakeDataValues(std::string fakeOption) { //******************************************************************** // Setup original/datatrue TH2D *tempdata = (TH2D *)fDataHist->Clone(); if (!fIsFakeData) { fIsFakeData = true; // Make a copy of the original data histogram. if (!fDataOrig) fDataOrig = (TH2D *)fDataHist->Clone((fName + "_data_original").c_str()); } else { ResetFakeData(); } // Setup Inputs fFakeDataInput = fakeOption; NUIS_LOG(SAM, "Setting fake data from : " << fFakeDataInput); // From MC if (fFakeDataInput.compare("MC") == 0) { fDataHist = (TH2D *)fMCHist->Clone((fName + "_MC").c_str()); // Fake File } else { if (!fFakeDataFile) fFakeDataFile = new TFile(fFakeDataInput.c_str(), "READ"); fDataHist = (TH2D *)fFakeDataFile->Get((fName + "_MC").c_str()); } // Setup Data Hist fDataHist->SetNameTitle((fName + "_FAKE").c_str(), (fName + fPlotTitles).c_str()); // Replace Data True if (fDataTrue) delete fDataTrue; fDataTrue = (TH2D *)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_FAKE_TRUE").c_str(), (fName + fPlotTitles).c_str()); // Make a new covariance for fake data hist. int nbins = fDataHist->GetNbinsX() * fDataHist->GetNbinsY(); double alpha_i = 0.0; double alpha_j = 0.0; for (int i = 0; i < nbins; i++) { for (int j = 0; j < nbins; j++) { if (tempdata->GetBinContent(i + 1) && tempdata->GetBinContent(j + 1)) { alpha_i = fDataHist->GetBinContent(i + 1) / tempdata->GetBinContent(i + 1); alpha_j = fDataHist->GetBinContent(j + 1) / tempdata->GetBinContent(j + 1); } else { alpha_i = 0.0; alpha_j = 0.0; } (*fFullCovar)(i, j) = alpha_i * alpha_j * (*fFullCovar)(i, j); } } // Setup Covariances if (covar) delete covar; covar = StatUtils::GetInvert(fFullCovar,true); if (fDecomp) delete fDecomp; fDecomp = StatUtils::GetDecomp(fFullCovar); delete tempdata; return; }; //******************************************************************** void Measurement2D::ResetFakeData() { //******************************************************************** if (fIsFakeData) { if (fDataHist) delete fDataHist; fDataHist = (TH2D *)fDataTrue->Clone((fSettings.GetName() + "_FKDAT").c_str()); } } //******************************************************************** void Measurement2D::ResetData() { //******************************************************************** if (fIsFakeData) { if (fDataHist) delete fDataHist; fDataHist = (TH2D *)fDataOrig->Clone((fSettings.GetName() + "_data").c_str()); } fIsFakeData = false; } //******************************************************************** void Measurement2D::ThrowCovariance() { //******************************************************************** // Take a fDecomposition and use it to throw the current dataset. // Requires fDataTrue also be set incase used repeatedly. if (fDataHist) delete fDataHist; fDataHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); return; }; //******************************************************************** void Measurement2D::ThrowDataToy() { //******************************************************************** if (!fDataTrue) fDataTrue = (TH2D *)fDataHist->Clone(); if (fMCHist) delete fMCHist; fMCHist = StatUtils::ThrowHistogram(fDataTrue, fFullCovar); } /* Access Functions */ //******************************************************************** TH2D *Measurement2D::GetMCHistogram() { //******************************************************************** if (!fMCHist) return fMCHist; std::ostringstream chi2; chi2 << std::setprecision(5) << this->GetLikelihood(); int linecolor = kRed; int linestyle = 1; int linewidth = 1; int fillcolor = 0; int fillstyle = 1001; if (fSettings.Has("linecolor")) linecolor = fSettings.GetI("linecolor"); if (fSettings.Has("linestyle")) linestyle = fSettings.GetI("linestyle"); if (fSettings.Has("linewidth")) linewidth = fSettings.GetI("linewidth"); if (fSettings.Has("fillcolor")) fillcolor = fSettings.GetI("fillcolor"); if (fSettings.Has("fillstyle")) fillstyle = fSettings.GetI("fillstyle"); fMCHist->SetTitle(chi2.str().c_str()); fMCHist->SetLineColor(linecolor); fMCHist->SetLineStyle(linestyle); fMCHist->SetLineWidth(linewidth); fMCHist->SetFillColor(fillcolor); fMCHist->SetFillStyle(fillstyle); return fMCHist; }; //******************************************************************** TH2D *Measurement2D::GetDataHistogram() { //******************************************************************** if (!fDataHist) return fDataHist; int datacolor = kBlack; int datastyle = 1; int datawidth = 1; if (fSettings.Has("datacolor")) datacolor = fSettings.GetI("datacolor"); if (fSettings.Has("datastyle")) datastyle = fSettings.GetI("datastyle"); if (fSettings.Has("datawidth")) datawidth = fSettings.GetI("datawidth"); fDataHist->SetLineColor(datacolor); fDataHist->SetLineWidth(datawidth); fDataHist->SetMarkerStyle(datastyle); return fDataHist; }; /* Write Functions */ // Save all the histograms at once //******************************************************************** void Measurement2D::Write(std::string drawOpt) { //******************************************************************** // Get Draw Options drawOpt = FitPar::Config().GetParS("drawopts"); // Write Settigns if (drawOpt.find("SETTINGS") != std::string::npos) { fSettings.Set("#chi^{2}", fLikelihood); fSettings.Set("NDOF", this->GetNDOF()); fSettings.Set("#chi^{2}/NDOF", fLikelihood / this->GetNDOF()); fSettings.Write(); } - // // Likelihood residual plots - // if (drawOpt.find("RESIDUAL") != std::string::npos) { - // WriteResidualPlots(); - //} - - // // RATIO - // if (drawOpt.find("CANVMC") != std::string::npos) { - // TCanvas* c1 = WriteMCCanvas(fDataHist, fMCHist); - // c1->Write(); - // delete c1; - // } - - // // PDG - // if (drawOpt.find("CANVPDG") != std::string::npos && fMCHist_Modes) { - // TCanvas* c2 = WritePDGCanvas(fDataHist, fMCHist, fMCHist_Modes); - // c2->Write(); - // delete c2; - // } - - /// 2D VERSION // If null pointer return if (!fMCHist and !fDataHist) { NUIS_LOG(SAM, fName << "Incomplete histogram set!"); return; } - // Config::Get().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 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 drawSliceMC = (drawOpt.find("CANVSLICEMC") != std::string::npos); bool drawWeighted = (drawOpt.find("WEIGHTS") != std::string::npos && fMCWeighted); if (FitPar::Config().GetParB("EventManager")) { drawFlux = false; drawEvents = false; } // Save standard plots if (drawData) { GetDataList().at(0)->Write(); // Generate a simple map if (!fMapHist) fMapHist = StatUtils::GenerateMap(fDataHist); // Convert to 1D Lists TH1D *data_1D = StatUtils::MapToTH1D(fDataHist, fMapHist); data_1D->Write(); delete data_1D; } if (drawNormal) { GetMCList().at(0)->Write(); if (!fMapHist) fMapHist = StatUtils::GenerateMap(fDataHist); TH1D *mc_1D = StatUtils::MapToTH1D(fMCHist, fMapHist); mc_1D->SetLineColor(kRed); mc_1D->Write(); delete mc_1D; } if (fIsChi2 && !fIsDiag) { fResidualHist = (TH2D *)fMCHist->Clone((fName + "_RESIDUAL").c_str()); - fResidualHist->GetYaxis()->SetTitle("#Delta#chi^{2}"); + fResidualHist->GetZaxis()->SetTitle("#Delta#chi^{2}"); fResidualHist->Reset(); fChi2LessBinHist = (TH2D *)fMCHist->Clone((fName + "_Chi2NMinusOne").c_str()); - fChi2LessBinHist->GetYaxis()->SetTitle("Total #chi^{2} without bin_{i}"); + fChi2LessBinHist->GetZaxis()->SetTitle("Total #chi^{2} without bin_{i}"); fChi2LessBinHist->Reset(); fIsWriting = true; (void)GetLikelihood(); fIsWriting = false; fResidualHist->Write((fName + "_RESIDUAL").c_str()); fChi2LessBinHist->Write((fName + "_Chi2NMinusOne").c_str()); if (fMapHist) { TH1D *ResidualHist_1D = StatUtils::MapToTH1D(fResidualHist, fMapHist); TH1D *Chi2LessBinHist_1D = StatUtils::MapToTH1D(fChi2LessBinHist, fMapHist); ResidualHist_1D->Write((fName + "_RESIDUAL_1D").c_str()); Chi2LessBinHist_1D->Write((fName + "_Chi2NMinusOne_1D").c_str()); } } // Write Weighted Histogram if (drawWeighted) fMCWeighted->Write(); if (drawCov) { TH2D(*fFullCovar).Write((fName + "_COV").c_str()); } if (drawOpt.find("INVCOV") != std::string::npos) { TH2D(*covar).Write((fName + "_INVCOV").c_str()); } // 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 and GetFluxHistogram()) { GetFluxHistogram()->Write(); } if (drawEvents and GetEventHistogram()) { GetEventHistogram()->Write(); } if (fIsMask and drawMask) { fMaskHist->Write((fName + "_MSK").c_str()); //< save mask TH1I *mask_1D = StatUtils::MapToMask(fMaskHist, fMapHist); if (mask_1D) { mask_1D->Write(); TMatrixDSym *calc_cov = StatUtils::ApplyInvertedMatrixMasking(covar, mask_1D); TH1D *data_1D = StatUtils::MapToTH1D(fDataHist, fMapHist); TH1D *mc_1D = StatUtils::MapToTH1D(fMCHist, fMapHist); TH1D *calc_data = StatUtils::ApplyHistogramMasking(data_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; } } 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); // combo_fMCHist_PDG.Write(); // } // Save Matrix plots 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.Write(); TH2D covinv = TH2D((*this->covar)); 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.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 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)); } 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 TH2D *mcShape = (TH2D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); + TH1D *mcShape_1D = StatUtils::MapToTH1D(mcShape, fMapHist); + mcShape_1D ->SetName((fName + "_MC_SHAPE_1D").c_str()); double shapeScale = 1.0; if (fIsRawEvents) { shapeScale = fDataHist->Integral() / fMCHist->Integral(); } else { shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); } - mcShape->Scale(shapeScale); + mcShape->SetTitle(Form("%f", shapeScale)); + mcShape_1D->SetTitle(Form("%f", shapeScale)); - mcShape->SetLineWidth(3); - mcShape->SetLineStyle(7); // dashes + mcShape->Scale(shapeScale); + mcShape_1D->Scale(shapeScale); mcShape->Write(); + mcShape_1D->Write(); // Save shape ratios 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()); // 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; + delete mcShape_1D; } // Save residual calculations of what contributed to the chi2 values. if (residual) { } if (fIsProjFitX || fIsProjFitY || drawProj) { // If not already made, make the projections 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); // This is not the correct way of doing it // 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 (drawSliceMC) { TCanvas *c1 = new TCanvas((fName + "_MC_CANV_Y").c_str(), (fName + "_MC_CANV_Y").c_str(), 1024, 1024); c1->Divide(2, int(fDataHist->GetNbinsY() / 3. + 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.0, 0.0, 1.0, 1.0); leg->AddEntry(fDataHist, (fName + " Data").c_str(), "lep"); leg->AddEntry(fMCHist, (fName + " MC").c_str(), "l"); leg->AddEntry(mcShape, (fName + " Shape").c_str(), "l"); leg->SetLineColor(0); leg->SetLineStyle(0); leg->SetFillColor(0); leg->SetLineStyle(0); leg->Draw("SAME"); // Make Y slices for (int i = 1; i < fDataHist->GetNbinsY() + 1; i++) { c1->cd(i + 1); TH1D *fDataHist_SliceY = PlotUtils::GetSliceY(fDataHist, i); fDataHist_SliceY->Draw("E1"); TH1D *fMCHist_SliceY = PlotUtils::GetSliceY(fMCHist, i); fMCHist_SliceY->Draw("SAME"); TH1D *mcShape_SliceY = PlotUtils::GetSliceY(mcShape, i); mcShape_SliceY->Draw("SAME"); mcShape_SliceY->SetLineStyle(mcShape->GetLineStyle()); } c1->Write(); delete c1; delete leg; TCanvas *c2 = new TCanvas((fName + "_MC_CANV_X").c_str(), (fName + "_MC_CANV_X").c_str(), 1024, 1024); c2->Divide(2, int(fDataHist->GetNbinsX() / 3. + 1)); mcShape = (TH2D *)fMCHist->Clone((fName + "_MC_SHAPE").c_str()); shapeScale = fDataHist->Integral("width") / fMCHist->Integral("width"); mcShape->Scale(shapeScale); mcShape->SetLineStyle(7); c2->cd(1); TLegend *leg2 = new TLegend(0.0, 0.0, 1.0, 1.0); leg2->AddEntry(fDataHist, (fName + " Data").c_str(), "lep"); leg2->AddEntry(fMCHist, (fName + " MC").c_str(), "l"); leg2->AddEntry(mcShape, (fName + " Shape").c_str(), "l"); leg2->SetLineColor(0); leg2->SetLineStyle(0); leg2->SetFillColor(0); leg2->SetLineStyle(0); leg2->Draw("SAME"); // Make Y slices for (int i = 1; i < fDataHist->GetNbinsX() + 1; i++) { c2->cd(i + 1); TH1D *fDataHist_SliceX = PlotUtils::GetSliceX(fDataHist, i); fDataHist_SliceX->Draw("E1"); TH1D *fMCHist_SliceX = PlotUtils::GetSliceX(fMCHist, i); fMCHist_SliceX->Draw("SAME"); TH1D *mcShape_SliceX = PlotUtils::GetSliceX(mcShape, i); mcShape_SliceX->Draw("SAME"); mcShape_SliceX->SetLineStyle(mcShape->GetLineStyle()); } c2->Write(); delete c2; delete leg2; } // Write Extra Histograms AutoWriteExtraTH1(); WriteExtraHistograms(); // Returning NUIS_LOG(SAM, "Written Histograms: " << fName); return; } /* Setup Functions */ //******************************************************************** 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; NUIS_LOG(SAM, "Found event rate measurement but fIsRawEvents == false!"); NUIS_LOG(SAM, "Overriding this and setting fIsRawEvents == true!"); } fIsEnu = false; if ((fName.find("XSec") != std::string::npos) && (fName.find("Enu") != std::string::npos)) { fIsEnu = true; - NUIS_LOG(SAM, "::" << fName << "::"); NUIS_LOG(SAM, "Found XSec Enu measurement, applying flux integrated scaling, " "not flux averaged!"); if (FitPar::Config().GetParB("EventManager")) { NUIS_ERR(FTL, "Enu Measurements do not yet work with the Event Manager!"); NUIS_ERR(FTL, "If you want decent flux unfolded results please run in " "series mode (-q EventManager=0)"); sleep(2); throw; } } if (fIsEnu && fIsRawEvents) { NUIS_ERR(FTL, "Found 1D Enu XSec distribution AND fIsRawEvents, is this " "really correct?!"); NUIS_ERR(FTL, "Check experiment constructor for " << fName << " and correct this!"); NUIS_ABORT("I live in " << __FILE__ << ":" << __LINE__); } // Reset everything to NULL fRW = rw; // Setting up 2D Inputs this->SetupInputs(inputfile); // Set Default Options SetFitOptions(fDefaultTypes); // Set Passed Options SetFitOptions(type); } //******************************************************************** void Measurement2D::SetupDefaultHist() { //******************************************************************** // Setup fMCHist 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)); // Setup MC Stat fMCStat = (TH2D *)fMCHist->Clone(); fMCStat->Reset(); // Setup the NEUT Mode Array // 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()) { maskloc = FitPar::GetDataBase() + "/masks/" + fName + ".mask"; } SetBinMask(maskloc); } return; } //******************************************************************** void Measurement2D::SetDataValues(std::string dataFile, std::string TH2Dname) { //******************************************************************** if (dataFile.find(".root") == std::string::npos) { NUIS_ERR(FTL, "Error! " << dataFile << " is not a .root file"); NUIS_ERR(FTL, "Currently only .root file reading is supported (MiniBooNE " "CC1pi+ 2D), but implementing .txt should be dirt easy"); NUIS_ABORT("See me at " << __FILE__ << ":" << __LINE__); } else { 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()); delete inFile; } return; } //******************************************************************** 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(), std::ifstream::in); fDataHist = new TH2D((fName + "_data").c_str(), (fName + fPlotTitles).c_str(), fNDataPointsX - 1, fXBins, fNDataPointsY - 1, fYBins); if (data.is_open()) { NUIS_LOG(SAM, "Reading data from: " << dataFile.c_str()); } while (std::getline(data >> std::ws, line, '\n')) { int xBin = 0; // Loop over entries and insert them into the histogram std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { fDataHist->SetBinContent(xBin + 1, yBin + 1, (*iter) * dataNorm); xBin++; } yBin++; } yBin = 0; std::ifstream error(errorFile.c_str(), std::ifstream::in); if (error.is_open()) { NUIS_LOG(SAM, "Reading errors from: " << errorFile.c_str()); } while (std::getline(error >> std::ws, line, '\n')) { int xBin = 0; // Loop over entries and insert them into the histogram std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { fDataHist->SetBinError(xBin + 1, yBin + 1, (*iter) * errorNorm); xBin++; } yBin++; } return; }; //******************************************************************** 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); NUIS_LOG(SAM, "Reading data from: " << dataFile); PlotUtils::Set2DHistFromText(dataFile, fDataHist, dataNorm, true); return; }; //******************************************************************** void Measurement2D::SetCovarMatrix(std::string covarFile) { //******************************************************************** // Used to read a covariance matrix from a root file TFile *tempFile = new TFile(covarFile.c_str(), "READ"); // Make plots that we want TH2D *covarPlot = 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"; covarPlot = (TH2D *)tempFile->Get((covName + "cov").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 { NUIS_ERR(WRN, " Incorrect thrown_covariance option in parameters."); } // Bin masking? 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; row = 0; column = 0; 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++) { // 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) { 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(), ""); tempFile->Close(); delete tempFile; return; }; //******************************************************************** 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(), std::ifstream::in); this->covar = new TMatrixDSym(dim); fFullCovar = new TMatrixDSym(dim); if (covar.is_open()) { NUIS_LOG(SAM, "Reading covariance matrix from file: " << covarFile); } 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 std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); 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(), ""); return; }; //******************************************************************** 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(), std::ifstream::in); TMatrixD *newcov = new TMatrixD(dim, dim); if (covarread.is_open()) { NUIS_LOG(SAM, "Reading covariance matrix from file: " << covarFile); } 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 std::vector entries = GeneralUtils::ParseToDbl(line, " "); for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { (*newcov)(row, column) = *iter; column++; } row++; } covarread.close(); // Form full covariance 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(), ""); return; }; // //******************************************************************** // void Measurement2D::SetMapValuesFromText(std::string dataFile) { // //******************************************************************** // 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; // PlotUtils::Set2DHistFromText(dataFile, fMapHist, 1.0); // return; // }; diff --git a/src/FitBase/Measurement2D.h b/src/FitBase/Measurement2D.h index eb0a5b1..c3073ab 100644 --- a/src/FitBase/Measurement2D.h +++ b/src/FitBase/Measurement2D.h @@ -1,631 +1,631 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MEASUREMENT_2D_HXX_SEEN #define MEASUREMENT_2D_HXX_SEEN /*! * \addtogroup FitBase * @{ */ #include #include #include #include #include #include #include #include #include // ROOT includes #include #include #include #include #include #include #include #include #include // External data fit includes #include "FitEvent.h" #include "FitUtils.h" #include "MeasurementBase.h" #include "MeasurementVariableBox2D.h" #include "PlotUtils.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 */ /// \brief Setup all configs once initialised /// /// Should be called after all configs have been setup inside fSettings /// container. Handles the processing of inputs and setting up of types. /// Replaces the old 'SetupMeasurement' function. void FinaliseSampleSettings(); /// \brief Creates the 2D data distribution given the binning provided. virtual void CreateDataHistogram(int dimx, double *binx, int dimy, double *biny); /// \brief Set Data Histogram from a list of contents in a text file /// /// Assumes the format: \n /// x_low_1 y_low_1 cont_11 err_11 \n /// x_low_1 y_low_2 cont_12 err_12 \n /// x_low_2 y_low_1 cont_21 err_21 \n /// x_low_2 y_low_2 cont_22 err_22 \n /// x_low_2 y_low_3 cont_23 err_23 \n /// x_low_3 y_low_2 cont_32 err_32 \n virtual void SetDataFromTextFile(std::string data, std::string binx, std::string biny); /// \brief Set Data Histogram from a TH2D in a file /// /// - datfile = Full path to data file /// - histname = Name of histogram /// /// If histname not given it assumes that datfile /// is in the format: \n /// 'file.root;histname' virtual void SetDataFromRootFile(std::string datfile, std::string histname = ""); /// \brief Set data values from a 2D array in text file /// /// \warning requires DATA HISTOGRAM TO BE SET FIRST /// /// Assumes form: \n /// cont_11 cont_12 ... cont_1N \n /// cont_21 cont_22 ... cont_2N \n /// ... ... ... ... \n /// cont_N1 cont_N2 ... cont_NN \n virtual void SetDataValuesFromTextFile(std::string datfile, TH2D *hist = NULL); /// \brief Set data errors from a 2D array in text file /// /// \warning requires DATA HISTOGRAM TO BE SET FIRST /// /// Assumes form: \n /// errs_11 errs_12 ... errs_1N \n /// errs_21 errs_22 ... errs_2N \n /// ... ... ... ... \n /// errs_N1 errs_N2 ... errs_NN \n virtual void SetDataErrorsFromTextFile(std::string datfile, TH2D *hist = NULL); /// \brief Set data bin errors to sqrt(entries) /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Sets the data errors as the sqrt of the bin contents /// Should be use for counting experiments virtual void SetPoissonErrors(); /// \brief Make diagonal covariance from data /// /// \warning If no histogram passed, data must be setup first! /// Setup the covariance inputs by taking the data histogram /// errors and setting up a diagonal covariance matrix. /// /// If no data is supplied, fDataHist is used if already set. virtual void SetCovarFromDiagonal(TH2D *data = NULL); /// \brief Read the data covariance from a text file. /// /// Inputfile should have the format: \n /// covariance_11 covariance_12 covariance_13 ... \n /// covariance_21 covariance_22 covariance_23 ... \n /// ... ... ... ... \n /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCovarFromTextFile(std::string covfile, int dim = -1); /// \brief Read the data covariance from a ROOT file. /// /// - covfile specifies the full path to the file /// - histname specifies the name of the covariance object. Both TMatrixDSym /// and TH2D are supported. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCovarFromRootFile(std::string covfile, std::string histname = ""); /// \brief Read the inverted data covariance from a text file. /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCovarInvertFromTextFile(std::string covfile, int dim = -1); /// \brief Read the inverted data covariance from a ROOT file. /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCovarInvertFromRootFile(std::string covfile, std::string histname = ""); /// \brief Read the data correlations from a text file. /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCorrelationFromTextFile(std::string covfile, int dim = -1); /// \brief Read the data correlations from a ROOT file. /// /// \warning REQUIRES DATA TO BE SET FIRST /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCorrelationFromRootFile(std::string covfile, std::string histname = ""); /// \brief Read the cholesky decomposed covariance from a text file and turn /// it into a covariance /// /// Inputfile should have similar format to that shown /// in SetCovarFromTextFile. /// /// If no dimensions are given, it is assumed from the number /// entries in the first line of covfile. virtual void SetCholDecompFromTextFile(std::string covfile, int dim = -1); /// \brief Read the cholesky decomposed covariance from a ROOT file and turn /// it into a covariance /// /// Inputfile should have similar format to that shown /// in SetCovarFromRootFile. /// /// If no histogram name is given the inhistfile value /// is automatically parsed with ; so that: \n /// mycovfile.root;myhistname \n /// will also work. virtual void SetCholDecompFromRootFile(std::string covfile, std::string histname = ""); void SetShapeCovar(); /// \brief Read the map values from a text file /// /// \warning Requires DATA hist to be set beforehand. /// Format should be a 2D array of mappings. /// -1 indicates empty bins. \n /// e.g.: \n /// 1 2 3 4 5 \n /// -1 6 7 8 9 \n /// -1 -1 10 11 -1 \n virtual void SetMapValuesFromText(std::string dataFile); /// \brief Scale the data by some scale factor virtual void ScaleData(double scale); /// \brief Scale the data error bars by some scale factor virtual void ScaleDataErrors(double scale); /// \brief Scale the covariaince and its invert/decomp by some scale factor. virtual void ScaleCovar(double scale); /// \brief Setup a bin masking histogram and apply masking to data /// /// \warning REQUIRES DATA HISTOGRAM TO BE SET FIRST /// /// Reads in a list of bins in a text file to be masked. Format is: \n /// bin_index_x_1 bin_index_y_1 1 \n /// bin_index_x_2 bin_index_y_2 1 \n /// bin_index_x_3 bin_index_y_3 1 \n /// /// If 0 is given then a bin entry will NOT be masked. So for example: \n\n /// 1 1 1 \n /// 2 0 1 \n /// 3 4 0 \n /// 4 0 1 \n\n /// Will mask only the (1,1), (2,0), and (4,0) bins. /// /// Masking can be turned on by specifiying the MASK option when creating a /// sample. When this is passed NUISANCE will look in the following locations /// for the mask file: /// - FitPar::Config().GetParS(fName + ".mask") /// - "data/masks/" + fName + ".mask"; virtual void SetBinMask(std::string maskfile); /// \brief Set the current fit options from a string. /// /// This is called twice for each sample, once to set the default /// and once to set the current setting (if anything other than default given) /// /// For this to work properly it requires the default and allowed types to be /// set correctly. These should be specified as a string listing options. /// /// To split up options so that NUISANCE can automatically detect ones that /// are conflicting. Any options separated with the '/' symbol are non /// conflicting and can be given together, whereas any separated with the ',' /// symbol cannot be specified by the end user at the same time. /// /// Default Type Examples: /// - DIAG/FIX = Default option will be a diagonal covariance, with FIXED /// norm. /// - MASK/SHAPE = Default option will be a masked hist, with SHAPE always on. /// /// Allowed Type examples: /// - 'FULL/DIAG/NORM/MASK' = Any of these options can be specified. /// - 'FULL,FREE,SHAPE/MASK/NORM' = User can give either FULL, FREE, or SHAPE /// as on option. MASK and NORM can also be included as options. virtual void SetFitOptions(std::string opt); /// \brief Final constructor setup /// \warning Should be called right at the end of the constructor. /// /// Contains a series of checks to ensure the data and inputs have been setup. /// Also creates the MC histograms needed for fitting. void FinaliseMeasurement(); /* Reconfigure */ /// \brief Create a Measurement1D box /// /// Creates a new 1D variable box containing just fXVar. /// /// This box is the bare minimum required by the JointFCN when /// running fast reconfigures during a routine. /// If for some reason a sample needs extra variables to be saved then /// it should override this function creating its own MeasurementVariableBox /// that contains the extra variables. virtual MeasurementVariableBox *CreateBox() { return new MeasurementVariableBox2D(); }; /// \brief Reset all MC histograms /// /// Resets all standard histograms and those registered to auto /// process to zero. /// /// If extra histograms are not included in auto processing, then they must be /// reset by overriding this function and doing it manually if required. virtual void ResetAll(void); /// \brief Fill MC Histograms from XVar, YVar /// /// Fill standard histograms using fXVar, fYVar, Weight read from the variable /// box. /// /// WARNING : Any extra MC histograms need to be filled by overriding this /// function, even if they have been set to auto process. virtual void FillHistograms(void); // \brief Convert event rates to final histogram /// /// Apply standard scaling procedure to standard mc histograms to convert from /// raw events to xsec prediction. /// /// If any distributions have been set to auto process /// that is done during this function call, and a differential xsec is /// assumed. If that is not the case this function must be overriden. virtual void ScaleEvents(void); /// \brief Scale MC by a factor=1/norm /// /// Apply a simple normalisation scaling if the option FREE or a /// norm_parameter has been specified in the NUISANCE routine. virtual void ApplyNormScale(double norm); /* Statistical Functions */ /// \brief Get Number of degrees of freedom /// /// Returns the number bins inside the data histogram accounting for /// any bin masking applied. virtual int GetNDOF(); /// \brief Return Data/MC Likelihood at current state /// /// Returns the likelihood of the data given the current MC prediction. /// Diferent likelihoods definitions are used depending on the FitOptions. virtual double GetLikelihood(void); /* Fake Data */ /// \brief Set the fake data values from either a file, or MC /// /// - Setting from a file "path": \n /// When reading from a file the full path must be given to a standard /// nuisance output. The standard MC histogram should have a name that matches /// this sample for it to be read in. /// \n\n /// - Setting from "MC": \n /// If the MC option is given the current MC prediction is used as fake data. virtual void SetFakeDataValues(std::string fakeOption); /// \brief Reset fake data back to starting fake data /// /// Reset the fake data back to original fake data (Reset back to before /// ThrowCovariance was first called) virtual void ResetFakeData(void); /// \brief Reset fake data back to original data /// /// Reset the data histogram back to the true original dataset for this sample /// before any fake data was defined. virtual void ResetData(void); /// \brief Generate fake data by throwing the covariance. /// /// Can be used on fake MC data or just the original dataset. /// Call ResetFakeData or ResetData to return to values before the throw. virtual void ThrowCovariance(void); /// \brief Throw the data by its assigned errors and assign this to MC /// /// Used when creating data toys by assign the MC to this thrown data /// so that the likelihood is calculated between data and thrown data virtual void ThrowDataToy(void); /* Access Functions */ /// \brief Returns nicely formatted MC Histogram /// /// Format options can also be given in the samplesettings: /// - linecolor /// - linestyle /// - linewidth /// - fillcolor /// - fillstyle /// /// So to have a sample line colored differently in the xml cardfile put: \n /// virtual TH2D *GetMCHistogram(void); /// \brief Returns nicely formatted data Histogram /// /// Format options can also be given in the samplesettings: /// - datacolor /// - datastyle /// - datawidth /// /// So to have a sample data colored differently in the xml cardfile put: \n /// virtual TH2D *GetDataHistogram(void); /// \brief Returns a list of all MC histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetMCList(void) { return std::vector(1, GetMCHistogram()); } /// \brief Returns a list of all Data histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetDataList(void) { return std::vector(1, GetDataHistogram()); } /// \brief Returns a list of all Mask histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetMaskList(void) { return std::vector(1, fMaskHist); }; /// \brief Returns a list of all Fine histograms. /// /// Override this if you have extra histograms that need to be /// accessed outside of the Measurement1D class. inline virtual std::vector GetFineList(void) { return std::vector(1, fMCFine); }; /* Write Functions */ /// \brief Save the current state to the current TFile directory \n /// /// Data/MC are both saved by default. /// A range of other histograms can be saved by setting the /// config option 'drawopts'. /// /// Possible options: \n /// - FINE = Write Fine Histogram \n /// - WEIGHTS = Write Weighted MC Histogram (before scaling) \n /// - FLUX = Write Flux Histogram from MC Input \n /// - EVT = Write Event Histogram from MC Input \n /// - XSEC = Write XSec Histogram from MC Input \n /// - MASK = Write Mask Histogram \n /// - COV = Write Covariance Histogram \n /// - INVCOV = Write Inverted Covariance Histogram \n /// - DECMOP = Write Decomp. Covariance Histogram \n /// - RESIDUAL= Write Resudial Histograms \n /// - RATIO = Write Data/MC Ratio Histograms \n /// - SHAPE = Write MC Shape Histograms norm. to Data \n /// - CANVMC = Build MC Canvas Showing Data, MC, Shape \n /// - MODES = Write PDG Stack \n /// - CANVPDG = Build MC Canvas Showing Data, PDGStack \n /// /// So to save a range of these in parameters/config.xml set: \n /// virtual void Write(std::string drawOpt); //////// OLD 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); //! Setup the default mc Hist given a data histogram virtual void SetupDefaultHist(); //! 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, std::string TH2Dname); //! Set the data values only from a text file 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 virtual void SetCovarMatrixFromChol(std::string covarFile, int dim); 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 // 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 TH2D *fMCStat; TH2I *fMaskHist; //!< mask histogram for the data TH2I *fMapHist; //!< map histogram used to convert 2D to 1D distributions TH2D *fResidualHist; TH2D *fChi2LessBinHist; 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 TMatrixDSym *fShapeCovar; double fCovDet; //!< covariance deteriminant double fNormError; //!< Normalisation on the error on the data double fLikelihood; //!< Likelihood value 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 fUseShapeNormDecomp; 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 fIsWriting; TrueModeStack *fMCHist_Modes; ///< Optional True Mode Stack TMatrixDSym *fCovar; ///< New FullCovar TMatrixDSym *fInvert; ///< New covar // Fake Data std::string fFakeDataInput; ///< Input fake data file path TFile *fFakeDataFile; ///< Input fake data file // Arrays for data entries Double_t *fDataValues; ///< REMOVE data bin contents Double_t *fDataErrors; ///< REMOVE data bin errors }; /*! @} */ #endif diff --git a/src/FitBase/MeasurementBase.cxx b/src/FitBase/MeasurementBase.cxx index e59484e..26ed24c 100644 --- a/src/FitBase/MeasurementBase.cxx +++ b/src/FitBase/MeasurementBase.cxx @@ -1,597 +1,595 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MeasurementBase.h" /* Constructor/Destructors */ //******************************************************************** // 2nd Level Constructor (Inherits From MeasurementBase.h) MeasurementBase::MeasurementBase(void) { //******************************************************************** fScaleFactor = 1.0; fMCFilled = false; fNoData = false; fInput = NULL; NSignal = 0; // Set the default values // After-wards this gets set in SetupMeasurement EnuMin = 0.; EnuMax = 1.E5; fMeasurementSpeciesType = kSingleSpeciesMeasurement; fEventVariables = NULL; fIsJoint = false; fNPOT = 0xdeadbeef; fFluxIntegralOverride = 0xdeadbeef; fTargetVolume = 0xdeadbeef; fTargetMaterialDensity = 0xdeadbeef; fEvtRateScaleFactor = 0xdeadbeef; }; void MeasurementBase::FinaliseMeasurement() { // Used to setup default data hists, covars, etc. } //******************************************************************** // 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 file_descriptor = GeneralUtils::ParseToStr(inputfile, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfile << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inpType = InputUtils::ParseInputType(file_descriptor[0]); fInput = InputUtils::CreateInputHandler(fName, inpType, file_descriptor[1]); } fNEvents = fInput->GetNEvents(); // Expect INPUTTYPE:FileLocation(s) std::vector file_descriptor = GeneralUtils::ParseToStr(inputfile, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfile << "\". expected \"FILETYPE:file.root\""); } fInputType = InputUtils::ParseInputType(file_descriptor[0]); fInputFileName = file_descriptor[1]; if (EnuMin == 0 && EnuMax == 1.E5) { EnuMin = fInput->GetFluxHistogram()->GetBinLowEdge(1); EnuMax = fInput->GetFluxHistogram()->GetBinLowEdge( fInput->GetFluxHistogram()->GetNbinsX() + 1); } fFluxHist = fInput->GetFluxHistogram(); fEventHist = fInput->GetEventHistogram(); } //*********************************************** int MeasurementBase::GetInputID() { //*********************************************** return FitBase::GetInputID(fInputFileName); } //*********************************************** SampleSettings MeasurementBase::LoadSampleSettings(nuiskey samplekey) { //*********************************************** SampleSettings setting = SampleSettings(samplekey); fName = setting.GetS("name"); // Used as an initial setup function incase we need to do anything here. - NUIS_LOG(SAM, "Loading Sample : " << setting.GetName()); - fEvtRateScaleFactor = 0xdeadbeef; if (!fIsJoint) { SetupInputs(setting.GetS("input")); fNPOT = samplekey.Has("NPOT") ? samplekey.GetD("NPOT") : 1; fFluxIntegralOverride = samplekey.Has("FluxIntegralOverride") ? samplekey.GetD("FluxIntegralOverride") : 0xdeadbeef; fTargetVolume = samplekey.Has("TargetVolume") ? samplekey.GetD("TargetVolume") : 0xdeadbeef; fTargetMaterialDensity = samplekey.Has("TargetMaterialDensity") ? samplekey.GetD("TargetMaterialDensity") : 0xdeadbeef; if ((fTargetVolume != 0xdeadbeef) && (fTargetMaterialDensity != 0xdeadbeef)) { double TargetMass_kg = fTargetVolume * fTargetMaterialDensity; double NNucleons = TargetMass_kg / PhysConst::mass_nucleon_kg; double NNeutrinos = ((fFluxIntegralOverride == 0xdeadbeef) ? TotalIntegratedFlux() : fFluxIntegralOverride) * fNPOT; fEvtRateScaleFactor = NNeutrinos * NNucleons; NUIS_LOG(SAM, "\tEvent rate prediction : "); NUIS_LOG(SAM, "\t\tTarget volume : " << fTargetVolume << " m^3"); NUIS_LOG(SAM, "\t\tTarget density : " << fTargetMaterialDensity << " kg/m^3"); NUIS_LOG(SAM, "\t\tTarget mass : " << TargetMass_kg << " kg"); NUIS_LOG(SAM, "\t\tNTarget Nucleons : " << NNucleons); if ((fNPOT != 1)) { NUIS_LOG(SAM, "\t\tTotal POT : " << fNPOT); } NUIS_LOG(SAM, "\t\tNNeutrinos : " << NNeutrinos << ((fNPOT != 1) ? " /cm^2" : " /POT /cm^2")); NUIS_LOG(SAM, "\t\tXSec -> EvtRate scale factor : " << fEvtRateScaleFactor); } } return setting; } //*********************************************** SampleSettings MeasurementBase::LoadSampleSettings(std::string name, std::string input, std::string type) { //*********************************************** nuiskey samplekey = Config::CreateKey("sample"); samplekey.SetS("name", name); samplekey.SetS("input", input); samplekey.SetS("type", type); return LoadSampleSettings(samplekey); } void MeasurementBase::FinaliseSampleSettings() { EnuMin = fSettings.GetD("enu_min"); EnuMax = fSettings.GetD("enu_max"); } //*********************************************** void MeasurementBase::Reconfigure() { //*********************************************** NUIS_LOG(REC, " Reconfiguring sample " << fName); // Reset Histograms ResetExtraHistograms(); AutoResetExtraTH1(); this->ResetAll(); // FitEvent* cust_event = fInput->GetEventPointer(); int fNEvents = fInput->GetNEvents(); int countwidth = (fNEvents / 5); // MAIN EVENT LOOP FitEvent *cust_event = fInput->FirstNuisanceEvent(); int i = 0; int npassed = 0; while (cust_event) { cust_event->RWWeight = fRW->CalcWeight(cust_event); cust_event->Weight = cust_event->RWWeight * cust_event->InputWeight; Weight = cust_event->Weight; // 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); if (Signal) npassed++; GetBox()->SetX(fXVar); GetBox()->SetY(fYVar); GetBox()->SetZ(fZVar); GetBox()->SetMode(Mode); // GetBox()->fSignal = Signal; // Fill Histogram Values GetBox()->FillBoxFromEvent(cust_event); // this->FillExtraHistograms(GetBox(), Weight); this->FillHistogramsFromBox(GetBox(), Weight); // Print Out if (LOG_LEVEL(REC) && countwidth > 0 && !(i % countwidth)) { std::stringstream ss(""); ss.unsetf(std::ios_base::fixed); ss << std::setw(7) << std::right << i << "/" << fNEvents << " events (" << std::setw(2) << int(double(i) / double(fNEvents) * 100.) + 1 << 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; NUIS_LOG(SAM, ss.str()); } // iterate cust_event = fInput->NextNuisanceEvent(); i++; } NUIS_LOG(SAM, npassed << "/" << fNEvents << " passed selection "); if (npassed == 0) { NUIS_LOG(SAM, "WARNING: NO EVENTS PASSED SELECTION!"); } NUIS_LOG(REC, std::setw(10) << std::right << NSignal << "/" << fNEvents << " events passed selection + binning after reweight"); // Finalise Histograms fMCFilled = true; this->ConvertEventRates(); } void MeasurementBase::FillHistogramsFromBox(MeasurementVariableBox *var, double weight) { fXVar = var->GetX(); fYVar = var->GetY(); fZVar = var->GetZ(); Weight = weight; fEventVariables = var; FillHistograms(); FillExtraHistograms(var, weight); } void MeasurementBase::FillHistograms(double weight) { Weight = weight * GetBox()->GetSampleWeight(); FillHistograms(); FillExtraHistograms(GetBox(), Weight); } MeasurementVariableBox *MeasurementBase::FillVariableBox(FitEvent *event) { GetBox()->Reset(); Mode = event->Mode; Weight = 1.0; // event->Weight; this->FillEventVariables(event); Signal = this->isSignal(event); GetBox()->FillBoxFromEvent(event); GetBox()->SetX(fXVar); GetBox()->SetY(fYVar); GetBox()->SetZ(fZVar); GetBox()->SetMode(event->Mode); GetBox()->SetSampleWeight(Weight); // GetBox()->fSignal = Signal; return GetBox(); } MeasurementVariableBox *MeasurementBase::GetBox() { if (!fEventVariables) fEventVariables = CreateBox(); return fEventVariables; } //*********************************************** void MeasurementBase::ReconfigureFast() { //*********************************************** this->Reconfigure(); } //*********************************************** void MeasurementBase::ConvertEventRates() { //*********************************************** AutoScaleExtraTH1(); ScaleExtraHistograms(GetBox()); this->ScaleEvents(); double normval = fRW->GetSampleNorm(this->fName); if (normval < 0.01 or normval > 10.0) { NUIS_ERR(WRN, "Norm Value inside MeasurementBase::ConvertEventRates() looks off!"); NUIS_ERR(WRN, "It could have become out of sync with the minimizer norm list."); NUIS_ERR(WRN, "Setting it to 1.0"); normval = 1.0; } AutoNormExtraTH1(normval); NormExtraHistograms(GetBox(), normval); this->ApplyNormScale(normval); } //*********************************************** InputHandlerBase *MeasurementBase::GetInput() { //*********************************************** if (!fInput) { NUIS_ABORT("MeasurementBase::fInput not set. Please submit your command " "line options and input cardfile with a bug report to: " "nuisance@projects.hepforge.org"); } 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 = fRW->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 MeasurementBase::GetFluxList() { //*********************************************** return GetInput()->GetFluxList(); } //*********************************************** std::vector MeasurementBase::GetEventRateList() { //*********************************************** return GetInput()->GetEventList(); } //*********************************************** std::vector MeasurementBase::GetXSecList() { //*********************************************** return GetInput()->GetXSecList(); } void MeasurementBase::ProcessExtraHistograms(int cmd, MeasurementVariableBox *vars, double weight) { // This should be overriden if we have extra histograms!!! // Add a flag to tell user this... return; } void MeasurementBase::FillExtraHistograms(MeasurementVariableBox *vars, double weight) { ProcessExtraHistograms(kCMD_Fill, vars, weight); } void MeasurementBase::ScaleExtraHistograms(MeasurementVariableBox *vars) { ProcessExtraHistograms(kCMD_Scale, vars, 1.0); } void MeasurementBase::ResetExtraHistograms() { ProcessExtraHistograms(kCMD_Reset, NULL, 1.0); } void MeasurementBase::NormExtraHistograms(MeasurementVariableBox *vars, double norm) { ProcessExtraHistograms(kCMD_Norm, vars, norm); } void MeasurementBase::WriteExtraHistograms() { ProcessExtraHistograms(kCMD_Write, NULL, 1.00); } void MeasurementBase::SetAutoProcessTH1(TH1 *hist, int c1, int c2, int c3, int c4, int c5) { FakeStack *fake = new FakeStack(hist); SetAutoProcessTH1(fake, c1, c2, c3, c4, c5); // Need to add a destroy command! } void MeasurementBase::SetAutoProcess(TH1 *hist, int c1, int c2, int c3, int c4, int c5) { FakeStack *fake = new FakeStack(hist); SetAutoProcessTH1(fake, c1, c2, c3, c4, c5); // Need to add a destroy command! } void MeasurementBase::SetAutoProcess(TGraph *g, int c1, int c2, int c3, int c4, int c5) { FakeStack *fake = new FakeStack(g); SetAutoProcessTH1(fake, c1, c2, c3, c4, c5); // Need to add a destroy command! } void MeasurementBase::SetAutoProcess(TF1 *f, int c1, int c2, int c3, int c4, int c5) { FakeStack *fake = new FakeStack(f); SetAutoProcessTH1(fake, c1, c2, c3, c4, c5); // Need to add a destroy command! } void MeasurementBase::SetAutoProcess(StackBase *hist, int c1, int c2, int c3, int c4, int c5) { SetAutoProcessTH1(hist, c1, c2, c3, c4, c5); } void MeasurementBase::SetAutoProcessTH1(StackBase *hist, int c1, int c2, int c3, int c4, int c5) { // Set Defaults // int ncommands = kCMD_extraplotflags; int givenflags[5]; givenflags[0] = c1; givenflags[1] = c2; givenflags[2] = c3; givenflags[3] = c4; givenflags[4] = c5; fExtraTH1s[hist] = std::vector(5, 0); // Setup a default one. if (c1 == -1 && c2 == -1 && c3 == -1 && c4 == -1 && c5 == -1) { fExtraTH1s[hist][kCMD_Reset] = 1; fExtraTH1s[hist][kCMD_Scale] = 1; fExtraTH1s[hist][kCMD_Norm] = 1; fExtraTH1s[hist][kCMD_Write] = 1; } for (int i = 0; i < 5; i++) { switch (givenflags[i]) { // Skip over... case -1: break; case kCMD_Reset: case kCMD_Scale: case kCMD_Norm: case kCMD_Write: fExtraTH1s[hist][givenflags[i]] = 1; break; case kCMD_Fill: { NUIS_ERR(FTL, "Can't auto fill yet!"); break; } default: break; } } } void MeasurementBase::AutoFillExtraTH1() { NUIS_ABORT("Can't auto fill yet! it's too inefficent!"); return; } void MeasurementBase::AutoResetExtraTH1() { for (std::map >::iterator iter = fExtraTH1s.begin(); iter != fExtraTH1s.end(); iter++) { if (!((*iter).second)[kCMD_Reset]) continue; (*iter).first->Reset(); } }; void MeasurementBase::AutoScaleExtraTH1() { for (std::map >::iterator iter = fExtraTH1s.begin(); iter != fExtraTH1s.end(); iter++) { if (!((*iter).second)[kCMD_Scale]) continue; if (fIsNoWidth) { (*iter).first->Scale(fScaleFactor); } else { (*iter).first->Scale(fScaleFactor, "width"); } } }; void MeasurementBase::AutoNormExtraTH1(double norm) { double sfactor = 0.0; if (norm != 0.0) sfactor = 1.0 / norm; for (std::map >::iterator iter = fExtraTH1s.begin(); iter != fExtraTH1s.end(); iter++) { if (!((*iter).second)[kCMD_Norm]) continue; (*iter).first->Scale(sfactor); } }; void MeasurementBase::AutoWriteExtraTH1() { for (std::map >::iterator iter = fExtraTH1s.begin(); iter != fExtraTH1s.end(); iter++) { if (!(((*iter).second)[kCMD_Write])) continue; (*iter).first->Write(); } }; diff --git a/src/FitBase/MeasurementBase.h b/src/FitBase/MeasurementBase.h index 87eae43..dc98bba 100644 --- a/src/FitBase/MeasurementBase.h +++ b/src/FitBase/MeasurementBase.h @@ -1,366 +1,366 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef INPUTHANDLER_H_SEEN #define INPUTHANDLER_H_SEEN /*! * \addtogroup FitBase * @{ */ // C Includes #include #include #include #include #include #include #include #include #include #include // ROOT includes #include #include #include #include #include #include #include #include #include #include // External data fit includes #include "FitEvent.h" #include "FitUtils.h" #include "GeneralUtils.h" #include "PlotUtils.h" #include "StatUtils.h" #include "InputFactory.h" #include "FitWeight.h" #include "TMultiDimFit.h" #ifdef __GENIE_ENABLED__ #ifdef GENIE_PRE_R3 #include "Conventions/Units.h" #else #include "Framework/Conventions/Units.h" #endif #endif #include "EventManager.h" #include "TObject.h" #include "InputHandler.h" #include "NuisConfig.h" #include "NuisKey.h" #include "SampleSettings.h" #include "StackBase.h" #include "StandardStacks.h" /// Enumerations to help with extra plot functions enum extraplotflags { kCMD_Reset = 0, kCMD_Fill, kCMD_Scale, kCMD_Norm, kCMD_Write, kCMD_Error, kCMD_extraplotflags }; 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. /// Used generally for the MC inputs. //! 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(); //! Default virtual destructor virtual ~MeasurementBase(void); virtual void InitialSetup(void) {}; /* Reconfigure Functions */ //! 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); virtual void FillHistograms(double weight); //! 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 void ThrowCovariance(void) = 0; virtual void ThrowDataToy(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); //! Get the predicted event rate for this sample virtual double PredictedEventRate(std::string intOpt = "width", double low = -9999.9, double high = -9999.9); virtual SampleSettings LoadSampleSettings(nuiskey samplekey); virtual SampleSettings LoadSampleSettings(std::string name, std::string input, std::string type); virtual void FinaliseSampleSettings(); virtual void FinaliseMeasurement(); virtual void ProcessExtraHistograms(int cmd, MeasurementVariableBox* vars, double weight = 1.0); virtual void FillExtraHistograms(MeasurementVariableBox* vars, double weight = 1.0); virtual void ScaleExtraHistograms(MeasurementVariableBox* vars); virtual void ResetExtraHistograms(); virtual void NormExtraHistograms(MeasurementVariableBox* vars, double norm = 1.0); virtual void WriteExtraHistograms(); virtual MeasurementVariableBox* CreateBox() {return new MeasurementVariableBox();}; int GetPassed() { int signalSize = 0; return signalSize; } 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; }; ///! Check whether this event is signle (Handled in each inherited sample) virtual bool isSignal(FitEvent* event) { (void)event; return false; }; ///! 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. virtual void ScaleEvents(void) {}; ///! Apply the scale factor at the end of reconfigure. virtual void ApplyNormScale(double norm) { (void)norm; }; ///! Save Histograms virtual void Write(std::string drawOpt = "") = 0; virtual MeasurementVariableBox* FillVariableBox(FitEvent* event); virtual MeasurementVariableBox* GetBox(); void FillHistogramsFromBox(MeasurementVariableBox* var, double weight); /* Histogram Access Functions */ ///! Virtual function to get data histogram virtual std::vector GetDataList(void) = 0; ///! Virtual function to get MC histogram virtual std::vector GetMCList(void) = 0; virtual std::vector GetFineList(void) = 0; virtual std::vector GetMaskList(void) = 0; ///! Return flux histograms in a vector virtual std::vector GetFluxList(void); virtual std::vector GetEventRateList(void); virtual std::vector 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 InputHandlerBase* GetInput(void); 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; }; void SetupInputs(std::string inputfile); int GetInputID(void); 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; }; inline void SetXVar(double xvar) { fXVar = xvar; }; inline void SetYVar(double yvar) { fYVar = yvar; }; inline void SetZVar(double zvar) { fZVar = zvar; }; virtual std::vector GetSubSamples() { return std::vector(1, this); } void SetAutoProcessTH1(TH1* hist, int c1 = -1, int c2 = -1, int c3 = -1, int c4 = -1, int c5 = -1); void SetAutoProcess(TH1* hist, int c1 = -1, int c2 = -1, int c3 = -1, int c4 = -1, int c5 = -1); void SetAutoProcess(TGraph* g, int c1 = -1, int c2 = -1, int c3 = -1, int c4 = -1, int c5 = -1); void SetAutoProcess(TF1* f, int c1 = -1, int c2 = -1, int c3 = -1, int c4 = -1, int c5 = -1); void SetAutoProcess(StackBase* hist, int c1 = -1, int c2 = -1, int c3 = -1, int c4 = -1, int c5 = -1); void SetAutoProcessTH1(StackBase* hist, int c1 = -1, int c2 = -1, int c3 = -1, int c4 = -1, int c5 = -1); void AutoFillExtraTH1(); void AutoResetExtraTH1(); void AutoScaleExtraTH1(); void AutoNormExtraTH1(double norm); void AutoWriteExtraTH1(); // functions that need to be added. // - Initial Check // - Check Target/Beam loop. // - Check flux shape if suggested one given. // - Return MeasurementList (returns ) 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 BaseFitEvt* signal_event; FitEvent* cust_event; FitWeight* fRW; //!< Pointer to the rw engine InputHandlerBase* 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) bool fIsNoWidth; ///< Flag : Don't scale by bin width // TEMP OBJECTS TO HANDLE MERGE double fXVar, fYVar, fZVar, Mode, Weight; bool Signal; int ievt; int fNEvents; double Enu_rec, ThetaMu, CosThetaMu; InputUtils::InputType fInputType; std::string fInputFileName; TH1D* fFluxHist; TH1D* fEventHist; MeasurementSpeciesClass fMeasurementSpeciesType; SampleSettings fSettings; MeasurementVariableBox* fEventVariables; std::map > fExtraTH1s; int NSignal; // std::map fExtaStacks; bool fIsJoint; double fNPOT, fFluxIntegralOverride, fTargetVolume, fTargetMaterialDensity; double fEvtRateScaleFactor; }; // Class TypeDefs typedef std::list::const_iterator MeasListConstIter; typedef std::list::iterator MeasListIter; typedef std::vector::const_iterator MeasVectConstIter; typedef std::vector::iterator MeasVectIter; /*! @} */ #endif diff --git a/src/FitBase/ParamPull.cxx b/src/FitBase/ParamPull.cxx index bea9af0..4cb1302 100644 --- a/src/FitBase/ParamPull.cxx +++ b/src/FitBase/ParamPull.cxx @@ -1,867 +1,867 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ParamPull.h" //******************************************************************************* ParamPull::ParamPull(std::string name, std::string inputfile, std::string type, std::string dials) { //******************************************************************************* fMinHist = NULL; fMaxHist = NULL; fTypeHist = NULL; fDialSelection = dials; fLimitHist = NULL; fName = name; fInput = inputfile; fType = type; // Set the pull type SetType(fType); // Setup Histograms from input file SetupHistograms(fInput); }; //******************************************************************************* void ParamPull::SetType(std::string type) { //******************************************************************************* fType = type; // Assume Default if empty if (type.empty() || type == "DEFAULT") { NUIS_ERR(WRN, "No type specified for ParmPull class " << fName); NUIS_ERR(WRN, "Assuming GAUSTHROW/GAUSPULL"); type = "GAUSTHROW/GAUSPULL"; } // Set Dial options if (type.find("FRAC") != std::string::npos) { fDialOptions = "FRAC"; fPlotTitles = ";; Fractional RW Value"; } else if (type.find("ABS") != std::string::npos) { fDialOptions = "ABS"; fPlotTitles = ";; ABS RW Value"; } else { fDialOptions = ""; fPlotTitles = ";; RW Value"; } // Parse throw types if (type.find("GAUSPULL") != std::string::npos) fCalcType = kGausPull; else fCalcType = kNoPull; if (type.find("GAUSTHROW") != std::string::npos) fThrowType = kGausThrow; else if (type.find("FLATTHROW") != std::string::npos) fThrowType = kFlatThrow; else fThrowType = kNoThrow; // Extra check to see if throws or pulls are turned off if (type.find("NOPULL") != std::string::npos) fCalcType = kNoPull; if (type.find("NOTHROW") != std::string::npos) fThrowType = kNoThrow; } //******************************************************************************* void ParamPull::SetupHistograms(std::string input) { //******************************************************************************* // Extract Types from Input fFileType = ""; const int nfiletypes = 4; const std::string filetypes[nfiletypes] = {"FIT", "ROOT", "TXT", "DIAL"}; for (int i = 0; i < nfiletypes; i++) { std::string tempTypes = filetypes[i] + ":"; if (input.find(tempTypes) != std::string::npos) { fFileType = filetypes[i]; input.replace(input.find(tempTypes), tempTypes.size(), ""); break; } } // Read Files if (!fFileType.compare("FIT")) ReadFitFile(input); else if (!fFileType.compare("ROOT")) ReadRootFile(input); else if (!fFileType.compare("VECT")) ReadVectFile(input); else if (!fFileType.compare("DIAL")) ReadDialInput(input); else { NUIS_ERR(FTL, "Unknown ParamPull Type: " << input); NUIS_ABORT("Need FIT, ROOT, VECT or DIAL"); } // Check Dials are all good if (!CheckDialsValid()) { NUIS_ABORT("DIALS NOT VALID"); } // Setup MC Histogram fMCHist = (TH1D *)fDataHist->Clone(); fMCHist->Reset(); fMCHist->SetNameTitle((fName + "_MC").c_str(), (fName + " MC" + fPlotTitles).c_str()); // If no Covar input make an uncorrelated one if (!fCovar) { fCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist, 1.0); } // If no types or limits are provided give them a default option if (!fMinHist) { NUIS_LOG(FIT, "No minimum histogram found for pull parameters, setting to be " "content - 1E6..."); fMinHist = (TH1D *)fDataHist->Clone(); fMinHist->SetNameTitle((fName + "_min").c_str(), (fName + " min" + fPlotTitles).c_str()); for (int i = 0; i < fMinHist->GetNbinsX(); i++) { // TODO (P.Stowell) Change this to a NULL system where limits are actually // free! fMinHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) - 1E6); } } if (!fMaxHist) { NUIS_LOG(FIT, "No maximum histogram found for pull parameters, setting to be " "content - 1E6..."); fMaxHist = (TH1D *)fDataHist->Clone(); fMaxHist->SetNameTitle((fName + "_min").c_str(), (fName + " min" + fPlotTitles).c_str()); for (int i = 0; i < fMaxHist->GetNbinsX(); i++) { fMaxHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) - 1E6); } } // Set types from state, or to unknown // Not really sure when or if this is ever used if (!fTypeHist) { int deftype = -1; if (fType.find("T2K") != std::string::npos) { deftype = kT2K; } else if (fType.find("NEUT") != std::string::npos) { deftype = kNEUT; } else if (fType.find("NIWG") != std::string::npos) { deftype = kNIWG; } else if (fType.find("GENIE") != std::string::npos) { deftype = kGENIE; } else if (fType.find("NORM") != std::string::npos) { deftype = kNORM; } else if (fType.find("NUWRO") != std::string::npos) { deftype = kNUWRO; } fTypeHist = new TH1I((fName + "_type").c_str(), (fName + " type" + fPlotTitles).c_str(), fDataHist->GetNbinsX(), 0, fDataHist->GetNbinsX()); for (int i = 0; i < fTypeHist->GetNbinsX(); i++) { fTypeHist->SetBinContent(i + 1, deftype); } } // Sort Covariances fInvCovar = StatUtils::GetInvert(fCovar); fDecomp = StatUtils::GetDecomp(fCovar); // Create DataTrue for Throws fDataTrue = (TH1D *)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_truedata").c_str(), (fName + " truedata" + fPlotTitles).c_str()); fDataOrig = (TH1D *)fDataHist->Clone(); fDataOrig->SetNameTitle((fName + "_origdata").c_str(), (fName + " origdata" + fPlotTitles).c_str()); // Select only dials we want if (!fDialSelection.empty()) { (*fDataHist) = RemoveBinsNotInString(*fDataHist, fDialSelection); } } //******************************************************************************* TH1D ParamPull::RemoveBinsNotInString(TH1D hist, std::string mystr) { //******************************************************************************* // Make list of allowed bins std::vector allowedbins; for (int i = 0; i < hist.GetNbinsX(); i++) { std::string syst = std::string(hist.GetXaxis()->GetBinLabel(i + 1)); if (mystr.find(syst) != std::string::npos) { allowedbins.push_back(syst); } } // Make new histogram UInt_t nbins = allowedbins.size(); TH1D newhist = TH1D(hist.GetName(), hist.GetTitle(), (Int_t)nbins, 0.0, (Double_t)nbins); // Setup bins for (UInt_t i = 0; i < nbins; i++) { // Set Labels newhist.GetXaxis()->SetBinLabel(i + 1, allowedbins[i].c_str()); // Copy Values for (Int_t j = 0; j < hist.GetNbinsX(); j++) { if (!allowedbins[i].compare(hist.GetXaxis()->GetBinLabel(j + 1))) { newhist.SetBinContent(i + 1, hist.GetBinContent(j + 1)); newhist.SetBinError(i + 1, hist.GetBinError(j + 1)); } } } return newhist; } //******************************************************************************* TH1I ParamPull::RemoveBinsNotInString(TH1I hist, std::string mystr) { //******************************************************************************* // Make list of allowed bins std::vector allowedbins; for (int i = 0; i < hist.GetNbinsX(); i++) { std::string syst = std::string(hist.GetXaxis()->GetBinLabel(i + 1)); if (mystr.find(syst) != std::string::npos) { allowedbins.push_back(syst); } } // Make new histogram UInt_t nbins = allowedbins.size(); TH1I newhist = TH1I(hist.GetName(), hist.GetTitle(), (Int_t)nbins, 0.0, (Int_t)nbins); // Setup bins for (UInt_t i = 0; i < nbins; i++) { // Set Labels newhist.GetXaxis()->SetBinLabel(i + 1, allowedbins[i].c_str()); // Copy Values for (Int_t j = 0; j < hist.GetNbinsX(); j++) { if (!allowedbins[i].compare(hist.GetXaxis()->GetBinLabel(j + 1))) { newhist.SetBinContent(i + 1, hist.GetBinContent(j + 1)); newhist.SetBinError(i + 1, hist.GetBinError(j + 1)); } } } return newhist; } //******************************************************************************* void ParamPull::ReadFitFile(std::string input) { //******************************************************************************* TFile *tempfile = new TFile(input.c_str(), "READ"); // Read Data fDataHist = (TH1D *)tempfile->Get("fit_dials_free"); CheckHist(fDataHist); fDataHist->SetDirectory(0); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + " data" + fPlotTitles).c_str()); fMinHist = (TH1D *)tempfile->Get("min_dials_free"); CheckHist(fMinHist); fMinHist->SetDirectory(0); fMinHist->SetNameTitle((fName + "_min").c_str(), (fName + " min" + fPlotTitles).c_str()); fMaxHist = (TH1D *)tempfile->Get("max_dials_free"); CheckHist(fMaxHist); fMaxHist->SetDirectory(0); fMaxHist->SetNameTitle((fName + "_max").c_str(), (fName + " max" + fPlotTitles).c_str()); // Read Covar TH2D *tempcov = (TH2D *)tempfile->Get("covariance_free"); if (!tempcov) { NUIS_ERR(FTL, "Can't find TH2D covariance_free in " << fName); NUIS_ERR(FTL, "File Entries:"); tempfile->ls(); throw; } // Setup Covar int nbins = fDataHist->GetNbinsX(); fCovar = new TMatrixDSym(nbins); for (int i = 0; i < nbins; i++) { for (int j = 0; j < nbins; j++) { (*fCovar)(i, j) = tempcov->GetBinContent(i + 1, j + 1); } } return; } //******************************************************************************* void ParamPull::ReadRootFile(std::string input) { //******************************************************************************* std::vector inputlist = GeneralUtils::ParseToStr(input, ";"); // Check all given if (inputlist.size() < 2) { NUIS_ERR(FTL, "Covar supplied in 'ROOT' format should have 3 semi-colon " "separated entries!" << std::endl << "ROOT:filename;histname[;covarname]"); NUIS_ABORT("histname = TH1D, covarname = TH2D"); } // Get Entries std::string filename = inputlist[0]; std::string histname = inputlist[1]; // Read File TFile *tempfile = new TFile(filename.c_str(), "READ"); if (tempfile->IsZombie()) { NUIS_LOG(FIT, "Looking for ParamPull input inside database"); filename = FitPar::GetDataBase() + "/" + filename; tempfile = new TFile(filename.c_str(), "READ"); } if (tempfile->IsZombie()) { NUIS_ERR(FTL, "Can't find file in " << fName); NUIS_ABORT("location = " << filename); } // Read Hist fDataHist = (TH1D *)tempfile->Get(histname.c_str()); if (!fDataHist) { NUIS_ERR(FTL, "Can't find TH1D hist " << histname << " in " << fName); NUIS_ERR(FTL, "File Entries:"); tempfile->ls(); throw; } fDataHist->SetDirectory(0); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + " data" + fPlotTitles).c_str()); NUIS_LOG(DEB, "READING COVAR"); // Read Covar if (inputlist.size() > 2) { std::string covarname = inputlist[2]; NUIS_LOG(DEB, "COVARNAME = " << covarname); TH2D *tempcov = (TH2D *)tempfile->Get(covarname.c_str()); if (!tempcov) { NUIS_ERR(FTL, "Can't find TH2D covar " << covarname << " in " << fName); NUIS_ERR(FTL, "File Entries:"); tempfile->ls(); throw; } // Setup Covar int nbins = fDataHist->GetNbinsX(); fCovar = new TMatrixDSym(nbins); for (int i = 0; i < nbins; i++) { for (int j = 0; j < nbins; j++) { (*fCovar)(i, j) = tempcov->GetBinContent(i + 1, j + 1); } } // Uncorrelated } else { NUIS_LOG(SAM, "No Covar provided so using diagonal errors for " << fName); fCovar = NULL; } } //******************************************************************************* void ParamPull::ReadVectFile(std::string input) { //******************************************************************************* std::vector inputlist = GeneralUtils::ParseToStr(input, ";"); if (inputlist.size() < 4) { NUIS_ERR(FTL, "Need 3 inputs for vector input in " << fName); NUIS_ABORT("Inputs: " << input); } // Open File std::string rootname = inputlist[0]; TFile *tempfile = new TFile(rootname.c_str(), "READ"); if (tempfile->IsZombie()) { NUIS_ERR(FTL, "Can't find file in " << fName); NUIS_ABORT("location = " << rootname); } // Get Name std::string tagname = inputlist[1]; // TVector dialtags = tempfile->Get(tagname.c_str()); // if (!dialtags){ // ERR(FTL) << "Can't find list of dial names!" << std::endl; // } // Get Values std::string valuename = inputlist[2]; TVectorD *dialvals = (TVectorD *)tempfile->Get(valuename.c_str()); if (!dialvals) { NUIS_ERR(FTL, "Can't find dial values"); } // Get Matrix std::string matrixname = inputlist[3]; TMatrixD *matrixvals = (TMatrixD *)tempfile->Get(matrixname.c_str()); if (!matrixvals) { NUIS_ERR(FTL, "Can't find matirx values"); } // Get Types if (inputlist.size() > 4) { std::string typesname = inputlist[3]; } // Get Minimum if (inputlist.size() > 5) { std::string minname = inputlist[4]; } // Get Maximum if (inputlist.size() > 6) { std::string maxname = inputlist[5]; } } //******************************************************************************* void ParamPull::ReadDialInput(std::string input) { //******************************************************************************* std::vector inputlist = GeneralUtils::ParseToStr(input, ";"); if (inputlist.size() < 3) { NUIS_ERR(FTL, "Need 3 inputs for dial input in " << fName); NUIS_ABORT("Inputs: " << input); } std::vector inputvals = GeneralUtils::ParseToDbl(input, ";"); std::string dialname = inputlist[0]; double val = inputvals[1]; double err = inputvals[2]; fDataHist = new TH1D((fName + "_data").c_str(), (fName + "_data" + fPlotTitles).c_str(), 1, 0, 1); fDataHist->SetBinContent(1, val); fDataHist->SetBinError(1, err); fDataHist->GetXaxis()->SetBinLabel(1, dialname.c_str()); fLimitHist = new TH1D((fName + "_limits").c_str(), (fName + "_limits" + fPlotTitles).c_str(), 1, 0, 1); fLimitHist->Reset(); if (inputvals.size() > 4) { fLimitHist->SetBinContent(1, (inputvals[3] + inputvals[4]) / 2.0); fLimitHist->SetBinError(1, (inputvals[4] - inputvals[3]) / 2.0); } fCovar = NULL; } //******************************************************************************* std::map ParamPull::GetAllDials() { //******************************************************************************* std::map dialtypemap; for (int i = 0; i < fDataHist->GetNbinsX(); i++) { std::string name = fDataHist->GetXaxis()->GetBinLabel(i + 1); int type = fTypeHist->GetBinContent(i + 1); dialtypemap[name] = type; } return dialtypemap; } //******************************************************************************* bool ParamPull::CheckDialsValid() { //******************************************************************************* std::string helpstring = ""; for (int i = 0; i < fDataHist->GetNbinsX(); i++) { std::string name = std::string(fDataHist->GetXaxis()->GetBinLabel(i + 1)); // If dial exists its all good if (FitBase::GetRW()->DialIncluded(name)) { NUIS_LOG(DEB, "Found dial " << name << " in covariance " << fInput << " and matched to reweight engine "); continue; } // If it doesn't but its a sample norm also continue if (name.find("_norm") != std::string::npos) { NUIS_ERR(WRN, "Norm dial included in covar but not set in FitWeight."); NUIS_ERR(WRN, "Assuming its a sample norm and skipping..."); } // Dial unknown so print a help statement std::ostringstream tempstr; tempstr << "unknown_parameter " << name << " " << fDataHist->GetBinContent(i + 1) << " " << fDataHist->GetBinContent(i + 1) - fDataHist->GetBinError(i + 1) << " " << fDataHist->GetBinContent(i + 1) + fDataHist->GetBinError(i + 1) << " " << fDataHist->GetBinError(i + 1) << " "; if (!fType.empty()) tempstr << fType << std::endl; else tempstr << "FREE" << std::endl; helpstring += tempstr.str(); } // Show statement before failing if (!helpstring.empty()) { NUIS_ERR(FTL, "Dial(s) included in covar but not set in FitWeight."); NUIS_ERR(FTL, "ParamPulls needs to know how you want it to be treated."); NUIS_ABORT("Include the following lines into your card to throw UNCORRELATED:" << std::endl << helpstring); } else { return true; } return false; } //******************************************************************************* void ParamPull::Reconfigure() { //******************************************************************************* FitWeight *rw = FitBase::GetRW(); // Get Dial Names that are valid std::vector namevec = rw->GetDialNames(); std::vector valuevec = rw->GetDialValues(); // Set Bin Values from RW for (UInt_t i = 0; i < namevec.size(); i++) { // Loop over bins and check name matches std::string syst = namevec.at(i); double systval = valuevec.at(i); std::vector allsyst = GeneralUtils::ParseToStr(syst, ","); // Proper Reconf using RW for (int j = 0; j < fMCHist->GetNbinsX(); j++) { // Search for the name of this bin in the corrent dial std::string binname = std::string(fMCHist->GetXaxis()->GetBinLabel(j + 1)); // Check Full Name if (!syst.compare(binname.c_str())) { fMCHist->SetBinContent(j + 1, systval); break; } std::vector splitbinname = GeneralUtils::ParseToStr(binname, ","); for (size_t l = 0; l < splitbinname.size(); l++) { std::string singlebinname = splitbinname[l]; for (size_t k = 0; k < allsyst.size(); k++) { if (!allsyst[k].compare(singlebinname.c_str())) { fMCHist->SetBinContent(j + 1, systval); } } } } } return; }; //******************************************************************************* void ParamPull::ResetToy(void) { //******************************************************************************* if (fDataHist) delete fDataHist; NUIS_LOG(DEB, "Resetting toy"); NUIS_LOG(DEB, fDataTrue); fDataHist = (TH1D *)fDataTrue->Clone(); NUIS_LOG(DEB, "Setting name"); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + " data" + fPlotTitles).c_str()); } //******************************************************************************* void ParamPull::SetFakeData(std::string fakeinput) { //******************************************************************************* // Set from MC Setting if (!fakeinput.compare("MC")) { // Copy MC into data if (fDataHist) delete fDataHist; fDataHist = (TH1D *)fMCHist->Clone(); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + " fakedata" + fPlotTitles).c_str()); // Copy original data errors for (int i = 0; i < fDataOrig->GetNbinsX(); i++) { fDataHist->SetBinError(i + 1, fDataOrig->GetBinError(i + 1)); } // Make True Toy Central Value Hist fDataTrue = (TH1D *)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_truedata").c_str(), (fName + " truedata" + fPlotTitles).c_str()); } else { NUIS_ERR(FTL, "Trying to set fake data for ParamPulls not from MC!"); NUIS_ABORT("Not currently implemented.."); } } //******************************************************************************* void ParamPull::RemoveFakeData() { //******************************************************************************* delete fDataHist; fDataHist = (TH1D *)fDataOrig->Clone(); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + " data" + fPlotTitles).c_str()); fDataTrue = (TH1D *)fDataHist->Clone(); fDataTrue->SetNameTitle((fName + "_truedata").c_str(), (fName + " truedata" + fPlotTitles).c_str()); } //******************************************************************************* double ParamPull::GetLikelihood() { //******************************************************************************* double like = 0.0; switch (fCalcType) { // Gaussian Calculation with correlations case kGausPull: like = StatUtils::GetChi2FromCov(fDataHist, fMCHist, fInvCovar, NULL); like *= 1E-76; break; // Default says this has no pull case kNoThrow: default: like = 0.0; break; } NUIS_LOG(DEB, "Likelihood = " << like << " " << fCalcType); return like; }; //******************************************************************************* int ParamPull::GetNDOF() { //******************************************************************************* int ndof = 0; if (fCalcType != kNoThrow) { ndof = fDataHist->GetNbinsX(); } return ndof; }; //******************************************************************************* void ParamPull::ThrowCovariance() { //******************************************************************************* // Reset toy for throw ResetToy(); NUIS_LOG(FIT, "Creating new toy dataset"); // Generate random Gaussian throws std::vector randthrows; for (int i = 0; i < fDataHist->GetNbinsX(); i++) { double randtemp = 0.0; switch (fThrowType) { // Gaussian Throws case kGausThrow: randtemp = gRandom->Gaus(0.0, 1.0); break; // Uniform Throws case kFlatThrow: randtemp = gRandom->Uniform(0.0, 1.0); if (fLimitHist) { randtemp = fLimitHist->GetBinContent(i + 1) + fLimitHist->GetBinError(i + 1) * (randtemp * 2 - 1); } break; // No Throws (DEFAULT) default: break; } randthrows.push_back(randtemp); } // Create Bin Modifications double totalres = 0.0; for (int i = 0; i < fDataHist->GetNbinsX(); i++) { // Calc Bin Mod double binmod = 0.0; if (fThrowType == kGausThrow) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { binmod += (*fDecomp)(j, i) * randthrows.at(j); } } else if (fThrowType == kFlatThrow) { binmod = randthrows.at(i) - fDataHist->GetBinContent(i + 1); } // Add up fraction dif totalres += binmod; // Add to current data fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) + binmod); } // Rename fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + " toydata" + fPlotTitles).c_str()); // Check Limits if (fLimitHist) { for (int i = 0; i < fLimitHist->GetNbinsX(); i++) { if (fLimitHist->GetBinError(i + 1) == 0.0) continue; if (fDataHist->GetBinContent(i + 1) > fLimitHist->GetBinContent(i + 1) + fLimitHist->GetBinError(i + 1) || fDataHist->GetBinContent(i + 1) < fLimitHist->GetBinContent(i + 1) - fLimitHist->GetBinError(i + 1)) { NUIS_LOG(FIT, "Threw outside allowed region, rethrowing..."); ThrowCovariance(); } } } }; //******************************************************************************* TH2D ParamPull::GetCovar() { //******************************************************************************* TH2D tempCov = TH2D(*fInvCovar); for (int i = 0; i < tempCov.GetNbinsX(); i++) { tempCov.GetXaxis()->SetBinLabel(i + 1, fDataHist->GetXaxis()->GetBinLabel(i + 1)); tempCov.GetYaxis()->SetBinLabel(i + 1, fDataHist->GetXaxis()->GetBinLabel(i + 1)); } tempCov.SetNameTitle((fName + "_INVCOV").c_str(), (fName + " InvertedCovariance;Dials;Dials").c_str()); return tempCov; } //******************************************************************************* TH2D ParamPull::GetFullCovar() { //******************************************************************************* TH2D tempCov = TH2D(*fCovar); for (int i = 0; i < tempCov.GetNbinsX(); i++) { tempCov.GetXaxis()->SetBinLabel(i + 1, fDataHist->GetXaxis()->GetBinLabel(i + 1)); tempCov.GetYaxis()->SetBinLabel(i + 1, fDataHist->GetXaxis()->GetBinLabel(i + 1)); } tempCov.SetNameTitle((fName + "_COV").c_str(), (fName + " Covariance;Dials;Dials").c_str()); return tempCov; } //******************************************************************************* TH2D ParamPull::GetDecompCovar() { //******************************************************************************* TH2D tempCov = TH2D(*fDecomp); for (int i = 0; i < tempCov.GetNbinsX(); i++) { tempCov.GetXaxis()->SetBinLabel(i + 1, fDataHist->GetXaxis()->GetBinLabel(i + 1)); tempCov.GetYaxis()->SetBinLabel(i + 1, fDataHist->GetXaxis()->GetBinLabel(i + 1)); } tempCov.SetNameTitle((fName + "_DEC").c_str(), (fName + " Decomposition;Dials;Dials").c_str()); return tempCov; } //******************************************************************************* void ParamPull::Write(std::string writeoptt) { //******************************************************************************* fDataHist->Write(); fMCHist->Write(); if (fLimitHist) { fLimitHist->Write(); } GetCovar().Write(); GetFullCovar().Write(); GetDecompCovar().Write(); return; }; void ParamPull::CheckHist(TH1D *hist) { if (!hist) { NUIS_ERR(FTL, "Can't find TH1D hist fit_dials in " << fName); NUIS_ERR(FTL, "File Entries:"); TFile *temp = new TFile(fInput.c_str(), "open"); temp->ls(); throw; } } diff --git a/src/FitBase/ParamPull.h b/src/FitBase/ParamPull.h index e62acb5..aaf3866 100644 --- a/src/FitBase/ParamPull.h +++ b/src/FitBase/ParamPull.h @@ -1,195 +1,195 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef PARAM_PULL_H_SEEN #define PARAM_PULL_H_SEEN /*! * \addtogroup FitBase * @{ */ #include #include #include #include #include #include #include #include // ROOT includes #include #include #include #include #include #include #include #include "TRandom3.h" // Fit Includes #include "PlotUtils.h" #include "StatUtils.h" #include "FitWeight.h" #include "FitLogger.h" #include "EventManager.h" #include "TVector.h" using namespace std; //! Enums to allow Non Guassian Pulls in Future enum FitPullTypes { kUnknownPull = -1, kNoPull = 0, kGausPull = 1 }; enum FitThrowTypes { kUnknownThrow = -1, kNoThrow = 0, kGausThrow = 1, kFlatThrow = 2 }; //! Used to produce gaussian penalty terms in the fit. class ParamPull { public: //! Default Constructor ParamPull(std::string name, std::string inputfile, std::string type, std::string dials=""); //! Default destructor virtual ~ParamPull(void) {}; // Set dial types (DEFAULT,ABS,FRAC) void SetType(std::string type); // Setup Histogram inputs (from previous fit file, or ROOT file) void SetupHistograms(std::string input); // Read a previous NUISANCE file void ReadFitFile(std::string input); // Read a ROOT file with any histograms in void ReadRootFile(std::string input); // Read Text file void ReadVectFile(std::string input); // Read a single dial central value and error void ReadDialInput(std::string input); //! Reconfigure function reads in current RW engine dials and sets their value to MC void Reconfigure(void); //! Get likelihood given the current values double GetLikelihood(void); //! Get NDOF if used in likelihoods int GetNDOF(void); // Get Covariance Matrices as plots TH2D GetCovar(void); TH2D GetFullCovar(void); TH2D GetDecompCovar(void); // Get Covariance Matrices inline TMatrixDSym GetCovarMatrix (void) const { return *fInvCovar; }; inline TMatrixDSym GetFullCovarMatrix (void) const { return *fCovar; }; inline TMatrixDSym GetDecompCovarMatrix (void) const { return *fDecomp; }; //! Save the histograms void Write(std::string writeopt=""); //! Throw the dial values using the current covariance. Useful for parameter throws. void ThrowCovariance(void); //! Compare dials to RW bool CheckDialsValid(void); //! Reset toy data back to original data void ResetToy(void); //! Read fake data from MC void SetFakeData(std::string fakeinput); //! Reset fake data back to original data (before fake data or throws) void RemoveFakeData(); // Get Functions inline std::string GetName (void) const { return fName; }; inline std::string GetInput (void) const { return fInput; }; inline std::string GetType (void) const { return fType; }; inline std::string GetFileType (void) const { return fFileType; }; inline std::string GetDialOptions (void) const { return fDialOptions; }; std::map GetAllDials(); inline TH1D GetDataHist (void) const { return *fDataHist; }; inline TH1D GetDataTrue (void) const { return *fDataTrue; }; inline TH1D GetDataOrig (void) const { return *fDataOrig; }; inline TH1D GetMCHist (void) const { return *fMCHist; }; inline TH1D GetMaxHist (void) const { return *fMaxHist; }; inline TH1D GetMinHist (void) const { return *fMinHist; }; inline TH1I GetDialTypes (void) const { return *fTypeHist; }; inline TH1D GetLimitHist (void) const { return *fLimitHist; }; private: void CheckHist(TH1D*); TH1D RemoveBinsNotInString(TH1D hist, std::string mystr); TH1I RemoveBinsNotInString(TH1I hist, std::string mystr); std::string fName; //!< Pull Name std::string fInput; //!< Pull input string std::string fType; //!< Pull options type std::string fFileType; //!< Pull input file types std::string fPlotTitles; //! Axis format std::string fDialOptions; //!< Dial handling options std::string fDialSelection; //!< Dial Selection TH1D* fMCHist; //!< Current MC Histogram TH1D* fDataHist; //!< Current data Histogram TH1D* fDataTrue; //!< True Data (before histogram throws) TH1D* fDataOrig; //!< Orig Data (without toys or fake data) TH1D* fMaxHist; //!< Maximum limit on MC/Data TH1D* fMinHist; //!< Maximum limit on MC/Data TH1I* fTypeHist; //!< Dial Types int fCalcType; //!< Method to calculate likelihood int fThrowType; //!< Method to calculate throws TMatrixDSym* fCovar; //!< Covariance TMatrixDSym* fInvCovar; //!< Inverted Covariance TMatrixDSym* fDecomp; //!< Decomposition TH1D* fLimitHist; }; // Class TypeDefs typedef std::list::const_iterator PullListConstIter; typedef std::list::iterator PullListIter; typedef std::vector::const_iterator PullVectConstIter; typedef std::vector::iterator PullVectIter; /*! @} */ #endif diff --git a/src/FitBase/SampleSettings.cxx b/src/FitBase/SampleSettings.cxx index e69bae0..a2793ca 100644 --- a/src/FitBase/SampleSettings.cxx +++ b/src/FitBase/SampleSettings.cxx @@ -1,233 +1,245 @@ #include "SampleSettings.h" SampleSettings::SampleSettings() { }; SampleSettings::SampleSettings(nuiskey key) { fKeyValues = key; if (!key.Has("type")) key.Set("type", "DEFAULT"); } std::string SampleSettings::GetName() { return GetS("name"); } void SampleSettings::SetS(std::string name, std::string val) { fKeyValues.SetS(name, val); }; bool SampleSettings::Found(std::string name, std::string substring) { std::string compstring = fKeyValues.GetS(name); return compstring.find(substring) != std::string::npos; } void SampleSettings::SetXTitle(std::string name) { SetDefault("xtitle", name); }; void SampleSettings::SetYTitle(std::string name) { SetDefault("ytitle", name); }; void SampleSettings::SetZTitle(std::string name) { SetDefault("ztitle", name); }; void SampleSettings::SetNormError(double norm) { SetDefault("norm_error", GeneralUtils::DblToStr(norm)); }; double SampleSettings::GetNormError() { return GetD("norm_error"); }; std::string SampleSettings::GetCovarInput() { return GetS("covar"); } void SampleSettings::SetAllowedTypes(std::string allowed, std::string defaulttype) { SetDefault("default_types", allowed); SetDefault("allowed_types", defaulttype); }; void SampleSettings::SetEnuRangeFromFlux(TH1D* fluxhist) { double enu_min = fluxhist->GetXaxis()->GetXmin(); double enu_max = fluxhist->GetXaxis()->GetXmax(); SetEnuRange(enu_min, enu_max); }; void SampleSettings::SetEnuRange(double min, double max) { SetDefault("enu_min", min); SetDefault("enu_max", max); }; void SampleSettings::Set(std::string name, double d) { SetDefault(name, d); } void SampleSettings::Set(std::string name, int i) { SetDefault(name, i); } void SampleSettings::Set(std::string name, std::string s) { SetDefault(name, s); } void SampleSettings::DefineAllowedTargets(std::string targ) { // fAllowedTargets = TargetUtils::ParseTargetsToIntVect(targ); }; void SampleSettings::FoundFill(std::string name, std::string substring, bool& cont, bool def) { std::string compstring = fKeyValues.GetS(name); if (compstring.find(substring) != std::string::npos) { cont = def; } else { cont = !def; } }; void SampleSettings::SetTitle(std::string val) { SetDefault("title", val); }; void SampleSettings::SetDataInput(std::string val) { SetDefault("data", val); }; std::string SampleSettings::GetMapInput() { return GetS("map"); } void SampleSettings::SetMapInput(std::string val) { SetDefault("map", val); } void SampleSettings::SetErrorInput(std::string val) { SetDefault("error", val); }; void SampleSettings::SetCovarInput(std::string val) { SetDefault("covar", val); }; void SampleSettings::SetShapeCovarInput(std::string val) { SetDefault("shapecovar", val); }; void SampleSettings::SetDefault(std::string name, std::string val) { if (!fKeyValues.Has(name)) fKeyValues.Set(name, val); }; void SampleSettings::SetDefault(std::string name, double val ) { if (!fKeyValues.Has(name)) fKeyValues.Set(name, val); }; void SampleSettings::SetHasExtraHistograms(bool opt) { fHasExtraHistograms = opt; }; void SampleSettings::DefineAllowedSpecies(std::string species) { fAllowedTargets = BeamUtils::ParseSpeciesToIntVect(species); }; std::string SampleSettings::Title() { return GetS("title"); } std::string SampleSettings::GetDataInput() { return GetS("data"); }; std::string SampleSettings::GetErrorInput() { return GetS("error"); }; +std::string SampleSettings::GetXTitle() { + return GetS("xtitle"); +} + +std::string SampleSettings::GetYTitle() { + return GetS("ytitle"); +} + +std::string SampleSettings::GetZTitle() { + return GetS("ztitle"); +} + std::string SampleSettings::PlotTitles() { std::string returnstring = ";"; - if (!(GetS("xtitle").empty())) returnstring += GetS("xtitle")+";"; - if (!(GetS("ytitle").empty())) returnstring += GetS("ytitle")+";"; - if (!(GetS("ztitle").empty())) returnstring += GetS("ztitle")+";"; - // Cut out the last ; symbol - returnstring = returnstring.substr(0, returnstring.find_last_of(";")); + if (!(GetS("xtitle").empty())) returnstring += GetS("xtitle"); + returnstring+=";"; + if (!(GetS("ytitle").empty())) returnstring += GetS("ytitle"); + returnstring+=";"; + if (!(GetS("ztitle").empty())) returnstring += GetS("ztitle"); return returnstring; }; std::string SampleSettings::GetFullTitles() { return Title() + PlotTitles(); } int SampleSettings::GetI(std::string name) { return fKeyValues.GetI(name); } bool SampleSettings::GetB(std::string name){ return fKeyValues.GetB(name); } double SampleSettings::GetD(std::string name) { return fKeyValues.GetD(name); } std::string SampleSettings::GetS(std::string name) { return fKeyValues.GetS(name); } void SampleSettings::SetSuggestedFlux(std::string str) { SetS("suggested_flux", str); } void SampleSettings::SetDescription(std::string str) { SetS("description", str); } void SampleSettings::Write(std::string name) { if (name.empty()) name = this->GetS("name") + "_settings"; // Make a new canvas TCanvas* c1 = new TCanvas( name.c_str(), name.c_str(), 800, 600 ); c1->cd(); TPaveText *pttitle = new TPaveText(0.01, 0.90, 0.99, 0.99, "NDC"); pttitle->AddText( name.c_str() ); pttitle->Draw(); TPaveText *pt = new TPaveText(0.01, 0.01, 0.99, 0.89, "NDC"); pt->Draw("same"); std::vector keys = fKeyValues.GetAllKeys(); for (size_t i = 0; i < keys.size(); i++) { std::string keyval = fKeyValues.GetS(keys[i]); std::vector lines = GeneralUtils::ParseToStr(keyval, "\n"); if (lines.size() == 1) { pt->AddText( ("#bullet #bf{" + keys[i] + "} : " + fKeyValues.GetS(keys[i])).c_str() ); } else { pt->AddText( ("#bullet #bf{" + keys[i] + "} : ").c_str() ); for (size_t j = 0; j < lines.size(); j++) { pt->AddText((" |--> " + lines[j]).c_str() ); } } } pt->SetTextAlign(11); //pt->SetTextSize(14); c1->Modified(); c1->Write(); delete c1; delete pt; delete pttitle; } void SampleSettings::SetOnlyMC(bool state) { SetDefault("onlymc", state); } diff --git a/src/FitBase/SampleSettings.h b/src/FitBase/SampleSettings.h index 1f6ee44..58ebe59 100644 --- a/src/FitBase/SampleSettings.h +++ b/src/FitBase/SampleSettings.h @@ -1,75 +1,78 @@ #ifndef SAMPLESETTINGS_H #define SAMPLESETTINGS_H #include "NuisConfig.h" #include "NuisKey.h" #include "TH1D.h" #include "BeamUtils.h" #include "TPaveText.h" #include "TCanvas.h" class SampleSettings { public: SampleSettings(); SampleSettings(nuiskey key); inline std::string Name(){return GetName();}; std::string GetName(); void SetS(std::string name, std::string val); void SetXTitle(std::string name); void SetYTitle(std::string name); void SetZTitle(std::string name); + std::string GetXTitle(); + std::string GetYTitle(); + std::string GetZTitle(); void SetNormError(double norm); double GetNormError(); void SetAllowedTypes(std::string allowed, std::string defaulttype="FIX"); void SetEnuRangeFromFlux(TH1D* fluxhist); void SetEnuRange(double min, double max); std::string Title(); void DefineAllowedTargets(std::string targ); void FoundFill(std::string name, std::string substring, bool& cont, bool def); // void FoundFill(std::string name, std::string substr, double& val, double ) bool Found(std::string name, std::string substring); void SetTitle(std::string val); void SetDataInput(std::string val); void SetErrorInput(std::string val); std::string GetErrorInput(); std::string GetMapInput(); void SetMapInput(std::string val); void SetCovarInput(std::string val); void SetShapeCovarInput(std::string val); void SetDefault(std::string name, std::string val); void SetDefault(std::string name, double val); void SetHasExtraHistograms(bool opt = true); void DefineAllowedSpecies(std::string species); void SetSuggestedFlux(std::string str); void SetDescription(std::string str); void Write(std::string name=""); std::string GetFullTitles(); bool Has(std::string name){return fKeyValues.Has(name);}; std::string GetDataInput(); std::string PlotTitles(); std::string GetS(std::string name); int GetI(std::string name); double GetD(std::string name); std::string GetCovarInput(); void SetOnlyMC(bool state=true); bool GetB(std::string name); void Set(std::string name, int i); void Set(std::string name, std::string s); void Set(std::string name, double d); std::vector fAllowedTargets; std::vector fAllowedSpecies; nuiskey fKeyValues; bool fHasExtraHistograms; }; #endif diff --git a/src/FitBase/StackBase.cxx b/src/FitBase/StackBase.cxx index 11cac25..c980821 100644 --- a/src/FitBase/StackBase.cxx +++ b/src/FitBase/StackBase.cxx @@ -1,251 +1,256 @@ #include "StackBase.h" void StackBase::AddMode(std::string name, std::string title, int linecolor, int linewidth, int fillstyle) { // int ncur = fAllLabels.size(); fAllLabels.push_back(name); fAllTitles.push_back(title); std::vector temp; temp.push_back(linecolor); temp.push_back(linewidth); temp.push_back(fillstyle); fAllStyles.push_back(temp); } void StackBase::FluxUnfold(TH1D *flux, TH1D *events, double scalefactor, int nevents) { for (size_t i = 0; i < fAllLabels.size(); i++) { if (fNDim == 1) { PlotUtils::FluxUnfoldedScaling((TH1D *)fAllHists[i], flux, events, scalefactor, nevents); } else if (fNDim == 2) { PlotUtils::FluxUnfoldedScaling((TH2D *)fAllHists[i], flux, events, scalefactor); } } } void StackBase::AddMode(int index, std::string name, std::string title, int linecolor, int linewidth, int fillstyle) { while (fAllLabels.size() <= (UInt_t)index) { fAllLabels.push_back(""); fAllTitles.push_back(""); fAllStyles.push_back(std::vector(1, 1)); } fAllLabels[index] = (name); fAllTitles[index] = (title); std::vector temp; temp.push_back(linecolor); temp.push_back(linewidth); temp.push_back(fillstyle); fAllStyles[index] = temp; } bool StackBase::IncludeInStack(TH1 *hist) { if (!FitPar::Config().GetParB("includeemptystackhists") and hist->Integral() == 0.0) return false; return true; } bool StackBase::IncludeInStack(int index) { return true; } void StackBase::SetupStack(TH1 *hist) { fTemplate = (TH1 *)hist->Clone(fName.c_str()); fTemplate->Reset(); // Determine template dim fNDim = fTemplate->GetDimension(); + // Sort out titles + fXTitle = hist->GetXaxis()->GetTitle(); + fYTitle = hist->GetYaxis()->GetTitle(); + fZTitle = hist->GetZaxis()->GetTitle(); + for (size_t i = 0; i < fAllLabels.size(); i++) { fAllHists.push_back( (TH1 *)fTemplate->Clone((fName + "_" + fAllLabels[i]).c_str())); } }; void StackBase::Scale(double sf, std::string opt) { for (size_t i = 0; i < fAllLabels.size(); i++) { // std::cout << "Scaling Stack Hist " << i << " by " << sf << std::endl; fAllHists[i]->Scale(sf, opt.c_str()); } }; void StackBase::Reset() { for (size_t i = 0; i < fAllLabels.size(); i++) { fAllHists[i]->Reset(); } }; void StackBase::FillStack(int index, double x, double y, double z, double weight) { if (index < 0 or (UInt_t) index >= fAllLabels.size()) { NUIS_ERR(WRN, "Returning Stack Fill Because Range = " << index << " " << fAllLabels.size()); return; } if (fNDim == 1) fAllHists[index]->Fill(x, y); else if (fNDim == 2) { // std::cout << "Filling 2D Stack " << index << " " << x << " " << y << " " // << z << std::endl; ((TH2 *)fAllHists[index])->Fill(x, y, z); } else if (fNDim == 3) ((TH3 *)fAllHists[index])->Fill(x, y, z, weight); } void StackBase::SetBinContentStack(int index, int binx, int biny, int binz, double content) { if (index < 0 or (UInt_t) index >= fAllLabels.size()) { NUIS_ERR(WRN, "Returning Stack Fill Because Range = " << index << " " << fAllLabels.size()); return; } if (fNDim == 1) { fAllHists[index]->SetBinContent(binx, content); } else if (fNDim == 2) { ((TH2 *)fAllHists[index])->SetBinContent(binx, biny, content); } else if (fNDim == 3) { ((TH3 *)fAllHists[index])->SetBinContent(binx, biny, binz, content); } } void StackBase::SetBinErrorStack(int index, int binx, int biny, int binz, double error) { if (index < 0 or (UInt_t) index >= fAllLabels.size()) { NUIS_ERR(WRN, "Returning Stack Fill Because Range = " << index << " " << fAllLabels.size()); return; } if (fNDim == 1) { fAllHists[index]->SetBinError(binx, error); } else if (fNDim == 2) { ((TH2 *)fAllHists[index])->SetBinError(binx, biny, error); } else if (fNDim == 3) { ((TH3 *)fAllHists[index])->SetBinError(binx, biny, binz, error); } } void StackBase::Write() { THStack *st = new THStack(); // Loop and add all histograms bool saveseparate = FitPar::Config().GetParB("WriteSeparateStacks"); for (size_t i = 0; i < fAllLabels.size(); i++) { if (!IncludeInStack(fAllHists[i])) continue; if (!IncludeInStack(i)) continue; fAllHists[i]->SetTitle(fAllTitles[i].c_str()); fAllHists[i]->GetXaxis()->SetTitle(fXTitle.c_str()); fAllHists[i]->GetYaxis()->SetTitle(fYTitle.c_str()); fAllHists[i]->GetZaxis()->SetTitle(fZTitle.c_str()); fAllHists[i]->SetLineColor(fAllStyles[i][0]); fAllHists[i]->SetLineWidth(fAllStyles[i][1]); fAllHists[i]->SetFillStyle(fAllStyles[i][2]); fAllHists[i]->SetFillColor(fAllStyles[i][0]); if (saveseparate) fAllHists[i]->Write(); st->Add(fAllHists[i]); } st->SetTitle((fTitle+";"+fXTitle+";"+fYTitle+";"+fZTitle).c_str()); st->SetName(fName.c_str()); st->Write(); delete st; }; void StackBase::Multiply(TH1 *hist) { for (size_t i = 0; i < fAllLabels.size(); i++) { fAllHists[i]->Multiply(hist); } } void StackBase::Divide(TH1 *hist) { for (size_t i = 0; i < fAllLabels.size(); i++) { fAllHists[i]->Divide(hist); } } void StackBase::Add(TH1 *hist, double scale) { for (size_t i = 0; i < fAllLabels.size(); i++) { fAllHists[i]->Add(hist, scale); } } void StackBase::Add(StackBase *hist, double scale) { if (hist->GetType() != fType) { NUIS_ERR(WRN, "Trying to add two StackBases of different types!"); NUIS_ERR(WRN, fType << " + " << hist->GetType() << " = Undefined."); NUIS_ERR(WRN, "Doing nothing..."); return; } for (size_t i = 0; i < fAllLabels.size(); i++) { fAllHists[i]->Add(hist->GetHist(i)); } } TH1 *StackBase::GetHist(int entry) { return fAllHists[entry]; } TH1 *StackBase::GetHist(std::string label) { TH1 *hist = NULL; std::vector splitlabels = GeneralUtils::ParseToStr(label, "+"); for (size_t j = 0; j < splitlabels.size(); j++) { std::string newlabel = splitlabels[j]; for (size_t i = 0; i < fAllLabels.size(); i++) { if (newlabel == fAllLabels[i]) { if (!hist) hist = (TH1 *)fAllHists[i]->Clone(); else hist->Add(fAllHists[i]); } } } return hist; } THStack StackBase::GetStack() { THStack st = THStack(); for (size_t i = 0; i < fAllLabels.size(); i++) { st.Add(fAllHists[i]); } return st; } void StackBase::AddNewHist(std::string name, TH1 *hist) { AddMode(fAllLabels.size(), name, hist->GetTitle(), hist->GetLineColor()); fAllHists.push_back((TH1 *)hist->Clone()); } void StackBase::AddToCategory(std::string name, TH1 *hist) { for (size_t i = 0; i < fAllLabels.size(); i++) { if (name == fAllLabels[i]) { fAllHists[i]->Add(hist); break; } } } void StackBase::AddToCategory(int index, TH1 *hist) { fAllHists[index]->Add(hist); } diff --git a/src/FitBase/TemplateMeas1D.cxx b/src/FitBase/TemplateMeas1D.cxx index 8ef1892..8a5c0e4 100644 --- a/src/FitBase/TemplateMeas1D.cxx +++ b/src/FitBase/TemplateMeas1D.cxx @@ -1,221 +1,221 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "TemplateMeas1D.h" //******************************************************************** TemplateMeas1D::TemplateMeas1D(std::string name, std::string inputfile, FitWeight *rw, std::string type) { //******************************************************************** // 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% // Setup allowed/default types // These give the starting possible options that can be specified when making // the class. // Different discrete fields should be separated by '/' and conflicting // options // should be separated 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 separate 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_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 = ((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"); } else { 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. fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar,true); // 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) { // 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); // Create Channel Plot // fMCHist_ExtraQ2Plot_PDG = NULL; } }; //******************************************************************** /// @details Extract q2qe(fXVar) from the 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) { int PID = abs((event->PartInfo(j))->fPID); if (!event->PartInfo(j)->fIsAlive) 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; } // Set X Variables fXVar = q2qe; return; }; //******************************************************************** bool TemplateMeas1D::isSignal(FitEvent *event) { //******************************************************************** // 2 Different Signal Definitions // 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() { //******************************************************************** 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) { //******************************************************************** 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(); } */ } //******************************************************************** void TemplateMeas1D::ResetAll() { //******************************************************************** Measurement1D::ResetAll(); // if (ccqelike) // PlotUtils::ResetNeutModeArray((TH1**)fMCHist_CCQELIKE); } //******************************************************************** void TemplateMeas1D::ScaleEvents() { //******************************************************************** Measurement1D::ScaleEvents(); // if (ccqelike) // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, // fScaleFactor,"width"); } //******************************************************************** void TemplateMeas1D::ApplyNormScale(double norm) { //******************************************************************** Measurement1D::ApplyNormScale(norm); // if (ccqelike) // PlotUtils::ScaleNeutModeArray((TH1**)fMCHist_CCQELIKE, 1.0/norm, ""); } diff --git a/src/FitBase/TemplateMeas1D.h b/src/FitBase/TemplateMeas1D.h index fb83404..9124fcc 100644 --- a/src/FitBase/TemplateMeas1D.h +++ b/src/FitBase/TemplateMeas1D.h @@ -1,69 +1,69 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef TEMPLATEMEAS1D_H_SEEN #define TEMPLATEMEAS1D_H_SEEN #include "Measurement1D.h" enum TemplateMeas1D_AnalysisTypes{ kTemplateMeas1D_CC0pi_Tmu = 0, kTemplateMeas1D_CCQE_Q2 = 1 }; //******************************************************************** class TemplateMeas1D : public Measurement1D { //******************************************************************** public: /// REQUIRED by all ssample classes TemplateMeas1D(std::string name, std::string inputfile, FitWeight *rw, std::string type); /// Destructor virtual ~TemplateMeas1D() {}; /// REQUIRED by all sample classes void FillEventVariables(FitEvent *event); /// REQUIRED by all sample classes bool isSignal(FitEvent *event); /// Optional void FillHistograms(); void Write(std::string drawOpt); void ScaleEvents(); void ApplyNormScale(double norm); void ResetAll(); private: /// OPTIONAL TH1D* fMCHist_ExtraQ2Plot_PDG[61]; TH1D* fMCHist_ExtraQ2Plot; double q2qe; ///. ################################################################################ set(IMPLFILES GGM_CC1ppip_Evt_1DQ2_nu.cxx GGM_CC1ppip_XSec_1DEnu_nu.cxx ) set(HEADERFILES GGM_CC1ppip_Evt_1DQ2_nu.h GGM_CC1ppip_XSec_1DEnu_nu.h ) set(LIBNAME expGGM) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/GGM) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx index 82329a0..4e08737 100644 --- a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx +++ b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GGM_CC1ppip_Evt_1DQ2_nu.h" //******************************************************************** GGM_CC1ppip_Evt_1DQ2_nu::GGM_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "GGM_CC1ppip_Evt_1DQ2_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC1#pi} (GeV^{2})"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Number of events"); // fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.SetEnuRange(1.0, 10.0); fSettings.DefineAllowedTargets("D,H"); fIsDiag = true; fIsRawEvents = true; // plot information fSettings.SetTitle("GGM_CC1ppip_Evt_1DQ2_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "GGM/CC1pip_on_p/GGM_CC1ppip_Q2_events_bin_edit.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents+0.)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetPoissonErrors(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); } 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_Evt_1DQ2_nu.h b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.h index d2f883e..7e2ff74 100644 --- a/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.h +++ b/src/GGM/GGM_CC1ppip_Evt_1DQ2_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GGM_CC1PPIP_EVT_1DQ2_NU_H_SEEN #define GGM_CC1PPIP_EVT_1DQ2_NU_H_SEEN #include "Measurement1D.h" class GGM_CC1ppip_Evt_1DQ2_nu : public Measurement1D { public: GGM_CC1ppip_Evt_1DQ2_nu(nuiskey samplekey); virtual ~GGM_CC1ppip_Evt_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx index c961121..886a0b6 100644 --- a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx +++ b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GGM_CC1ppip_XSec_1DEnu_nu.h" //******************************************************************** GGM_CC1ppip_XSec_1DEnu_nu::GGM_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "GGM_CC1ppip_XSec_1DEnu_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/proton)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG", "FIX/DIAG"); fSettings.SetEnuRange(1.0, 10.0); fSettings.DefineAllowedTargets("D,H"); // plot information fSettings.SetTitle("GGM_CC1ppip_XSec_1DEnu_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "GGM/CC1pip_on_p/Gargamelle78-numu-p-to-mu-p-piplus-lowW_EDGES.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor for shape fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(2./1.); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); } 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/GGM/GGM_CC1ppip_XSec_1DEnu_nu.h b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.h index b02e431..81998b7 100644 --- a/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.h +++ b/src/GGM/GGM_CC1ppip_XSec_1DEnu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GGM_CC1PPIP_XSEC_1DENU_NU_H_SEEN #define GGM_CC1PPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class GGM_CC1ppip_XSec_1DEnu_nu : public Measurement1D { public: GGM_CC1ppip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~GGM_CC1ppip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/InputHandler/BaseFitEvt.cxx b/src/InputHandler/BaseFitEvt.cxx index 8b684d9..9af163c 100644 --- a/src/InputHandler/BaseFitEvt.cxx +++ b/src/InputHandler/BaseFitEvt.cxx @@ -1,263 +1,263 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BaseFitEvt.h" #include "FitParticle.h" #include "GIBUUInputHandler.h" BaseFitEvt::BaseFitEvt() { Mode = 0; probe_E = 0xdeadbeef; probe_pdg = 0; Weight = 1.0; InputWeight = 1.0; RWWeight = 1.0; CustomWeight = 1.0; SavedRWWeight = 1.0; for (int i = 0; i < 6; ++i) { CustomWeightArray[i] = 1.0; } fSplineCoeff = NULL; fSplineRead = NULL; fGenInfo = NULL; fType = 9999; #ifdef __NEUT_ENABLED__ fNeutVect = NULL; #endif #ifdef __NUWRO_ENABLED__ #ifndef __USE_NUWRO_SRW_EVENTS__ fNuwroEvent = NULL; #endif #endif #ifdef __GENIE_ENABLED__ genie_event = NULL; genie_record = NULL; #endif #ifdef __NUANCE_ENABLED__ nuance_event = NULL; #endif #ifdef __GiBUU_ENABLED__ GiRead = NULL; #endif }; BaseFitEvt::~BaseFitEvt() { #ifdef __NEUT_ENABLED__ if (fNeutVect) delete fNeutVect; #endif #ifdef __NUWRO_ENABLED__ #ifndef __USE_NUWRO_SRW_EVENTS__ if (fNuwroEvent) delete fNuwroEvent; #endif #endif #ifdef __GENIE_ENABLED__ if (genie_event) delete genie_event; #endif #ifdef __NUANCE_ENABLED__ if (nuance_event) delete nuance_event; #endif #ifdef __GiBUU_ENABLED__ if (GiRead) delete GiRead; #endif }; BaseFitEvt::BaseFitEvt(const BaseFitEvt* obj) { Mode = obj->Mode; probe_E = obj->probe_E; probe_pdg = obj->probe_pdg; Weight = obj->Weight; InputWeight = obj->InputWeight; RWWeight = obj->RWWeight; SavedRWWeight = obj->SavedRWWeight; CustomWeight = obj->CustomWeight; for (int i = 0; i < 6; ++i) { CustomWeightArray[i] = obj->CustomWeightArray[i]; } fSplineCoeff = obj->fSplineCoeff; fSplineRead = obj->fSplineRead; fGenInfo = obj->fGenInfo; fType = obj->fType; #ifdef __NEUT_ENABLED__ fNeutVect = obj->fNeutVect; #endif #ifdef __NUWRO_ENABLED__ fNuwroEvent = obj->fNuwroEvent; #endif #ifdef __GENIE_ENABLED__ genie_event = obj->genie_event; #endif #ifdef __NUANCE_ENABLED__ nuance_event = obj->nuance_event; #endif #ifdef __GiBUU_ENABLED__ GiRead = obj->GiRead; #endif }; BaseFitEvt::BaseFitEvt(BaseFitEvt const& other) { Mode = other.Mode; probe_E = other.probe_E; probe_pdg = other.probe_pdg; Weight = other.Weight; InputWeight = other.InputWeight; RWWeight = other.RWWeight; CustomWeight = other.CustomWeight; SavedRWWeight = other.SavedRWWeight; for (int i = 0; i < 6; ++i) { CustomWeightArray[i] = other.CustomWeightArray[i]; } fSplineCoeff = other.fSplineCoeff; fSplineRead = other.fSplineRead; fGenInfo = other.fGenInfo; fType = other.fType; #ifdef __NEUT_ENABLED__ fNeutVect = other.fNeutVect; #endif #ifdef __NUWRO_ENABLED__ fNuwroEvent = other.fNuwroEvent; #ifdef __USE_NUWRO_SRW_EVENTS__ fNuwroSRWEvent = other.fNuwroSRWEvent; ///< Pointer to Nuwro event fNuwroParams = other.fNuwroParams; #endif #endif #ifdef __GENIE_ENABLED__ genie_event = other.genie_event; #endif #ifdef __NUANCE_ENABLED__ nuance_event = other.nuance_event; #endif #ifdef __GiBUU_ENABLED__ GiRead = other.GiRead; #endif }; BaseFitEvt BaseFitEvt::operator=(BaseFitEvt const& other) { Mode = other.Mode; probe_E = other.probe_E; probe_pdg = other.probe_pdg; Weight = other.Weight; InputWeight = other.InputWeight; RWWeight = other.RWWeight; CustomWeight = other.CustomWeight; SavedRWWeight = other.SavedRWWeight; for (int i = 0; i < 6; ++i) { CustomWeightArray[i] = other.CustomWeightArray[i]; } fSplineCoeff = other.fSplineCoeff; fSplineRead = other.fSplineRead; fGenInfo = other.fGenInfo; fType = other.fType; #ifdef __NEUT_ENABLED__ fNeutVect = other.fNeutVect; #endif #ifdef __NUWRO_ENABLED__ fNuwroEvent = other.fNuwroEvent; #ifdef __USE_NUWRO_SRW_EVENTS__ fNuwroSRWEvent = other.fNuwroSRWEvent; ///< Pointer to Nuwro event fNuwroParams = other.fNuwroParams; #endif #endif #ifdef __GENIE_ENABLED__ genie_event = other.genie_event; #endif #ifdef __NUANCE_ENABLED__ nuance_event = other.nuance_event; #endif #ifdef __GiBUU_ENABLED__ GiRead = other.GiRead; #endif return *this; } void BaseFitEvt::ResetWeight() { InputWeight = 1.0; #ifdef __GENIE_ENABLED__ for (int i = 0; i < 6; ++i) { CustomWeightArray[i] = 1.0; } #endif } double BaseFitEvt::GetWeight() { return InputWeight * RWWeight * CustomWeight; }; #ifdef __NEUT_ENABLED__ void BaseFitEvt::SetNeutVect(NeutVect* v) { fType = kNEUT; fNeutVect = v; } #endif #ifdef __GENIE_ENABLED__ void BaseFitEvt::SetGenieEvent(NtpMCEventRecord* ntpl) { fType = kGENIE; genie_event = ntpl; } #endif #ifdef __NUANCE_ENABLED__ void BaseFitEvt::SetNuanceEvent(NuanceEvent* e) { fType = kNUANCE; nuance_event = e; } #endif void BaseFitEvt::SetInputFitEvent() { fType = kINPUTFITEVENT; } void BaseFitEvt::SetInputFitSpline() { fType = kNEWSPLINE; } void BaseFitEvt::SetInputHepMC() { fType = kHEPMC; } diff --git a/src/InputHandler/BaseFitEvt.h b/src/InputHandler/BaseFitEvt.h index 84e3d88..8e655fb 100644 --- a/src/InputHandler/BaseFitEvt.h +++ b/src/InputHandler/BaseFitEvt.h @@ -1,147 +1,147 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FITEVENTBASE_H_SEEN #define FITEVENTBASE_H_SEEN /*! * \addtogroup InputHandler * @{ */ #ifdef __NEUT_ENABLED__ #include "neutpart.h" #include "neutvect.h" #endif #ifdef __NUWRO_ENABLED__ #ifdef __USE_NUWRO_SRW_EVENTS__ #include "NuwroReWeightSimpleEvent.h" #else #include "event1.h" #endif #endif #ifdef __GENIE_ENABLED__ #ifdef GENIE_PRE_R3 #include "EVGCore/EventRecord.h" #include "GHEP/GHepRecord.h" #include "Ntuple/NtpMCEventRecord.h" #else #include "Framework/EventGen/EventRecord.h" #include "Framework/GHEP/GHepRecord.h" #include "Framework/Ntuple/NtpMCEventRecord.h" #endif using namespace genie; #endif #ifdef __NUANCE_ENABLED__ #include "NuanceEvent.h" #endif #include "StdHepEvt.h" #include "SplineReader.h" #include "InputTypes.h" #include "GeneratorInfoBase.h" /// Base Event Class used to store just the generator event pointers class BaseFitEvt { public: /// Base Constructor BaseFitEvt(void); ~BaseFitEvt(); /// Copy base fit event pointers BaseFitEvt(const BaseFitEvt* obj); BaseFitEvt(BaseFitEvt const &); BaseFitEvt operator=(BaseFitEvt const &); /// Reset weight to 1.0 void ResetWeight(); /// Return combined weight for this event double GetWeight(); /// Manually set event type inline void SetType(int type){fType = type;}; // Global Event Variables/Weights int Mode; ///< True interaction mode double probe_E; ///< True probe energy double probe_pdg; // Weighting Info double Weight; ///< Total Weight For Event double InputWeight; ///< Input Starting Weight (used for GiBUU) double RWWeight; ///< Saved RW from FitWeight double CustomWeight; ///< Extra custom weight that samples can set double SavedRWWeight; ///< Saved RW value for FitEvents double CustomWeightArray[6]; ///< For custom tuning using arrays, e.g. NOvA MINERvA WS // Spline Info Coefficients and Readers float* fSplineCoeff; ///< ND Array of Spline Coefficients SplineReader* fSplineRead; ///< Spline Interpretter // Generator Info GeneratorInfoBase* fGenInfo; ///< Generator Variable Box UInt_t fType; ///< Generator Event Type #ifdef __NEUT_ENABLED__ /// Setup Event Reading from NEUT Event void SetNeutVect(NeutVect* v); NeutVect* fNeutVect; ///< Pointer to Neut Vector #endif #ifdef __NUWRO_ENABLED__ #ifdef __USE_NUWRO_SRW_EVENTS__ SRW::SRWEvent fNuwroSRWEvent; ///< Pointer to Nuwro event params * fNuwroParams; #endif event* fNuwroEvent; ///< Pointer to Nuwro event #endif #ifdef __GENIE_ENABLED__ /// Setup Event Reading from GENIE Event void SetGenieEvent(NtpMCEventRecord* ntpl); NtpMCEventRecord* genie_event; ///< Pointer to NTuple Genie Event GHepRecord* genie_record; ///< Pointer to actually accessible Genie Record #endif #ifdef __NUANCE_ENABLED__ /// Setup Event Reading from NUANCE Event void SetNuanceEvent(NuanceEvent* e); NuanceEvent* nuance_event; ///< Pointer to Nuance reader #endif #ifdef __GiBUU_ENABLED__ GiBUUStdHepReader* GiRead; ///< Pointer to GiBUU reader #endif /// Setup Event Type to FitEvent void SetInputFitEvent(); /// Setup Event Type to FitSpline void SetInputFitSpline(); /// Setup Event Type to HepMC void SetInputHepMC(); }; /*! @} */ #endif diff --git a/src/InputHandler/CMakeLists.txt b/src/InputHandler/CMakeLists.txt index 75da29f..4a82e29 100644 --- a/src/InputHandler/CMakeLists.txt +++ b/src/InputHandler/CMakeLists.txt @@ -1,96 +1,96 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES BaseFitEvt.cxx FitParticle.cxx FitEvent.cxx GeneratorUtils.cxx StdHepEvt.cxx InputUtils.cxx NEUTInputHandler.cxx GENIEInputHandler.cxx NuWroInputHandler.cxx GIBUUInputHandler.cxx NUANCEInputHandler.cxx InputHandler.cxx NuanceEvent.cxx FitEventInputHandler.cxx SplineInputHandler.cxx GeneratorInfoBase.h HepMCTextInputHandler.cxx InputFactory.cxx SigmaQ0HistogramInputHandler.cxx HistogramInputHandler.cxx ) set(HEADERFILES BaseFitEvt.h FitParticle.h FitEvent.h GeneratorUtils.h StdHepEvt.h InputUtils.h NEUTInputHandler.h GENIEInputHandler.h NuWroInputHandler.h GIBUUInputHandler.h NUANCEInputHandler.h InputHandler.h NuanceEvent.h FitEventInputHandler.h SplineInputHandler.h GeneratorInfoBase.h InputTypes.h HepMCTextInputHandler.h InputFactory.h SigmaQ0HistogramInputHandler.h HistogramInputHandler.h ) if(USE_HEPMCNUEVT) LIST(APPEND IMPLFILES HepMCNuEvtInputHandler.cxx) endif() set(LIBNAME InputHandler) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION - "${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}") + "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() if(HEPMC_USED_EP) add_dependencies(${LIBNAME} HepMC) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/InputHandler) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/InputHandler/FitEvent.cxx b/src/InputHandler/FitEvent.cxx index fe038b5..ef3b677 100644 --- a/src/InputHandler/FitEvent.cxx +++ b/src/InputHandler/FitEvent.cxx @@ -1,500 +1,500 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret /******************************************************************************* * This file is pddrt 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 . *******************************************************************************/ #include "FitEvent.h" #include "TObjArray.h" #include FitEvent::FitEvent() { fGenInfo = NULL; kRemoveFSIParticles = true; kRemoveUndefParticles = true; AllocateParticleStack(400); }; void FitEvent::AddGeneratorInfo(GeneratorInfoBase *gen) { fGenInfo = gen; gen->AllocateParticleStack(kMaxParticles); } void FitEvent::AllocateParticleStack(int stacksize) { NUIS_LOG(DEB, "Allocating particle stack of size: " << stacksize); kMaxParticles = stacksize; fParticleList = new FitParticle *[kMaxParticles]; fParticleMom = new double *[kMaxParticles]; fParticleState = new UInt_t[kMaxParticles]; fParticlePDG = new int[kMaxParticles]; fPrimaryVertex = new bool[kMaxParticles]; fOrigParticleMom = new double *[kMaxParticles]; fOrigParticleState = new UInt_t[kMaxParticles]; fOrigParticlePDG = new int[kMaxParticles]; fOrigPrimaryVertex = new bool[kMaxParticles]; for (size_t i = 0; i < kMaxParticles; i++) { fParticleList[i] = NULL; fParticleMom[i] = new double[4]; fOrigParticleMom[i] = new double[4]; } if (fGenInfo) fGenInfo->AllocateParticleStack(kMaxParticles); } void FitEvent::ExpandParticleStack(int stacksize) { DeallocateParticleStack(); AllocateParticleStack(stacksize); } void FitEvent::DeallocateParticleStack() { for (size_t i = 0; i < kMaxParticles; i++) { if (fParticleList[i]) delete fParticleList[i]; delete fParticleMom[i]; delete fOrigParticleMom[i]; } delete fParticleMom; delete fOrigParticleMom; delete fParticleList; delete fParticleState; delete fParticlePDG; delete fPrimaryVertex; delete fOrigParticleState; delete fOrigParticlePDG; delete fOrigPrimaryVertex; if (fGenInfo) fGenInfo->DeallocateParticleStack(); kMaxParticles = 0; } void FitEvent::ClearFitParticles() { for (size_t i = 0; i < kMaxParticles; i++) { fParticleList[i] = NULL; } } void FitEvent::FreeFitParticles() { for (size_t i = 0; i < kMaxParticles; i++) { FitParticle *fp = fParticleList[i]; if (fp) delete fp; fParticleList[i] = NULL; } } void FitEvent::ResetParticleList() { for (unsigned int i = 0; i < kMaxParticles; i++) { FitParticle *fp = fParticleList[i]; if (fp) delete fp; fParticleList[i] = NULL; } } void FitEvent::HardReset() { for (unsigned int i = 0; i < kMaxParticles; i++) { fParticleList[i] = NULL; } } void FitEvent::ResetEvent() { Mode = 9999; fEventNo = -1; fTotCrs = -1.0; fTargetA = -1; fTargetZ = -1; fTargetH = -1; fBound = false; fNParticles = 0; if (fGenInfo) fGenInfo->Reset(); for (unsigned int i = 0; i < kMaxParticles; i++) { if (fParticleList[i]) delete fParticleList[i]; fParticleList[i] = NULL; continue; fParticlePDG[i] = 0; fParticleState[i] = kUndefinedState; fParticleMom[i][0] = 0.0; fParticleMom[i][1] = 0.0; fParticleMom[i][2] = 0.0; fParticleMom[i][3] = 0.0; fPrimaryVertex[i] = false; fOrigParticlePDG[i] = 0; fOrigParticleState[i] = kUndefinedState; fOrigParticleMom[i][0] = 0.0; fOrigParticleMom[i][1] = 0.0; fOrigParticleMom[i][2] = 0.0; fOrigParticleMom[i][3] = 0.0; fOrigPrimaryVertex[i] = false; } } void FitEvent::OrderStack() { // Copy current stack int npart = fNParticles; for (int i = 0; i < npart; i++) { fOrigParticlePDG[i] = fParticlePDG[i]; fOrigParticleState[i] = fParticleState[i]; fOrigParticleMom[i][0] = fParticleMom[i][0]; fOrigParticleMom[i][1] = fParticleMom[i][1]; fOrigParticleMom[i][2] = fParticleMom[i][2]; fOrigParticleMom[i][3] = fParticleMom[i][3]; fOrigPrimaryVertex[i] = fPrimaryVertex[i]; } // 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 ((UInt_t)fOrigParticleState[i] != (UInt_t)stateorder[s]) continue; fParticlePDG[fNParticles] = fOrigParticlePDG[i]; fParticleState[fNParticles] = fOrigParticleState[i]; fParticleMom[fNParticles][0] = fOrigParticleMom[i][0]; fParticleMom[fNParticles][1] = fOrigParticleMom[i][1]; fParticleMom[fNParticles][2] = fOrigParticleMom[i][2]; fParticleMom[fNParticles][3] = fOrigParticleMom[i][3]; fPrimaryVertex[fNParticles] = fOrigPrimaryVertex[i]; fNParticles++; } } if (LOG_LEVEL(DEB)) { NUIS_LOG(DEB, "Ordered stack"); for (int i = 0; i < fNParticles; i++) { NUIS_LOG(DEB, "Particle " << i << ". " << fParticlePDG[i] << " " << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " " << fParticleState[i]); } } if (fNParticles != npart) { NUIS_ABORT("Dropped some particles when ordering the stack!"); } return; } void FitEvent::Print() { if (LOG_LEVEL(FIT)) { NUIS_LOG(FIT, "FITEvent print"); NUIS_LOG(FIT, "Mode: " << Mode << ", Weight: " << InputWeight); NUIS_LOG(FIT, "Particles: " << fNParticles); NUIS_LOG(FIT, " -> Particle Stack "); for (int i = 0; i < fNParticles; i++) { NUIS_LOG(FIT, " -> -> " << i << ". " << fParticlePDG[i] << " " << fParticleState[i] << " " << " Mom(" << fParticleMom[i][0] << ", " << fParticleMom[i][1] << ", " << fParticleMom[i][2] << ", " << fParticleMom[i][3] << ")."); } } return; } /* Read/Write own event class */ void FitEvent::SetBranchAddress(TChain *tn) { 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("RWWeight", &SavedRWWeight); tn->SetBranchAddress("InputWeight", &InputWeight); } void FitEvent::AddBranchesToTree(TTree *tn) { tn->Branch("Mode", &Mode, "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("RWWeight", &RWWeight, "RWWeight/D"); tn->Branch("InputWeight", &InputWeight, "InputWeight/D"); tn->Branch("NParticles", &fNParticles, "NParticles/I"); tn->Branch("ParticleState", fOrigParticleState, "ParticleState[NParticles]/i"); tn->Branch("ParticlePDG", fOrigParticlePDG, "ParticlePDG[NParticles]/I"); tn->Branch("ParticleMom", fOrigParticleMom, "ParticleMom[NParticles][4]/D"); } // ------- EVENT ACCESS FUNCTION --------- // TLorentzVector FitEvent::GetParticleP4(int index) const { if (index == -1 or index >= fNParticles) return TLorentzVector(); return TLorentzVector(fParticleMom[index][0], fParticleMom[index][1], fParticleMom[index][2], fParticleMom[index][3]); } TVector3 FitEvent::GetParticleP3(int index) const { if (index == -1 or index >= fNParticles) return TVector3(); return TVector3(fParticleMom[index][0], fParticleMom[index][1], fParticleMom[index][2]); } double FitEvent::GetParticleMom(int index) const { if (index == -1 or index >= fNParticles) return 0.0; return sqrt(fParticleMom[index][0] * fParticleMom[index][0] + fParticleMom[index][1] * fParticleMom[index][1] + fParticleMom[index][2] * fParticleMom[index][2]); } double FitEvent::GetParticleMom2(int index) const { if (index == -1 or index >= fNParticles) return 0.0; return fabs((fParticleMom[index][0] * fParticleMom[index][0] + fParticleMom[index][1] * fParticleMom[index][1] + fParticleMom[index][2] * fParticleMom[index][2])); } double FitEvent::GetParticleE(int index) const { if (index == -1 or index >= fNParticles) return 0.0; return fParticleMom[index][3]; } int FitEvent::GetParticleState(int index) const { if (index == -1 or index >= fNParticles) return kUndefinedState; return (fParticleState[index]); } int FitEvent::GetParticlePDG(int index) const { if (index == -1 or index >= fNParticles) return 0; return (fParticlePDG[index]); } FitParticle *FitEvent::GetParticle(int const i) { // Check Valid Index if (i == -1) { return NULL; } // Check Valid if (i > fNParticles) { NUIS_ABORT("Requesting particle beyond stack!" << std::endl << "i = " << i << " N = " << fNParticles << std::endl << "Mode = " << Mode); } if (!fParticleList[i]) { /* std::cout << "Creating particle with values i " << i << " "; std::cout << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " "; std::cout << fParticlePDG[i] << " " << fParticleState[i] << std::endl; */ fParticleList[i] = new FitParticle(fParticleMom[i][0], fParticleMom[i][1], fParticleMom[i][2], fParticleMom[i][3], fParticlePDG[i], fParticleState[i]); } else { /* std::cout << "Filling particle with values i " << i << " "; std::cout << fParticleMom[i][0] << " " << fParticleMom[i][1] << " " << fParticleMom[i][2] << " " << fParticleMom[i][3] << " "; std::cout << fParticlePDG[i] << " "<< fParticleState[i] <SetValues(fParticleMom[i][0], fParticleMom[i][1], fParticleMom[i][2], fParticleMom[i][3], fParticlePDG[i], fParticleState[i]); } return fParticleList[i]; } bool FitEvent::HasParticle(int const pdg, int const state) const { 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 const pdg, int const state) const { int nfound = 0; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (pdg == 0 or fParticlePDG[i] == pdg) nfound += 1; } return nfound; } std::vector FitEvent::GetAllParticleIndices(int const pdg, int const state) const { std::vector indexlist; for (int i = 0; i < fNParticles; i++) { if (state != -1 and fParticleState[i] != (uint)state) continue; if (pdg == 0 or fParticlePDG[i] == pdg) { indexlist.push_back(i); } } return indexlist; } std::vector FitEvent::GetAllParticle(int const pdg, int const state) { std::vector indexlist = GetAllParticleIndices(pdg, state); std::vector plist; for (std::vector::iterator iter = indexlist.begin(); iter != indexlist.end(); iter++) { plist.push_back(GetParticle((*iter))); } return plist; } int FitEvent::GetHMParticleIndex(int const pdg, int const state) const { double maxmom2 = -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) { double newmom2 = GetParticleMom2(i); if (newmom2 > maxmom2) { maxind = i; maxmom2 = newmom2; } } } return maxind; } int FitEvent::GetBeamNeutrinoIndex(void) const { for (int i = 0; i < fNParticles; i++) { if (fParticleState[i] != kInitialState) continue; int pdg = abs(fParticlePDG[i]); if (pdg == 12 or pdg == 14 or pdg == 16) { return i; } } return 0; } int FitEvent::GetBeamElectronIndex(void) const { return GetHMISParticleIndex(11); } int FitEvent::GetBeamPionIndex(void) const { return GetHMISParticleIndex(PhysConst::pdg_pions); } int FitEvent::GetBeamPartIndex(void) const { return GetHMISParticleIndex(this->probe_pdg); } 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; } int FitEvent::NumFSLeptons(void) const { 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; } // Get the outgoing lepton PDG depending on if it's a CC or NC event int FitEvent::GetLeptonOutPDG() { // Make sure the outgoing lepton has the correct PDG int pdgnu = PDGnu(); int PDGout; if (IsCC()) { if (pdgnu > 0) PDGout = pdgnu-1; else PDGout = pdgnu+1; } else { PDGout = pdgnu; } return PDGout; } //******************************************************************** // Returns the true Q2 of an event double FitEvent::GetQ2() { FitParticle *neutrino = GetNeutrinoIn(); FitParticle *lepton = GetLeptonOut(); // Sometimes NEUT won't have an outgoing lepton because the event is Pauli blocked if (!neutrino || !lepton) { //if (!neutrino) std::cout << "no incoming neutrino!" << std::endl; //if (!lepton) std::cout << "no outgoing lepton!" << std::endl; #ifdef __NEUT_ENABLED__ //fNeutVect->Dump(); #endif return -999; } double Q2 = -1.0 * (lepton->P4() - neutrino->P4()) * (lepton->P4() - neutrino->P4()) / 1.E6; return Q2; } //******************************************************************** diff --git a/src/InputHandler/FitEvent.h b/src/InputHandler/FitEvent.h index c104d39..91bca08 100644 --- a/src/InputHandler/FitEvent.h +++ b/src/InputHandler/FitEvent.h @@ -1,659 +1,659 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FITEVENT2_H_SEEN #define FITEVENT2_H_SEEN /*! * \addtogroup InputHandler * @{ */ #include #include #include #include "FitParticle.h" #include "TLorentzVector.h" #include "TSpline.h" #include "BaseFitEvt.h" #include "FitLogger.h" #include "TArrayD.h" #include "TTree.h" #include "TChain.h" #include "TargetUtils.h" #include "PhysConst.h" /// Common container for event particles class FitEvent : public BaseFitEvt { public: FitEvent(); ~FitEvent() {}; void FreeFitParticles(); void ClearFitParticles(); void ResetEvent(void); void ResetParticleList(void); void HardReset(); void OrderStack(); void SetBranchAddress(TChain* tn); void AddBranchesToTree(TTree* tn); void Print(); void DeallocateParticleStack(); void AllocateParticleStack(int stacksize); void ExpandParticleStack(int stacksize); void AddGeneratorInfo(GeneratorInfoBase* gen); // ---- HELPER/ACCESS FUNCTIONS ---- // /// Return True Interaction ID inline int GetMode (void) const { return Mode; }; /// Return Target Atomic Number inline int GetTargetA (void) const { return fTargetA; }; /// Return Target Nuclear Charge inline int GetTargetZ (void) const { return fTargetZ; }; /// Get Event Total Cross-section inline int GetTotCrs (void) const { return fTotCrs; }; /// Is Event Charged Current? inline bool IsCC() const { if (abs(this->probe_pdg) == 11) return false; return (abs(Mode) <= 30); }; /// Is Event Neutral Current? inline bool IsNC() const { if (abs(this->probe_pdg) == 11) return true; return (abs(Mode) > 30); }; // Is Event resonant? inline bool IsResonant() const { if (Mode != 11 && Mode != 12 && Mode != 13 && Mode != 31 && Mode != 32 && Mode != 33 && Mode != 34) return false; return true; }; /// Return Particle 4-momentum for given index in particle stack TLorentzVector GetParticleP4 (int index) const; /// Return Particle 3-momentum for given index in particle stack TVector3 GetParticleP3 (int index) const; /// Return Particle absolute momentum for given index in particle stack double GetParticleMom (int index) const; /// Return Particle absolute momentum-squared for given index in particle stack double GetParticleMom2 (int index) const; /// Return Particle energy for given index in particle stack double GetParticleE (int index) const; /// Return Particle State for given index in particle stack int GetParticleState (int index) const; /// Return Particle PDG for given index in particle stack int GetParticlePDG (int index) const; /// Allows the removal of KE up to total KE. inline void RemoveKE(int index, double KE){ FitParticle *fp = GetParticle(index); double mass = fp->M(); double oKE = fp->KE(); double nE = mass + (oKE - KE); if(nE < mass){ // Can't take more KE than it has nE = mass; } double n3Mom = sqrt(nE*nE - mass*mass); TVector3 np3 = fp->P3().Unit()*n3Mom; fParticleMom[index][0] = np3[0]; fParticleMom[index][1] = np3[1]; fParticleMom[index][2] = np3[2]; fParticleMom[index][3] = nE; } /// Allows the removal of KE up to total KE. inline void GiveKE(int index, double KE){ RemoveKE(index,-KE); } /// Return Particle for given index in particle stack FitParticle* GetParticle(int const index); /// Get Total Number of Particles in stack inline uint NParticles (void) const { return fNParticles; }; /// Check if event contains a particle given a pdg and state. /// If no state is passed all states are considered. bool HasParticle (int const pdg = 0, int const state = -1) const ; template inline bool HasParticle(int const (&pdgs)[N], int const state = -1) const { for (size_t i = 0; i < N; i++) { if (HasParticle( pdgs[i], state )) { return false; } } return false; } /// Get total number of particles given a pdg and state. /// If no state is passed all states are considered. int NumParticle (int const pdg = 0, int const state = -1) const; template inline int NumParticle(int const (&pdgs)[N], int const state = -1) const { int ncount = 0; for (size_t i = 0; i < N; i++) { ncount += NumParticle( pdgs[i], state ); } return ncount; } /// Return a vector of particle indices that can be used with 'GetParticle' /// functions given a particle pdg and state. /// If no state is passed all states are considered. std::vector GetAllParticleIndices (int const pdg = -1, int const state = -1) const; template inline std::vector GetAllParticleIndices(int const (&pdgs)[N], const int state = -1) const { std::vector plist; for (size_t i = 0; i < N; i++) { std::vector plisttemp = GetAllParticleIndices(pdgs[i], state); plist.insert( plist.end(), plisttemp.begin(), plisttemp.end() ); } return plist; } /// Return a vector of FitParticles given a particle pdg and state. /// This is memory intensive and slow than GetAllParticleIndices, /// but is slightly easier to use. std::vector GetAllParticle (int const pdg = -1, int const state = -1); template inline std::vector GetAllParticle(int const (&pdgs)[N], int const state = -1) { std::vector plist; for (size_t i = 0; i < N; i++) { std::vector plisttemp = GetAllParticle(pdgs[i], state); plist.insert( plist.end(), plisttemp.begin(), plisttemp.end() ); } return plist; } inline std::vector GetAllNuElectronIndices (void) { return GetAllParticleIndices(12); }; inline std::vector GetAllNuMuonIndices (void) { return GetAllParticleIndices(14); }; inline std::vector GetAllNuTauIndices (void) { return GetAllParticleIndices(16); }; inline std::vector GetAllElectronIndices (void) { return GetAllParticleIndices(11); }; inline std::vector GetAllMuonIndices (void) { return GetAllParticleIndices(13); }; inline std::vector GetAllTauIndices (void) { return GetAllParticleIndices(15); }; inline std::vector GetAllProtonIndices (void) { return GetAllParticleIndices(2212); }; inline std::vector GetAllNeutronIndices (void) { return GetAllParticleIndices(2112); }; inline std::vector GetAllPiZeroIndices (void) { return GetAllParticleIndices(111); }; inline std::vector GetAllPiPlusIndices (void) { return GetAllParticleIndices(211); }; inline std::vector GetAllPiMinusIndices (void) { return GetAllParticleIndices(-211); }; inline std::vector GetAllPhotonIndices (void) { return GetAllParticleIndices(22); }; inline std::vector GetAllNuElectron (void) { return GetAllParticle(12); }; inline std::vector GetAllNuMuon (void) { return GetAllParticle(14); }; inline std::vector GetAllNuTau (void) { return GetAllParticle(16); }; inline std::vector GetAllElectron (void) { return GetAllParticle(11); }; inline std::vector GetAllMuon (void) { return GetAllParticle(13); }; inline std::vector GetAllTau (void) { return GetAllParticle(15); }; inline std::vector GetAllProton (void) { return GetAllParticle(2212); }; inline std::vector GetAllNeutron (void) { return GetAllParticle(2112); }; inline std::vector GetAllPiZero (void) { return GetAllParticle(111); }; inline std::vector GetAllPiPlus (void) { return GetAllParticle(211); }; inline std::vector GetAllPiMinus (void) { return GetAllParticle(-211); }; inline std::vector GetAllPhoton (void) { return GetAllParticle(22); }; // --- Highest Momentum Search Functions --- // /// Returns the Index of the highest momentum particle given a pdg and state. /// If no state is given all states are considered, but that will just return the /// momentum of the beam in most cases so is not advised. int GetHMParticleIndex (int const pdg = 0, int const state = -1) const; template inline int GetHMParticleIndex (int const (&pdgs)[N], int const state = -1) const { double mom = -999.9; int rtnindex = -1; for (size_t i = 0; i < N; ++i) { // Use ParticleMom as doesn't require Particle Mem alloc int pindex = GetHMParticleIndex(pdgs[i], state); if (pindex != -1){ double momnew = GetParticleMom2(pindex); if (momnew > mom) { rtnindex = pindex; mom = momnew; } } } return rtnindex; }; /// Returns the highest momentum particle given a pdg and state. /// If no state is given all states are considered, but that will just return the /// momentum of the beam in most cases so is not advised. inline FitParticle* GetHMParticle(int const pdg = 0, int const state = -1) { return GetParticle( GetHMParticleIndex(pdg, state) ); } template inline FitParticle* GetHMParticle(int const (&pdgs)[N], int const state) { return GetParticle(GetHMParticleIndex(pdgs, state)); }; // ---- Initial State Helpers --- // /// Checks the event has a particle of a given pdg in the initial state. inline bool HasISParticle(int const pdg) const { return HasParticle(pdg, kInitialState); }; template inline bool HasISParticle(int const (&pdgs)[N]) const { return HasParticle(pdgs, kInitialState); }; /// Returns the number of particles with a given pdg in the initial state. inline int NumISParticle(int const pdg = 0) const { return NumParticle(pdg, kInitialState); }; template inline int NumISParticle(int const (&pdgs)[N]) const { return NumParticle(pdgs, kInitialState); }; /// Returns a list of indices for all particles with a given pdg /// in the initial state. These can be used with the 'GetParticle' functions. inline std::vector GetAllISParticleIndices(int const pdg = -1) const { return GetAllParticleIndices(pdg, kInitialState); }; template inline std::vector GetAllISParticleIndices(int const (&pdgs)[N]) const { return GetAllParticleIndices(pdgs, kInitialState); }; /// Returns a list of particles with a given pdg in the initial state. /// This function is more memory intensive and slower than the Indices function. inline std::vector GetAllISParticle(int const pdg = -1) { return GetAllParticle(pdg, kInitialState); }; template inline std::vector GetAllISParticle(int const (&pdgs)[N]) { return GetAllParticle(pdgs, kInitialState); }; /// Returns the highest momentum particle with a given pdg in the initial state. inline FitParticle* GetHMISParticle(int const pdg) { return GetHMParticle(pdg, kInitialState); }; template inline FitParticle* GetHMISParticle(int const (&pdgs)[N]) { return GetHMParticle(pdgs, kInitialState); }; /// Returns the highest momentum particle index with a given pdg in the initial state. inline int GetHMISParticleIndex(int const pdg) const { return GetHMParticleIndex(pdg, kInitialState); }; template inline int GetHMISParticleIndex(int const (&pdgs)[N]) const { return GetHMParticleIndex(pdgs, kInitialState); }; inline bool HasISNuElectron (void) const { return HasISParticle(12); }; inline bool HasISNuMuon (void) const { return HasISParticle(14); }; inline bool HasISNuTau (void) const { return HasISParticle(16); }; inline bool HasISElectron (void) const { return HasISParticle(11); }; inline bool HasISMuon (void) const { return HasISParticle(13); }; inline bool HasISTau (void) const { return HasISParticle(15); }; inline bool HasISProton (void) const { return HasISParticle(2212); }; inline bool HasISNeutron (void) const { return HasISParticle(2112); }; inline bool HasISPiZero (void) const { return HasISParticle(111); }; inline bool HasISPiPlus (void) const { return HasISParticle(211); }; inline bool HasISPiMinus (void) const { return HasISParticle(-211); }; inline bool HasISPhoton (void) const { return HasISParticle(22); }; inline bool HasISLeptons (void) const { return HasISParticle(PhysConst::pdg_leptons); }; inline bool HasISPions (void) const { return HasISParticle(PhysConst::pdg_pions); }; inline bool HasISChargePions (void) const { return HasISParticle(PhysConst::pdg_charged_pions); }; inline int NumISNuElectron (void) const { return NumISParticle(12); }; inline int NumISNuMuon (void) const { return NumISParticle(14); }; inline int NumISNuTau (void) const { return NumISParticle(16); }; inline int NumISElectron (void) const { return NumISParticle(11); }; inline int NumISMuon (void) const { return NumISParticle(13); }; inline int NumISTau (void) const { return NumISParticle(15); }; inline int NumISProton (void) const { return NumISParticle(2212); }; inline int NumISNeutron (void) const { return NumISParticle(2112); }; inline int NumISPiZero (void) const { return NumISParticle(111); }; inline int NumISPiPlus (void) const { return NumISParticle(211); }; inline int NumISPiMinus (void) const { return NumISParticle(-211); }; inline int NumISPhoton (void) const { return NumISParticle(22); }; inline int NumISLeptons (void) const { return NumISParticle(PhysConst::pdg_leptons); }; inline int NumISPions (void) const { return NumISParticle(PhysConst::pdg_pions); }; inline int NumISChargePions (void) const { return NumISParticle(PhysConst::pdg_charged_pions); }; inline std::vector GetAllISNuElectronIndices (void) const { return GetAllISParticleIndices(12); }; inline std::vector GetAllISNuMuonIndices (void) const { return GetAllISParticleIndices(14); }; inline std::vector GetAllISNuTauIndices (void) const { return GetAllISParticleIndices(16); }; inline std::vector GetAllISElectronIndices (void) const { return GetAllISParticleIndices(11); }; inline std::vector GetAllISMuonIndices (void) const { return GetAllISParticleIndices(13); }; inline std::vector GetAllISTauIndices (void) const { return GetAllISParticleIndices(15); }; inline std::vector GetAllISProtonIndices (void) const { return GetAllISParticleIndices(2212); }; inline std::vector GetAllISNeutronIndices (void) const { return GetAllISParticleIndices(2112); }; inline std::vector GetAllISPiZeroIndices (void) const { return GetAllISParticleIndices(111); }; inline std::vector GetAllISPiPlusIndices (void) const { return GetAllISParticleIndices(211); }; inline std::vector GetAllISPiMinusIndices (void) const { return GetAllISParticleIndices(-211); }; inline std::vector GetAllISPhotonIndices (void) const { return GetAllISParticleIndices(22); }; inline std::vector GetAllISLeptonsIndices (void) const { return GetAllISParticleIndices(PhysConst::pdg_leptons); }; inline std::vector GetAllISPionsIndices (void) const { return GetAllISParticleIndices(PhysConst::pdg_pions); }; inline std::vector GetAllISChargePionsIndices(void) const { return GetAllISParticleIndices(PhysConst::pdg_charged_pions); }; inline std::vector GetAllISNuElectron (void) { return GetAllISParticle(12); }; inline std::vector GetAllISNuMuon (void) { return GetAllISParticle(14); }; inline std::vector GetAllISNuTau (void) { return GetAllISParticle(16); }; inline std::vector GetAllISElectron (void) { return GetAllISParticle(11); }; inline std::vector GetAllISMuon (void) { return GetAllISParticle(13); }; inline std::vector GetAllISTau (void) { return GetAllISParticle(15); }; inline std::vector GetAllISProton (void) { return GetAllISParticle(2212); }; inline std::vector GetAllISNeutron (void) { return GetAllISParticle(2112); }; inline std::vector GetAllISPiZero (void) { return GetAllISParticle(111); }; inline std::vector GetAllISPiPlus (void) { return GetAllISParticle(211); }; inline std::vector GetAllISPiMinus (void) { return GetAllISParticle(-211); }; inline std::vector GetAllISPhoton (void) { return GetAllISParticle(22); }; inline std::vector GetAllISLeptons (void) { return GetAllISParticle(PhysConst::pdg_leptons); }; inline std::vector GetAllISPions (void) { return GetAllISParticle(PhysConst::pdg_pions); }; inline std::vector GetAllISChargePions(void) { return GetAllISParticle(PhysConst::pdg_charged_pions); }; inline FitParticle* GetHMISNuElectron (void) { return GetHMISParticle(12); }; inline FitParticle* GetHMISNuMuon (void) { return GetHMISParticle(14); }; inline FitParticle* GetHMISNuTau (void) { return GetHMISParticle(16); }; inline FitParticle* GetHMISElectron (void) { return GetHMISParticle(11); }; inline FitParticle* GetHMISMuon (void) { return GetHMISParticle(13); }; inline FitParticle* GetHMISTau (void) { return GetHMISParticle(15); }; inline FitParticle* GetHMISAnyLeptons (void) { return GetHMISParticle(PhysConst::pdg_all_leptons); }; inline FitParticle* GetHMISProton (void) { return GetHMISParticle(2212); }; inline FitParticle* GetHMISNeutron (void) { return GetHMISParticle(2112); }; inline FitParticle* GetHMISPiZero (void) { return GetHMISParticle(111); }; inline FitParticle* GetHMISPiPlus (void) { return GetHMISParticle(211); }; inline FitParticle* GetHMISPiMinus (void) { return GetHMISParticle(-211); }; inline FitParticle* GetHMISPhoton (void) { return GetHMISParticle(22); }; inline FitParticle* GetHMISLepton (void) { return GetHMISParticle(PhysConst::pdg_leptons); }; inline FitParticle* GetHMISPions (void) { return GetHMISParticle(PhysConst::pdg_pions); }; inline FitParticle* GetHMISChargePions(void) { return GetHMISParticle(PhysConst::pdg_charged_pions); }; inline int GetHMISNuElectronIndex (void) { return GetHMISParticleIndex(12); }; inline int GetHMISNuMuonIndex (void) { return GetHMISParticleIndex(14); }; inline int GetHMISNuTauIndex (void) { return GetHMISParticleIndex(16); }; inline int GetHMISElectronIndex (void) { return GetHMISParticleIndex(11); }; inline int GetHMISMuonIndex (void) { return GetHMISParticleIndex(13); }; inline int GetHMISTauIndex (void) { return GetHMISParticleIndex(15); }; inline int GetHMISProtonIndex (void) { return GetHMISParticleIndex(2212); }; inline int GetHMISNeutronIndex (void) { return GetHMISParticleIndex(2112); }; inline int GetHMISPiZeroIndex (void) { return GetHMISParticleIndex(111); }; inline int GetHMISPiPlusIndex (void) { return GetHMISParticleIndex(211); }; inline int GetHMISPiMinusIndex (void) { return GetHMISParticleIndex(-211); }; inline int GetHMISPhotonIndex (void) { return GetHMISParticleIndex(22); }; inline int GetHMISLeptonsIndex (void) { return GetHMISParticleIndex(PhysConst::pdg_leptons); }; inline int GetHMISPionsIndex (void) { return GetHMISParticleIndex(PhysConst::pdg_pions); }; inline int GetHMISChargePionsIndex(void) { return GetHMISParticleIndex(PhysConst::pdg_charged_pions); }; // ---- Final State Helpers --- // inline bool HasFSParticle(int const pdg) const { return HasParticle(pdg, kFinalState); }; template inline bool HasFSParticle(int const (&pdgs)[N]) const { return HasParticle(pdgs, kFinalState); }; inline int NumFSParticle(int const pdg = 0) const { return NumParticle(pdg, kFinalState); }; template inline int NumFSParticle(int const (&pdgs)[N]) const { return NumParticle(pdgs, kFinalState); }; inline std::vector GetAllFSParticleIndices(int const pdg = -1) const { return GetAllParticleIndices(pdg, kFinalState); }; template inline std::vector GetAllFSParticleIndices(int const (&pdgs)[N]) const { return GetAllParticleIndices(pdgs, kFinalState); }; inline std::vector GetAllFSParticle(int const pdg = -1) { return GetAllParticle(pdg, kFinalState); }; template inline std::vector GetAllFSParticle(int const (&pdgs)[N]) { return GetAllParticle(pdgs, kFinalState); }; inline FitParticle* GetHMFSParticle(int const pdg) { return GetHMParticle(pdg, kFinalState); }; template inline FitParticle* GetHMFSParticle(int const (&pdgs)[N]) { return GetHMParticle(pdgs, kFinalState); }; inline int GetHMFSParticleIndex(int const pdg) const { return GetHMParticleIndex(pdg, kFinalState); }; template inline int GetHMFSParticleIndex(int const (&pdgs)[N]) const { return GetHMParticleIndex(pdgs, kFinalState); }; inline bool HasFSNuElectron (void) const { return HasFSParticle(12); }; inline bool HasFSNuMuon (void) const { return HasFSParticle(14); }; inline bool HasFSNuTau (void) const { return HasFSParticle(16); }; inline bool HasFSElectron (void) const { return HasFSParticle(11); }; inline bool HasFSMuon (void) const { return HasFSParticle(13); }; inline bool HasFSTau (void) const { return HasFSParticle(15); }; inline bool HasFSProton (void) const { return HasFSParticle(2212); }; inline bool HasFSNeutron (void) const { return HasFSParticle(2112); }; inline bool HasFSPiZero (void) const { return HasFSParticle(111); }; inline bool HasFSPiPlus (void) const { return HasFSParticle(211); }; inline bool HasFSPiMinus (void) const { return HasFSParticle(-211); }; inline bool HasFSPhoton (void) const { return HasFSParticle(22); }; inline bool HasFSLeptons (void) const { return HasFSParticle(PhysConst::pdg_leptons); }; inline bool HasFSPions (void) const { return HasFSParticle(PhysConst::pdg_pions); }; inline bool HasFSChargePions (void) const { return HasFSParticle(PhysConst::pdg_charged_pions); }; inline bool HasFSNucleons (void) const { return HasFSParticle(PhysConst::pdg_nucleons); }; inline int NumFSNuElectron (void) const { return NumFSParticle(12); }; inline int NumFSNuMuon (void) const { return NumFSParticle(14); }; inline int NumFSNuTau (void) const { return NumFSParticle(16); }; inline int NumFSElectron (void) const { return NumFSParticle(11); }; inline int NumFSMuon (void) const { return NumFSParticle(13); }; inline int NumFSTau (void) const { return NumFSParticle(15); }; inline int NumFSProton (void) const { return NumFSParticle(2212); }; inline int NumFSNeutron (void) const { return NumFSParticle(2112); }; inline int NumFSPiZero (void) const { return NumFSParticle(111); }; inline int NumFSPiPlus (void) const { return NumFSParticle(211); }; inline int NumFSPiMinus (void) const { return NumFSParticle(-211); }; inline int NumFSPhoton (void) const { return NumFSParticle(22); }; int NumFSLeptons (void) const; // { return NumFSParticle(PhysConst::pdg_leptons); }; inline int NumFSPions (void) const { return NumFSParticle(PhysConst::pdg_pions); }; inline int NumFSChargePions (void) const { return NumFSParticle(PhysConst::pdg_charged_pions); }; inline int NumFSNucleons (void) const { return NumFSParticle(PhysConst::pdg_nucleons); }; inline std::vector GetAllFSNuElectronIndices (void) const { return GetAllFSParticleIndices(12); }; inline std::vector GetAllFSNuMuonIndices (void) const { return GetAllFSParticleIndices(14); }; inline std::vector GetAllFSNuTauIndices (void) const { return GetAllFSParticleIndices(16); }; inline std::vector GetAllFSElectronIndices (void) const { return GetAllFSParticleIndices(11); }; inline std::vector GetAllFSMuonIndices (void) const { return GetAllFSParticleIndices(13); }; inline std::vector GetAllFSTauIndices (void) const { return GetAllFSParticleIndices(15); }; inline std::vector GetAllFSProtonIndices (void) const { return GetAllFSParticleIndices(2212); }; inline std::vector GetAllFSNeutronIndices (void) const { return GetAllFSParticleIndices(2112); }; inline std::vector GetAllFSPiZeroIndices (void) const { return GetAllFSParticleIndices(111); }; inline std::vector GetAllFSPiPlusIndices (void) const { return GetAllFSParticleIndices(211); }; inline std::vector GetAllFSPiMinusIndices (void) const { return GetAllFSParticleIndices(-211); }; inline std::vector GetAllFSPhotonIndices (void) const { return GetAllFSParticleIndices(22); }; inline std::vector GetAllFSLeptonsIndices (void) const { return GetAllFSParticleIndices(PhysConst::pdg_leptons); }; inline std::vector GetAllFSPionsIndices (void) const { return GetAllFSParticleIndices(PhysConst::pdg_pions); }; inline std::vector GetAllFSChargePionsIndices(void) const { return GetAllFSParticleIndices(PhysConst::pdg_charged_pions); }; inline std::vector GetAllFSNucleonIndices(void) const { return GetAllFSParticleIndices(PhysConst::pdg_nucleons); }; inline std::vector GetAllFSNuElectron (void) { return GetAllFSParticle(12); }; inline std::vector GetAllFSNuMuon (void) { return GetAllFSParticle(14); }; inline std::vector GetAllFSNuTau (void) { return GetAllFSParticle(16); }; inline std::vector GetAllFSElectron (void) { return GetAllFSParticle(11); }; inline std::vector GetAllFSMuon (void) { return GetAllFSParticle(13); }; inline std::vector GetAllFSTau (void) { return GetAllFSParticle(15); }; inline std::vector GetAllFSProton (void) { return GetAllFSParticle(2212); }; inline std::vector GetAllFSNeutron (void) { return GetAllFSParticle(2112); }; inline std::vector GetAllFSPiZero (void) { return GetAllFSParticle(111); }; inline std::vector GetAllFSPiPlus (void) { return GetAllFSParticle(211); }; inline std::vector GetAllFSPiMinus (void) { return GetAllFSParticle(-211); }; inline std::vector GetAllFSPhoton (void) { return GetAllFSParticle(22); }; inline std::vector GetAllFSLeptons (void) { return GetAllFSParticle(PhysConst::pdg_leptons); }; inline std::vector GetAllFSPions (void) { return GetAllFSParticle(PhysConst::pdg_pions); }; inline std::vector GetAllFSChargePions (void) { return GetAllFSParticle(PhysConst::pdg_charged_pions); }; inline std::vector GetAllFSNucleons (void) { return GetAllFSParticle(PhysConst::pdg_nucleons); }; inline FitParticle* GetHMFSNuElectron (void) { return GetHMFSParticle(12); }; inline FitParticle* GetHMFSNuMuon (void) { return GetHMFSParticle(14); }; inline FitParticle* GetHMFSNuTau (void) { return GetHMFSParticle(16); }; inline FitParticle* GetHMFSElectron (void) { return GetHMFSParticle(11); }; inline FitParticle* GetHMFSMuon (void) { return GetHMFSParticle(13); }; inline FitParticle* GetHMFSTau (void) { return GetHMFSParticle(15); }; inline FitParticle* GetHMFSAnyLeptons (void) { return GetHMFSParticle(PhysConst::pdg_all_leptons); }; inline FitParticle* GetHMFSProton (void) { return GetHMFSParticle(2212); }; inline FitParticle* GetHMFSNeutron (void) { return GetHMFSParticle(2112); }; inline FitParticle* GetHMFSPiZero (void) { return GetHMFSParticle(111); }; inline FitParticle* GetHMFSPiPlus (void) { return GetHMFSParticle(211); }; inline FitParticle* GetHMFSPiMinus (void) { return GetHMFSParticle(-211); }; inline FitParticle* GetHMFSPhoton (void) { return GetHMFSParticle(22); }; inline FitParticle* GetHMFSLeptons (void) { return GetHMFSParticle(PhysConst::pdg_leptons); }; inline FitParticle* GetHMFSAnyLepton (void) { return GetHMFSParticle(PhysConst::pdg_all_leptons); }; inline FitParticle* GetHMFSPions (void) { return GetHMFSParticle(PhysConst::pdg_pions); }; inline FitParticle* GetHMFSChargePions(void) { return GetHMFSParticle(PhysConst::pdg_charged_pions); }; inline FitParticle* GetHMFSNucleons(void) { return GetHMFSParticle(PhysConst::pdg_nucleons); }; inline int GetHMFSNuElectronIndex (void) const { return GetHMFSParticleIndex(12); }; inline int GetHMFSNuMuonIndex (void) const { return GetHMFSParticleIndex(14); }; inline int GetHMFSNuTauIndex (void) const { return GetHMFSParticleIndex(16); }; inline int GetHMFSElectronIndex (void) const { return GetHMFSParticleIndex(11); }; inline int GetHMFSMuonIndex (void) const { return GetHMFSParticleIndex(13); }; inline int GetHMFSTauIndex (void) const { return GetHMFSParticleIndex(15); }; inline int GetHMFSProtonIndex (void) const { return GetHMFSParticleIndex(2212); }; inline int GetHMFSNeutronIndex (void) const { return GetHMFSParticleIndex(2112); }; inline int GetHMFSPiZeroIndex (void) const { return GetHMFSParticleIndex(111); }; inline int GetHMFSPiPlusIndex (void) const { return GetHMFSParticleIndex(211); }; inline int GetHMFSPiMinusIndex (void) const { return GetHMFSParticleIndex(-211); }; inline int GetHMFSPhotonIndex (void) const { return GetHMFSParticleIndex(22); }; inline int GetHMFSLeptonsIndex (void) const { return GetHMFSParticleIndex(PhysConst::pdg_leptons); }; inline int GetHMFSAnyLeptonIndex (void) const { return GetHMFSParticleIndex(PhysConst::pdg_all_leptons); }; inline int GetHMFSPionsIndex (void) const { return GetHMFSParticleIndex(PhysConst::pdg_pions); }; inline int GetHMFSChargePionsIndex(void) const { return GetHMFSParticleIndex(PhysConst::pdg_charged_pions); }; inline int GetHMFSChargeNucleonIndex(void) const { return GetHMFSParticleIndex(PhysConst::pdg_nucleons); }; // ---- NEUTRINO INCOMING Related Functions int GetBeamNeutrinoIndex (void) const; inline TLorentzVector GetBeamNeutrinoP4 (void) const { return GetParticleP4(GetBeamNeutrinoIndex()); }; inline TVector3 GetBeamNeutrinoP3 (void) const { return GetParticleP3(GetBeamNeutrinoIndex()); }; inline double GetBeamNeutrinoMom (void) const { return GetParticleMom(GetBeamNeutrinoIndex()); }; inline double GetBeamNeutrinoMom2 (void) const { return GetParticleMom2(GetBeamNeutrinoIndex()); }; inline double GetBeamNeutrinoE (void) const { return GetParticleE(GetBeamNeutrinoIndex()); }; inline double Enu (void) const { return GetBeamNeutrinoE(); }; inline int GetBeamNeutrinoPDG (void) const { return GetParticlePDG(GetBeamNeutrinoIndex()); }; inline int PDGnu (void) const { return GetBeamNeutrinoPDG(); }; inline int GetNeutrinoInPos (void) const { return GetBeamNeutrinoIndex(); }; inline FitParticle* GetBeamNeutrino (void) { return GetParticle(GetBeamNeutrinoIndex()); }; inline FitParticle* GetNeutrinoIn (void) { return GetParticle(GetBeamNeutrinoIndex()); }; // ---- Electron INCOMING Related Functions int GetBeamElectronIndex (void) const; inline TLorentzVector GetBeamElectronP4 (void) const { return GetParticleP4(GetBeamElectronIndex()); }; inline TVector3 GetBeamElectronP3 (void) const { return GetParticleP3(GetBeamElectronIndex()); }; inline double GetBeamElectronMom (void) const { return GetParticleMom(GetBeamElectronIndex()); }; inline double GetBeamElectronMom2 (void) const { return GetParticleMom2(GetBeamElectronIndex()); }; inline double GetBeamElectronE (void) const { return GetParticleE(GetBeamElectronIndex()); }; inline FitParticle* GetBeamElectron (void) { return GetParticle(GetBeamElectronIndex()); }; // ---- Pion INCOMING Functions int GetBeamPionIndex (void) const; inline TLorentzVector GetBeamPionP4 (void) const { return GetParticleP4(GetBeamPionIndex()); }; inline TVector3 GetBeamPionP3 (void) const { return GetParticleP3(GetBeamPionIndex()); }; inline double GetBeamPionMom (void) const { return GetParticleMom(GetBeamPionIndex()); }; inline double GetBeamPionMom2 (void) const { return GetParticleMom2(GetBeamPionIndex()); }; inline double GetBeamPionE (void) const { return GetParticleE(GetBeamPionIndex()); }; inline FitParticle* GetBeamPion (void) { return GetParticle(GetBeamPionIndex()); }; // ---- Generic beam incoming functions // I'm not 100% sure why these can't replace the above (FitEvent knows the type) int GetBeamPartIndex (void) const; inline TLorentzVector GetBeamPartP4 (void) const { return GetParticleP4(GetBeamPartIndex()); }; inline TVector3 GetBeamPartP3 (void) const { return GetParticleP3(GetBeamPartIndex()); }; inline double GetBeamPartMom (void) const { return GetParticleMom(GetBeamPartIndex()); }; inline double GetBeamPartMom2 (void) const { return GetParticleMom2(GetBeamPartIndex()); }; inline double GetBeamPartE (void) const { return GetParticleE(GetBeamPartIndex()); }; inline int GetBeamPartPDG (void) const { return GetParticlePDG(GetBeamPartIndex()); }; inline int GetPartInPos (void) const { return GetBeamPartIndex(); }; inline FitParticle* GetBeamPart (void) { return GetParticle(GetBeamPartIndex()); }; /// Legacy Functions inline FitParticle* PartInfo(uint i) { return GetParticle(i); }; inline UInt_t Npart (void) const { return NPart(); }; inline UInt_t NPart (void) const { return fNParticles; }; // Other Functions int NumFSMesons(); // Get outgoing lepton matching PDG of neutrino int GetLeptonOutPDG(); FitParticle* GetLeptonOut() {return GetHMFSParticle(GetLeptonOutPDG()); }; // Get the outgoing lepton index int GetLeptonIndex() { return GetHMFSParticleIndex(GetLeptonOutPDG()); }; double GetQ2(); // Event Information UInt_t fEventNo; double fTotCrs; int fTargetA; int fTargetZ; int fTargetH; bool fBound; int fDistance; int fTargetPDG; // Reduced Particle Stack UInt_t kMaxParticles; int fNParticles; double** fParticleMom; UInt_t* fParticleState; int* fParticlePDG; FitParticle** fParticleList; bool *fPrimaryVertex; double** fOrigParticleMom; UInt_t* fOrigParticleState; int* fOrigParticlePDG; bool* fOrigPrimaryVertex; double* fNEUT_ParticleStatusCode; double* fNEUT_ParticleAliveCode; GeneratorInfoBase* fGenInfo; // Config Options for this class bool kRemoveFSIParticles; bool kRemoveUndefParticles; }; /*! @} */ #endif diff --git a/src/InputHandler/FitEventInputHandler.cxx b/src/InputHandler/FitEventInputHandler.cxx index a30350f..2cde85c 100644 --- a/src/InputHandler/FitEventInputHandler.cxx +++ b/src/InputHandler/FitEventInputHandler.cxx @@ -1,141 +1,141 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitEventInputHandler.h" #include "InputUtils.h" FitEventInputHandler::FitEventInputHandler(std::string const &handle, std::string const &rawinputs) { NUIS_LOG(SAM, "Creating FitEventInputHandler : " << handle); // Run a joint input handling fName = handle; fFitEventTree = new TChain("nuisance_events"); fCacheSize = FitPar::Config().GetParI("CacheSize"); std::vector inputs = InputUtils::ParseInputFileList(rawinputs); for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { // Open File for histogram access TFile *inp_file = new TFile(inputs[inp_it].c_str(), "READ"); if (!inp_file or inp_file->IsZombie()) { NUIS_ABORT("FitEvent File IsZombie() at " << inputs[inp_it]); } // Get Flux/Event hist TH1D *fluxhist = (TH1D *)inp_file->Get("nuisance_fluxhist"); TH1D *eventhist = (TH1D *)inp_file->Get("nuisance_eventhist"); if (!fluxhist or !eventhist) { NUIS_ABORT("FitEvent FILE doesn't contain flux/xsec info"); } // Get N Events TTree *eventtree = (TTree *)inp_file->Get("nuisance_events"); if (!eventtree) { NUIS_ABORT("nuisance_events not located in GENIE file! " << inputs[inp_it]); } int nevents = eventtree->GetEntries(); // Register input to form flux/event rate hists RegisterJointInput(inputs[inp_it], nevents, fluxhist, eventhist); // Add to TChain fFitEventTree->Add(inputs[inp_it].c_str()); } // Registor all our file inputs SetupJointInputs(); // Assign to tree fEventType = kINPUTFITEVENT; // Create Fit Event fNUISANCEEvent = new FitEvent(); fNUISANCEEvent->HardReset(); fNUISANCEEvent->SetBranchAddress(fFitEventTree); fFitEventTree->SetBranchAddress("NParticles", &fReadNParticles); fFitEventTree->SetBranchAddress("ParticleState", &fReadParticleState); fFitEventTree->SetBranchAddress("ParticlePDG", &fReadParticlePDG); fFitEventTree->SetBranchAddress("ParticleMom", &fReadParticleMom); fFitEventTree->Show(0); fNUISANCEEvent = GetNuisanceEvent(0); std::cout << "NParticles = " << fNUISANCEEvent->Npart() << std::endl; std::cout << "Event Info " << fNUISANCEEvent->PartInfo(0)->fPID << std::endl; } FitEventInputHandler::~FitEventInputHandler() { if (fFitEventTree) delete fFitEventTree; } void FitEventInputHandler::CreateCache() { // fFitEventTree->SetCacheEntryRange(0, fNEvents); // fFitEventTree->AddBranchToCache("*", 1); // fFitEventTree->SetCacheSize(fCacheSize); } void FitEventInputHandler::RemoveCache() { // fFitEventTree->SetCacheEntryRange(0, fNEvents); // fFitEventTree->AddBranchToCache("*", 0); // fFitEventTree->SetCacheSize(0); } FitEvent *FitEventInputHandler::GetNuisanceEvent(const UInt_t entry, const bool lightweight) { // Return NULL if out of bounds if (entry >= (UInt_t)fNEvents) return NULL; // Reset all variables before tree read fNUISANCEEvent->ResetEvent(); // Read NUISANCE Tree fFitEventTree->GetEntry(entry); // Fill Stack fNUISANCEEvent->fNParticles = 0; for (int i = 0; i < fReadNParticles; i++) { size_t curpart = fNUISANCEEvent->fNParticles; fNUISANCEEvent->fParticleState[curpart] = fReadParticleState[i]; // Mom fNUISANCEEvent->fParticleMom[curpart][0] = fReadParticleMom[i][0]; fNUISANCEEvent->fParticleMom[curpart][1] = fReadParticleMom[i][1]; fNUISANCEEvent->fParticleMom[curpart][2] = fReadParticleMom[i][2]; fNUISANCEEvent->fParticleMom[curpart][3] = fReadParticleMom[i][3]; // PDG fNUISANCEEvent->fParticlePDG[curpart] = fReadParticlePDG[i]; // Add to N particle count fNUISANCEEvent->fNParticles++; } // Setup Input scaling for joint inputs fNUISANCEEvent->InputWeight = GetInputWeight(entry); return fNUISANCEEvent; } double FitEventInputHandler::GetInputWeight(int entry) { double w = InputHandlerBase::GetInputWeight(entry); return w * fNUISANCEEvent->SavedRWWeight; } void FitEventInputHandler::Print() {} diff --git a/src/InputHandler/FitEventInputHandler.h b/src/InputHandler/FitEventInputHandler.h index 0f38ce6..9a1bc60 100644 --- a/src/InputHandler/FitEventInputHandler.h +++ b/src/InputHandler/FitEventInputHandler.h @@ -1,61 +1,61 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FITEVENT_INPUTHANDLER_H #define FITEVENT_INPUTHANDLER_H /*! * \addtogroup InputHandler * @{ */ #include "InputHandler.h" #include "FitEvent.h" #include "PlotUtils.h" /// Class to read in NUISANCE FitEvents that have been saved to tree class FitEventInputHandler : public InputHandlerBase { public: /// Standard constructor given name and inputs FitEventInputHandler(std::string const& handle, std::string const& rawinputs); virtual ~FitEventInputHandler(); /// Create a TTree Cache to speed up file read void CreateCache(); /// Remove TTree Cache to save memory void RemoveCache(); /// Returns NUISANCE FitEvent from the TTree. If lightweight does nothing. FitEvent* GetNuisanceEvent(const UInt_t entry, const bool lightweight=false); /// Alongside InputWeight also returns any saved RWWeights double GetInputWeight(int entry); /// Print out event information void Print(); TChain* fFitEventTree; ///< TTree from FitEvent file. int fReadNParticles; double fReadParticleMom[400][4]; UInt_t fReadParticleState[400]; int fReadParticlePDG[400]; }; /*! @} */ #endif diff --git a/src/InputHandler/FitParticle.cxx b/src/InputHandler/FitParticle.cxx index 54b3ffb..2c9301f 100644 --- a/src/InputHandler/FitParticle.cxx +++ b/src/InputHandler/FitParticle.cxx @@ -1,53 +1,53 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitParticle.h" FitParticle::FitParticle(double x, double y, double z, double t, int pdg, Int_t state){ fP = TLorentzVector(x, y, z, t); fPID = pdg; fStatus = state; // Set status manually from switch switch(state){ case kInitialState: fIsAlive= 0; fNEUTStatusCode=1; break; // Initial State case kFinalState: fIsAlive= 1; fNEUTStatusCode=0; break; // Final State case kFSIState: fIsAlive= 0; fNEUTStatusCode=2; break; // Intermediate State default: fIsAlive=0; fNEUTStatusCode=999; break; // Other? // default: fIsAlive=-1; fNEUTStatusCode=3; break; } }; void FitParticle::SetValues(double x, double y, double z, double t, int pdg, Int_t state){ fP = TLorentzVector(x, y, z, t); fPID = pdg; fStatus = state; // Set status manually from switch switch(state){ case kInitialState: fIsAlive= 0; fNEUTStatusCode=1; break; // Initial State case kFinalState: fIsAlive= 1; fNEUTStatusCode=0; break; // Final State case kFSIState: fIsAlive= 0; fNEUTStatusCode=2; break; // Intermediate State default: fIsAlive=0; fNEUTStatusCode=999; break; // Other? // default: fIsAlive=-1; fNEUTStatusCode=3; break; } }; diff --git a/src/InputHandler/FitParticle.h b/src/InputHandler/FitParticle.h index 5141e81..5776d5e 100644 --- a/src/InputHandler/FitParticle.h +++ b/src/InputHandler/FitParticle.h @@ -1,109 +1,109 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FITPARTICLE_H_SEEN #define FITPARTICLE_H_SEEN /*! * \addtogroup InputHandler * @{ */ #include "TLorentzVector.h" /// Partle state flags for its position in the event enum particle_state{ kUndefinedState = 5, kInitialState = 0, kFSIState = 1, kFinalState = 2, kNuclearInitial = 3, kNuclearRemnant = 4, }; /// Condensed FitParticle class which acts a common format between the generators class FitParticle { public: /// Create particle of given pdg from momentum variables and state FitParticle(double x, double y, double z, double t, int pdg, Int_t state); /// Create empty particle (zero momentum) FitParticle(){}; ~FitParticle(){}; /// Used to change values after creation void SetValues(double x, double y, double z, double t, int pdg, Int_t state); /// Return Status Code according to particle_state enum inline int Status (void) const { return fStatus; }; /// Get Particle PDF inline int PDG (void) const { return fPID; }; /// Check if particle makes it to final state inline bool IsFinalState (void) const { return (fStatus == kFinalState); }; /// Was particle involved in intermediate state inline bool IsFSIState (void) const { return (fStatus == kFSIState); }; /// Was particle incoming inline bool IsInitialState (void) const { return (fStatus == kInitialState); }; /// Get Mass inline double M (void){ return fP.Mag(); }; /// Get Kinetic Energy inline double KE (void){ return fP.E() - fP.Mag(); }; /// Get Total Energy inline double E (void){ return fP.E(); }; /// Get 4 Momentum inline TLorentzVector P4(void) {return fP;}; /// Get 3 Momentum inline TVector3 P3(void) {return fP.Vect();}; /// Get 3 momentum magnitude inline double p(void) { return fP.Vect().Mag(); }; /// Get 3 momentum magnitude squared inline double p2(void) { return fP.Vect().Mag2(); }; /// Data Members TLorentzVector fP; ///< Particle 4 Momentum int fPID; ///< Particle PDG Code int fIsAlive; ///< Whether the particle is alive at the end of the event (Yes 1, No 0, Other? -1) int fNEUTStatusCode; ///< Particle Status (Incoming 1, FSI 2, Outgoing 0, Other 3) double fMass; ///< Particle Mass int fStatus; ///< State corresponding to particle_state enum bool fIsPrimary; ///< Primary target }; inline std::ostream& operator<<(std::ostream& os, FitParticle const& p){ return os << " Particle[pdgc:" << p.fPID << ", stat:"<. *******************************************************************************/ #ifdef __GENIE_ENABLED__ #include "GENIEInputHandler.h" #ifdef GENIE_PRE_R3 #include "Messenger/Messenger.h" #else #include "Framework/Messenger/Messenger.h" #endif #include "InputUtils.h" GENIEGeneratorInfo::~GENIEGeneratorInfo() { DeallocateParticleStack(); } void GENIEGeneratorInfo::AddBranchesToTree(TTree *tn) { tn->Branch("GenieParticlePDGs", &fGenieParticlePDGs, "GenieParticlePDGs/I"); } void GENIEGeneratorInfo::SetBranchesFromTree(TTree *tn) { tn->SetBranchAddress("GenieParticlePDGs", &fGenieParticlePDGs); } void GENIEGeneratorInfo::AllocateParticleStack(int stacksize) { fGenieParticlePDGs = new int[stacksize]; } void GENIEGeneratorInfo::DeallocateParticleStack() { delete fGenieParticlePDGs; } void GENIEGeneratorInfo::FillGeneratorInfo(NtpMCEventRecord *ntpl) { Reset(); // Check for GENIE Event if (!ntpl) return; if (!ntpl->event) return; // Cast Event Record GHepRecord *ghep = static_cast(ntpl->event); if (!ghep) return; // Fill Particle Stack GHepParticle *p = 0; TObjArrayIter iter(ghep); // Loop over all particles int i = 0; while ((p = (dynamic_cast((iter).Next())))) { if (!p) continue; // Get PDG fGenieParticlePDGs[i] = p->Pdg(); i++; } } void GENIEGeneratorInfo::Reset() { for (int i = 0; i < kMaxParticles; i++) { fGenieParticlePDGs[i] = 0; } } GENIEInputHandler::GENIEInputHandler(std::string const &handle, std::string const &rawinputs) { NUIS_LOG(SAM, "Creating GENIEInputHandler : " << handle); // Plz no shouting StopTalking(); genie::Messenger::Instance()->SetPriorityLevel("GHepUtils", pFATAL); StartTalking(); // Shout all you want // Run a joint input handling fName = handle; // Setup the TChain fGENIETree = new TChain("gtree"); fSaveExtra = FitPar::Config().GetParB("SaveExtraGenie"); fCacheSize = FitPar::Config().GetParI("CacheSize"); fMaxEvents = FitPar::Config().GetParI("MAXEVENTS"); // Are we running with NOvA weights fNOvAWeights = FitPar::Config().GetParB("NOvA_Weights"); MAQEw = 1.0; NonResw = 1.0; RPAQEw = 1.0; RPARESw = 1.0; MECw = 1.0; DISw = 1.0; NOVAw = 1.0; // Loop over all inputs and grab flux, eventhist, and nevents std::vector inputs = InputUtils::ParseInputFileList(rawinputs); for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { // Open File for histogram access TFile *inp_file = new TFile( InputUtils::ExpandInputDirectories(inputs[inp_it]).c_str(), "READ"); if (!inp_file or inp_file->IsZombie()) { NUIS_ABORT( "GENIE File IsZombie() at : '" << inputs[inp_it] << "'" << std::endl << "Check that your file paths are correct and the file exists!" << std::endl << "$ ls -lh " << inputs[inp_it]); } // Get Flux/Event hist TH1D *fluxhist = (TH1D *)inp_file->Get("nuisance_flux"); TH1D *eventhist = (TH1D *)inp_file->Get("nuisance_events"); if (!fluxhist or !eventhist) { NUIS_ERR(FTL, "Input File Contents: " << inputs[inp_it]); inp_file->ls(); NUIS_ABORT("GENIE FILE doesn't contain flux/xsec info." << std::endl << "Try running the app PrepareGENIE first on :" << inputs[inp_it] << std::endl << "$ PrepareGENIE -h"); } // Get N Events TTree *genietree = (TTree *)inp_file->Get("gtree"); if (!genietree) { NUIS_ERR(FTL, "gtree not located in GENIE file: " << inputs[inp_it]); NUIS_ABORT( "Check your inputs, they may need to be completely regenerated!"); } int nevents = genietree->GetEntries(); if (nevents <= 0) { NUIS_ABORT("Trying to a TTree with " << nevents << " to TChain from : " << inputs[inp_it]); } // Check for precomputed weights TTree *weighttree = (TTree *)inp_file->Get("nova_wgts"); if (fNOvAWeights) { if (!weighttree) { NUIS_ABORT("Did not find nova_wgts tree in file " << inputs[inp_it] << " but you specified it" << std::endl); } else { NUIS_LOG(FIT, "Found nova_wgts tree in file " << inputs[inp_it]); } } // Register input to form flux/event rate hists RegisterJointInput(inputs[inp_it], nevents, fluxhist, eventhist); // Add To TChain fGENIETree->AddFile(inputs[inp_it].c_str()); if (weighttree != NULL) fGENIETree->AddFriend(weighttree); } // Registor all our file inputs SetupJointInputs(); // Assign to tree fEventType = kGENIE; fGenieNtpl = NULL; fGENIETree->SetBranchAddress("gmcrec", &fGenieNtpl); // Set up the custom weights if (fNOvAWeights) { fGENIETree->SetBranchAddress("MAQEwgt", &MAQEw); fGENIETree->SetBranchAddress("nonResNormWgt", &NonResw); fGENIETree->SetBranchAddress("RPAQEWgt", &RPAQEw); fGENIETree->SetBranchAddress("RPARESWgt", &RPARESw); fGENIETree->SetBranchAddress("MECWgt", &MECw); fGENIETree->SetBranchAddress("DISWgt", &DISw); fGENIETree->SetBranchAddress("nova2018CVWgt", &NOVAw); } // Libraries should be seen but not heard... StopTalking(); fGENIETree->GetEntry(0); StartTalking(); // Create Fit Event fNUISANCEEvent = new FitEvent(); fNUISANCEEvent->SetGenieEvent(fGenieNtpl); if (fSaveExtra) { fGenieInfo = new GENIEGeneratorInfo(); fNUISANCEEvent->AddGeneratorInfo(fGenieInfo); } fNUISANCEEvent->HardReset(); }; GENIEInputHandler::~GENIEInputHandler() { // if (fGenieGHep) delete fGenieGHep; // if (fGenieNtpl) delete fGenieNtpl; // if (fGENIETree) delete fGENIETree; // if (fGenieInfo) delete fGenieInfo; } void GENIEInputHandler::CreateCache() { if (fCacheSize > 0) { // fGENIETree->SetCacheEntryRange(0, fNEvents); fGENIETree->AddBranchToCache("*", 1); fGENIETree->SetCacheSize(fCacheSize); } } void GENIEInputHandler::RemoveCache() { // fGENIETree->SetCacheEntryRange(0, fNEvents); fGENIETree->AddBranchToCache("*", 0); fGENIETree->SetCacheSize(0); } FitEvent *GENIEInputHandler::GetNuisanceEvent(const UInt_t ent, const bool lightweight) { UInt_t entry = ent + fSkip; if (entry >= (UInt_t)fNEvents) return NULL; // Clear the previous event (See Note 1 in ROOT TClonesArray documentation) if (fGenieNtpl) { fGenieNtpl->Clear(); } // Read Entry from TTree to fill NEUT Vect in BaseFitEvt; fGENIETree->GetEntry(entry); // Run NUISANCE Vector Filler if (!lightweight) { CalcNUISANCEKinematics(); } #ifdef __PROB3PP_ENABLED__ else { // Check for GENIE Event if (!fGenieNtpl) return NULL; if (!fGenieNtpl->event) return NULL; // Cast Event Record fGenieGHep = static_cast(fGenieNtpl->event); if (!fGenieGHep) return NULL; TObjArrayIter iter(fGenieGHep); genie::GHepParticle *p; while ((p = (dynamic_cast((iter).Next())))) { if (!p) { continue; } // Get Status int state = GetGENIEParticleStatus(p, fNUISANCEEvent->Mode); if (state != genie::kIStInitialState) { continue; } fNUISANCEEvent->probe_E = p->E() * 1.E3; fNUISANCEEvent->probe_pdg = p->Pdg(); break; } } #endif // Setup Input scaling for joint inputs fNUISANCEEvent->InputWeight = GetInputWeight(entry); return fNUISANCEEvent; } int GENIEInputHandler::GetGENIEParticleStatus(genie::GHepParticle *p, int mode) { /* 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 */ 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(mode) == 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; } return state; } #endif #ifdef __GENIE_ENABLED__ int GENIEInputHandler::ConvertGENIEReactionCode(GHepRecord *gheprec) { // I randomly picked 53 here because NEUT doesn't have an appropriate mode... if (gheprec->Summary()->ProcInfo().IsNuElectronElastic()){ if (pdg::IsNeutrino(gheprec->Summary()->InitState().ProbePdg())) return 53; else return -53; } // And the same story for 54 if (gheprec->Summary()->ProcInfo().IsIMDAnnihilation()){ if (pdg::IsNeutrino(gheprec->Summary()->InitState().ProbePdg())) return 54; else return -54; } // Electron Scattering if (gheprec->Summary()->ProcInfo().IsEM()) { if (gheprec->Summary()->InitState().ProbePdg() == 11) { if (gheprec->Summary()->ProcInfo().IsQuasiElastic()) return 1; else if (gheprec->Summary()->ProcInfo().IsMEC()) return 2; else if (gheprec->Summary()->ProcInfo().IsResonant()) return 13; else if (gheprec->Summary()->ProcInfo().IsDeepInelastic()) return 26; else { NUIS_ERR(WRN, "Unknown GENIE Electron Scattering Mode!" << std::endl << "ScatteringTypeId = " << gheprec->Summary()->ProcInfo().ScatteringTypeId() << " " << "InteractionTypeId = " << gheprec->Summary()->ProcInfo().InteractionTypeId() << std::endl << genie::ScatteringType::AsString( gheprec->Summary()->ProcInfo().ScatteringTypeId()) << " " << genie::InteractionType::AsString( gheprec->Summary()->ProcInfo().InteractionTypeId()) << " " << gheprec->Summary()->ProcInfo().IsMEC()); return 0; } } // Weak CC } else if (gheprec->Summary()->ProcInfo().IsWeakCC()) { // CC MEC if (gheprec->Summary()->ProcInfo().IsMEC()) { if (pdg::IsNeutrino(gheprec->Summary()->InitState().ProbePdg())) return 2; else if (pdg::IsAntiNeutrino(gheprec->Summary()->InitState().ProbePdg())) return -2; #ifndef GENIE_PRE_R3 } else if (gheprec->Summary()->ProcInfo().IsDiffractive()) { if (pdg::IsNeutrino(gheprec->Summary()->InitState().ProbePdg())) return 15; else if (pdg::IsAntiNeutrino(gheprec->Summary()->InitState().ProbePdg())) return -15; #endif // CC OTHER } else { return utils::ghep::NeutReactionCode(gheprec); } // Weak NC } else if (gheprec->Summary()->ProcInfo().IsWeakNC()) { // NC MEC if (gheprec->Summary()->ProcInfo().IsMEC()) { if (pdg::IsNeutrino(gheprec->Summary()->InitState().ProbePdg())) return 32; else if (pdg::IsAntiNeutrino(gheprec->Summary()->InitState().ProbePdg())) return -32; #ifndef GENIE_PRE_R3 } else if (gheprec->Summary()->ProcInfo().IsDiffractive()) { if (pdg::IsNeutrino(gheprec->Summary()->InitState().ProbePdg())) return 35; else if (pdg::IsAntiNeutrino(gheprec->Summary()->InitState().ProbePdg())) return -35; #endif // NC OTHER } else { return utils::ghep::NeutReactionCode(gheprec); } } return 0; } void GENIEInputHandler::CalcNUISANCEKinematics() { // Reset all variables fNUISANCEEvent->ResetEvent(); // Check for GENIE Event if (!fGenieNtpl) return; if (!fGenieNtpl->event) return; // Cast Event Record fGenieGHep = static_cast(fGenieNtpl->event); if (!fGenieGHep) return; // Convert GENIE Reaction Code fNUISANCEEvent->Mode = ConvertGENIEReactionCode(fGenieGHep); if (!fNUISANCEEvent->Mode) { - std::cout << "[WARN]: Failed to determine mode for GENIE event: " - << *fGenieGHep << std::endl; + NUIS_ERR(WRN, "Failed to determine mode for GENIE event: "); + std::cout << *fGenieGHep << std::endl; } // Set Event Info fNUISANCEEvent->fEventNo = 0.0; fNUISANCEEvent->fTotCrs = fGenieGHep->XSec(); // Have a bool storing if interaction happened on free or bound nucleon bool IsFree = false; // Set the TargetPDG if (fGenieGHep->TargetNucleus() != NULL) { fNUISANCEEvent->fTargetPDG = fGenieGHep->TargetNucleus()->Pdg(); IsFree = false; // Sometimes GENIE scatters off free nucleons, electrons, photons // In which TargetNucleus is NULL and we need to find the initial state // particle } else { // Check the particle is an initial state particle // Follows GHepRecord::TargetNucleusPosition but doesn't do check on // pdg::IsIon GHepParticle *p = fGenieGHep->Particle(1); // Check that particle 1 actually exists if (!p) { NUIS_ABORT("Can't find particle 1 for GHepRecord"); } // If not an ion but is an initial state particle if (!pdg::IsIon(p->Pdg()) && p->Status() == kIStInitialState) { IsFree = true; fNUISANCEEvent->fTargetPDG = p->Pdg(); // Catch if something strange happens: // Here particle 1 is not an initial state particle OR // particle 1 is an ion OR // both } else { if (pdg::IsIon(p->Pdg())) { NUIS_ABORT( "Particle 1 in GHepRecord stack is an ion but isn't an initial " "state particle"); } else { NUIS_ABORT( "Particle 1 in GHepRecord stack is not an ion but is an initial " "state particle"); } } } // Set the A and Z and H from the target PDG // Depends on if we scattered off a free or bound nucleon if (!IsFree) { fNUISANCEEvent->fTargetA = TargetUtils::GetTargetAFromPDG(fNUISANCEEvent->fTargetPDG); fNUISANCEEvent->fTargetZ = TargetUtils::GetTargetZFromPDG(fNUISANCEEvent->fTargetPDG); fNUISANCEEvent->fTargetH = 0; } else { // If free proton scattering if (fNUISANCEEvent->fTargetPDG == 2212) { fNUISANCEEvent->fTargetA = 1; fNUISANCEEvent->fTargetZ = 1; fNUISANCEEvent->fTargetH = 1; // If free neutron scattering } else if (fNUISANCEEvent->fTargetPDG == 2112) { fNUISANCEEvent->fTargetA = 0; fNUISANCEEvent->fTargetZ = 1; fNUISANCEEvent->fTargetH = 0; // If neither } else { fNUISANCEEvent->fTargetA = 0; fNUISANCEEvent->fTargetZ = 0; fNUISANCEEvent->fTargetH = 0; } } fNUISANCEEvent->fBound = !IsFree; fNUISANCEEvent->InputWeight = 1.0; //(1E+38 / genie::units::cm2) * fGenieGHep->XSec(); // And the custom weights if (fNOvAWeights) { fNUISANCEEvent->CustomWeight = NOVAw; fNUISANCEEvent->CustomWeightArray[0] = MAQEw; fNUISANCEEvent->CustomWeightArray[1] = NonResw; fNUISANCEEvent->CustomWeightArray[2] = RPAQEw; fNUISANCEEvent->CustomWeightArray[3] = RPARESw; fNUISANCEEvent->CustomWeightArray[4] = MECw; fNUISANCEEvent->CustomWeightArray[5] = NOVAw; } else { fNUISANCEEvent->CustomWeight = 1.0; fNUISANCEEvent->CustomWeightArray[0] = 1.0; fNUISANCEEvent->CustomWeightArray[1] = 1.0; fNUISANCEEvent->CustomWeightArray[2] = 1.0; fNUISANCEEvent->CustomWeightArray[3] = 1.0; fNUISANCEEvent->CustomWeightArray[4] = 1.0; fNUISANCEEvent->CustomWeightArray[5] = 1.0; } // Get N Particle Stack unsigned int npart = fGenieGHep->GetEntries(); unsigned int kmax = fNUISANCEEvent->kMaxParticles; if (npart > kmax) { NUIS_ERR(WRN, "GENIE has too many particles, expanding stack."); fNUISANCEEvent->ExpandParticleStack(npart); } // Fill Particle Stack GHepParticle *p = 0; TObjArrayIter iter(fGenieGHep); fNUISANCEEvent->fNParticles = 0; // Loop over all particles while ((p = (dynamic_cast((iter).Next())))) { if (!p) continue; // Get Status int state = GetGENIEParticleStatus(p, fNUISANCEEvent->Mode); // Remove Undefined if (kRemoveUndefParticles && state == kUndefinedState) continue; // Remove FSI if (kRemoveFSIParticles && state == kFSIState) continue; if (kRemoveNuclearParticles && (state == kNuclearInitial || state == kNuclearRemnant)) continue; // Fill Vectors int curpart = fNUISANCEEvent->fNParticles; fNUISANCEEvent->fParticleState[curpart] = state; // Mom fNUISANCEEvent->fParticleMom[curpart][0] = p->Px() * 1.E3; fNUISANCEEvent->fParticleMom[curpart][1] = p->Py() * 1.E3; fNUISANCEEvent->fParticleMom[curpart][2] = p->Pz() * 1.E3; fNUISANCEEvent->fParticleMom[curpart][3] = p->E() * 1.E3; // PDG fNUISANCEEvent->fParticlePDG[curpart] = p->Pdg(); // Set if the particle was on the fundamental vertex fNUISANCEEvent->fPrimaryVertex[curpart] = (p->FirstMother() < 2); // Add to N particle count fNUISANCEEvent->fNParticles++; // Extra Check incase GENIE fails. if ((UInt_t)fNUISANCEEvent->fNParticles == kmax) { NUIS_ERR(WRN, "Number of GENIE Particles exceeds maximum!"); NUIS_ERR(WRN, "Extend kMax, or run without including FSI particles!"); break; } } // Fill Extra Stack if (fSaveExtra) fGenieInfo->FillGeneratorInfo(fGenieNtpl); // Run Initial, FSI, Final, Other ordering. fNUISANCEEvent->OrderStack(); FitParticle *ISAnyLepton = fNUISANCEEvent->GetHMISAnyLeptons(); if (ISAnyLepton) { fNUISANCEEvent->probe_E = ISAnyLepton->E(); fNUISANCEEvent->probe_pdg = ISAnyLepton->PDG(); } return; } void GENIEInputHandler::Print() {} #endif diff --git a/src/InputHandler/GENIEInputHandler.h b/src/InputHandler/GENIEInputHandler.h index 16a7092..a09cda0 100644 --- a/src/InputHandler/GENIEInputHandler.h +++ b/src/InputHandler/GENIEInputHandler.h @@ -1,130 +1,130 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GENIEINPUTHANDLER_H #define GENIEINPUTHANDLER_H /*! * \addtogroup InputHandler * @{ */ #ifdef __GENIE_ENABLED__ #include "InputHandler.h" #include "InputUtils.h" #include "PlotUtils.h" #ifdef GENIE_PRE_R3 #include "GHEP/GHepParticle.h" #include "PDG/PDGUtils.h" #include "GHEP/GHepUtils.h" #include "Conventions/Units.h" #include "EVGCore/EventRecord.h" #include "GHEP/GHepRecord.h" #include "Ntuple/NtpMCEventRecord.h" #else #include "Framework/GHEP/GHepParticle.h" #include "Framework/ParticleData/PDGUtils.h" #include "Framework/GHEP/GHepUtils.h" #include "Framework/Conventions/Units.h" #include "Framework/EventGen/EventRecord.h" #include "Framework/GHEP/GHepRecord.h" #include "Framework/Ntuple/NtpMCEventRecord.h" #endif using namespace genie; /// GENIE Generator Container to save extra particle status codes. class GENIEGeneratorInfo : public GeneratorInfoBase { public: GENIEGeneratorInfo() {}; virtual ~GENIEGeneratorInfo(); /// Assigns information to branches void AddBranchesToTree(TTree* tn); /// Setup reading information from branches void SetBranchesFromTree(TTree* tn); /// Allocate any dynamic arrays for a new particle stack size void AllocateParticleStack(int stacksize); /// Clear any dynamic arrays void DeallocateParticleStack(); /// Read extra genie information from the event void FillGeneratorInfo(NtpMCEventRecord* ntpl); /// Reset extra information to default/empty values void Reset(); int kMaxParticles; ///< Number of particles in stack int* fGenieParticlePDGs; ///< GENIE Particle PDGs (example) }; /// Main GENIE InputHandler class GENIEInputHandler : public InputHandlerBase { public: /// Standard constructor given a name and input files GENIEInputHandler(std::string const& handle, std::string const& rawinputs); virtual ~GENIEInputHandler(); /// Create a TTree Cache to speed up file read void CreateCache(); /// Remove TTree Cache to save memory void RemoveCache(); /// Returns a NUISANCE format event from the GENIE TTree. If !lightweight /// then CalcNUISANCEKinematics() is called to convert the GENIE event into /// a standard NUISANCE format. FitEvent* GetNuisanceEvent(const UInt_t entry, const bool lightweight = false); /// Converts GENIE event into standard NUISANCE FitEvent by looping over all /// particles in the event and adding them to stack in fNUISANCEEvent. void CalcNUISANCEKinematics(); /// Placeholder for GENIE related event printing. void Print(); /// Converts GENIE particle status codes into NUISANCE status codes. int GetGENIEParticleStatus(genie::GHepParticle* part, int mode = 0); /// Converts GENIE event reaction codes into NUISANCE reaction codes. int ConvertGENIEReactionCode(GHepRecord* gheprec); GHepRecord* fGenieGHep; ///< Pointer to actual event record NtpMCEventRecord* fGenieNtpl; ///< Ntpl Wrapper Class TChain* fGENIETree; ///< Main GENIE Event TTree bool fSaveExtra; ///< Flag to save Extra GENIE info into Nuisance Event GENIEGeneratorInfo* fGenieInfo; ///< Extra GENIE Generator Info Writer bool fNOvAWeights; ///< Flag to save nova weights or not // Extra weights from Jeremy for NOvA weights double MAQEw; double NonResw; double RPAQEw; double RPARESw; double MECw; double DISw; double NOVAw; }; /*! @} */ #endif #endif diff --git a/src/InputHandler/GeneratorInfoBase.h b/src/InputHandler/GeneratorInfoBase.h index 4623916..c0c67c7 100644 --- a/src/InputHandler/GeneratorInfoBase.h +++ b/src/InputHandler/GeneratorInfoBase.h @@ -1,39 +1,39 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GENERATOR_INFO_BASE_SEEN_H #define GENERATOR_INFO_BASE_SEEN_H /*! * \addtogroup InputHandler * @{ */ /// Base Box object that allows user to save extra generator level info /// by overriding functions. For an example see GENIEGeneratorInfo class GeneratorInfoBase { public: inline GeneratorInfoBase(){}; inline virtual ~GeneratorInfoBase(){}; inline virtual void AddBranchesToTree(TTree* tn){}; inline virtual void SetBranchesFromTree(TTree* tn){}; inline virtual void AllocateParticleStack(int stacksize){}; inline virtual void DeallocateParticleStack(){}; inline virtual void Reset(){}; }; /*! @} */ #endif diff --git a/src/InputHandler/GeneratorUtils.cxx b/src/InputHandler/GeneratorUtils.cxx index 7e06b62..7279a8f 100644 --- a/src/InputHandler/GeneratorUtils.cxx +++ b/src/InputHandler/GeneratorUtils.cxx @@ -1,60 +1,60 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include #include "GeneratorUtils.h" #include "FitLogger.h" #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ // niwg::rew::NIWGEvent * GeneratorUtils::GetNIWGEventLocal(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; ipNpart(); ++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 #endif diff --git a/src/InputHandler/GeneratorUtils.h b/src/InputHandler/GeneratorUtils.h index c6f809f..18a9493 100644 --- a/src/InputHandler/GeneratorUtils.h +++ b/src/InputHandler/GeneratorUtils.h @@ -1,74 +1,74 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GENERATOR_UTILS_H #define GENERATOR_UTILS_H /*! * \addtogroup InputHandler * @{ */ #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ #include "NIWGEvent.h" #include "NIWGSyst.h" #include "InputHandler.h" #include "TargetUtils.h" #include "TTreePerfStats.h" #include "PlotUtils.h" /* #include "neutpart.h" #include "neutvect.h" #include "nefillverC.h" #include "necardC.h" #include "neutmodelC.h" #include "neutparamsC.h" #include "neworkC.h" #include "fsihistC.h" #include "neutcrsC.h" #include "neutvect.h" #include "neutpart.h" #include "neutfsipart.h" #include "neutfsivert.h" #include "neutrootTreeSingleton.h" #include "NModeDefn.h" #include "NSyst.h" #include "NFortFns.h" // Contains all the NEUT common blocks #ifdef __NEUT_NUCFSI_ENABLED__ #include "nucleonfsihistC.h" #include "neutnucfsivert.h" #include "neutnucfsistep.h" #endif */ #include "neutvect.h" #endif #endif // namespace GeneratorUtils { // #ifdef __NIWG_ENABLED__ // #ifdef __NEUT_ENABLED__ // niwg::rew::NIWGEvent* GetNIWGEventLocal(NeutVect* nvect); // #endif // #endif // }; /*! @} */ #endif diff --git a/src/InputHandler/InputFactory.cxx b/src/InputHandler/InputFactory.cxx index 794edf6..f55676b 100644 --- a/src/InputHandler/InputFactory.cxx +++ b/src/InputHandler/InputFactory.cxx @@ -1,122 +1,122 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitEventInputHandler.h" #include "GENIEInputHandler.h" #include "GIBUUInputHandler.h" #include "HistogramInputHandler.h" #include "NEUTInputHandler.h" #include "NUANCEInputHandler.h" #include "NuWroInputHandler.h" #include "SigmaQ0HistogramInputHandler.h" #include "SplineInputHandler.h" #include "InputFactory.h" #include "TFile.h" namespace InputUtils { InputHandlerBase *CreateInputHandler(std::string const &handle, InputUtils::InputType inpType, std::string const &inputs) { InputHandlerBase *input = NULL; std::string newinputs = InputUtils::ExpandInputDirectories(inputs); switch (inpType) { case (kNEUT_Input): #ifdef __NEUT_ENABLED__ input = new NEUTInputHandler(handle, newinputs); #else NUIS_ERR(FTL, "Tried to create NEUTInputHandler : " << handle << " " << inpType << " " << inputs); NUIS_ABORT("NEUT is not enabled!"); #endif break; case (kGENIE_Input): #ifdef __GENIE_ENABLED__ input = new GENIEInputHandler(handle, newinputs); #else NUIS_ERR(FTL, "Tried to create GENIEInputHandler : " << handle << " " << inpType << " " << inputs); NUIS_ABORT("GENIE is not enabled!"); #endif break; case (kNUWRO_Input): #ifdef __NUWRO_ENABLED__ input = new NuWroInputHandler(handle, newinputs); #else NUIS_ERR(FTL, "Tried to create NuWroInputHandler : " << handle << " " << inpType << " " << inputs); NUIS_ABORT("NuWro is not enabled!"); #endif break; case (kGiBUU_Input): #ifdef __GiBUU_ENABLED__ input = new GIBUUInputHandler(handle, newinputs); #else NUIS_ERR(FTL, "Tried to create GiBUUInputHandler : " << handle << " " << inpType << " " << inputs); NUIS_ABORT("GiBUU is not enabled!"); #endif break; case (kNUANCE_Input): #ifdef __NUANCE_ENABLED__ input = new NUANCEInputHandler(handle, newinputs); #else NUIS_ERR(FTL, "Tried to create NUANCEInputHandler : " << handle << " " << inpType << " " << inputs); NUIS_ABORT("NUANCE is not enabled!"); #endif break; case (kFEVENT_Input): input = new FitEventInputHandler(handle, newinputs); break; case (kEVSPLN_Input): input = new SplineInputHandler(handle, newinputs); break; case (kSIGMAQ0HIST_Input): input = new SigmaQ0HistogramInputHandler(handle, newinputs); break; case (kHISTO_Input): input = new HistoInputHandler(handle, newinputs); break; default: break; } /// Input failed if (!input) { NUIS_ABORT("Input handler creation failed!" << std::endl << "Generator Type " << inpType << " not enabled!"); } return input; }; } // namespace InputUtils diff --git a/src/InputHandler/InputFactory.h b/src/InputHandler/InputFactory.h index b06d5ad..f16d768 100644 --- a/src/InputHandler/InputFactory.h +++ b/src/InputHandler/InputFactory.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef INPUT_FACTORY_H #define INPUT_FACTORY_H #include #include "InputUtils.h" #include "InputHandler.h" namespace InputUtils { InputHandlerBase* CreateInputHandler(std::string const& handle, InputUtils::InputType inpType, std::string const& inputs); } #endif diff --git a/src/InputHandler/InputHandler.cxx b/src/InputHandler/InputHandler.cxx index e65591f..6ecd963 100644 --- a/src/InputHandler/InputHandler.cxx +++ b/src/InputHandler/InputHandler.cxx @@ -1,305 +1,299 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "InputHandler.h" #include "InputUtils.h" InputHandlerBase::InputHandlerBase() { fName = ""; fFluxHist = NULL; fEventHist = NULL; fNEvents = 0; fNUISANCEEvent = NULL; fBaseEvent = NULL; kRemoveUndefParticles = FitPar::Config().GetParB("RemoveUndefParticles"); kRemoveFSIParticles = FitPar::Config().GetParB("RemoveFSIParticles"); kRemoveNuclearParticles = FitPar::Config().GetParB("RemoveNuclearParticles"); fMaxEvents = FitPar::Config().GetParI("MAXEVENTS"); fTTreePerformance = NULL; fSkip = 0; if (FitPar::Config().HasConfig("NSKIPEVENTS")) { fSkip = FitPar::Config().GetParI("NSKIPEVENTS"); } }; InputHandlerBase::~InputHandlerBase() { if (fFluxHist) delete fFluxHist; if (fEventHist) delete fEventHist; // if (fXSecHist) delete fXSecHist; // if (fNUISANCEEvent) delete fNUISANCEEvent; jointfluxinputs.clear(); jointeventinputs.clear(); jointindexlow.clear(); jointindexhigh.clear(); jointindexallowed.clear(); jointindexscale.clear(); // if (fTTreePerformance) { // fTTreePerformance->SaveAs(("ttreeperfstats_" + fName + // ".root").c_str()); // } } void InputHandlerBase::Print(){}; TH1D *InputHandlerBase::GetXSecHistogram(void) { fXSecHist = (TH1D *)fEventHist->Clone(); fXSecHist->SetNameTitle((fName + "_XSEC").c_str(), (fName + "_XSEC").c_str()); fXSecHist->GetYaxis()->SetTitle("#sigma #times 10^{-38} (cm^{2}/nucleon)"); fXSecHist->Divide(fFluxHist); return fXSecHist; }; double InputHandlerBase::PredictedEventRate(double low, double high, std::string intOpt) { Int_t minBin = fEventHist->GetXaxis()->FindFixBin(low); Int_t maxBin = fEventHist->GetXaxis()->FindFixBin(high); if ((fEventHist->IsBinOverflow(minBin) && (low != -9999.9))) { minBin = 1; } if ((fEventHist->IsBinOverflow(maxBin) && (high != -9999.9))) { maxBin = fEventHist->GetXaxis()->GetNbins() + 1; } // If we are within a single bin if (minBin == maxBin) { // Get the contained fraction of the single bin's width return ((high - low) / fEventHist->GetXaxis()->GetBinWidth(minBin)) * fEventHist->Integral(minBin, minBin, intOpt.c_str()); } double lowBinUpEdge = fEventHist->GetXaxis()->GetBinUpEdge(minBin); double highBinLowEdge = fEventHist->GetXaxis()->GetBinLowEdge(maxBin); double lowBinfracIntegral = ((lowBinUpEdge - low) / fEventHist->GetXaxis()->GetBinWidth(minBin)) * fEventHist->Integral(minBin, minBin, intOpt.c_str()); double highBinfracIntegral = ((high - highBinLowEdge) / fEventHist->GetXaxis()->GetBinWidth(maxBin)) * fEventHist->Integral(maxBin, maxBin, intOpt.c_str()); // If they are neighbouring bins if ((minBin + 1) == maxBin) { std::cout << "Get lowfrac + highfrac" << std::endl; // Get the contained fraction of the two bin's width return lowBinfracIntegral + highBinfracIntegral; } double ContainedIntegral = fEventHist->Integral(minBin + 1, maxBin - 1, intOpt.c_str()); // If there are filled bins between them return lowBinfracIntegral + highBinfracIntegral + ContainedIntegral; }; double InputHandlerBase::TotalIntegratedFlux(double low, double high, std::string intOpt) { Int_t minBin = fFluxHist->GetXaxis()->FindFixBin(low); Int_t maxBin = fFluxHist->GetXaxis()->FindFixBin(high); if ((fFluxHist->IsBinOverflow(minBin) && (low != -9999.9))) { minBin = 1; } if ((fFluxHist->IsBinOverflow(maxBin) && (high != -9999.9))) { maxBin = fFluxHist->GetXaxis()->GetNbins(); high = fFluxHist->GetXaxis()->GetBinLowEdge(maxBin + 1); } // 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) { std::cout << "Get lowfrac + highfrac" << std::endl; // Get the contained fraction of the two bin's width return lowBinfracIntegral + highBinfracIntegral; } double ContainedIntegral = fFluxHist->Integral(minBin + 1, maxBin - 1, intOpt.c_str()); // If there are filled bins between them return lowBinfracIntegral + highBinfracIntegral + ContainedIntegral; } std::vector InputHandlerBase::GetFluxList(void) { return std::vector(1, fFluxHist); }; std::vector InputHandlerBase::GetEventList(void) { return std::vector(1, fEventHist); }; std::vector InputHandlerBase::GetXSecList(void) { return std::vector(1, GetXSecHistogram()); }; FitEvent *InputHandlerBase::FirstNuisanceEvent() { fCurrentIndex = 0; return GetNuisanceEvent(fCurrentIndex); }; FitEvent *InputHandlerBase::NextNuisanceEvent() { fCurrentIndex++; if ((fMaxEvents != -1) && (fCurrentIndex > fMaxEvents)) { return NULL; } return GetNuisanceEvent(fCurrentIndex); }; BaseFitEvt *InputHandlerBase::FirstBaseEvent() { fCurrentIndex = 0; return GetBaseEvent(fCurrentIndex); }; BaseFitEvt *InputHandlerBase::NextBaseEvent() { fCurrentIndex++; if (jointinput and fMaxEvents != -1) { while (fCurrentIndex < jointindexlow[jointindexswitch] || fCurrentIndex >= jointindexhigh[jointindexswitch]) { jointindexswitch++; // Loop Around if (jointindexswitch == jointindexlow.size()) { jointindexswitch = 0; } } if (fCurrentIndex > jointindexlow[jointindexswitch] + jointindexallowed[jointindexswitch]) { fCurrentIndex = jointindexlow[jointindexswitch]; } } return GetBaseEvent(fCurrentIndex); }; void InputHandlerBase::RegisterJointInput(std::string input, int n, TH1D *f, TH1D *e) { if (jointfluxinputs.size() == 0) { jointindexswitch = 0; fNEvents = 0; } // Push into individual input vectors jointfluxinputs.push_back((TH1D *)f->Clone()); jointeventinputs.push_back((TH1D *)e->Clone()); jointindexlow.push_back(fNEvents); jointindexhigh.push_back(fNEvents + n); fNEvents += n; // Add to the total flux/event hist if (!fFluxHist) fFluxHist = (TH1D *)f->Clone(); else fFluxHist->Add(f); if (!fEventHist) fEventHist = (TH1D *)e->Clone(); else fEventHist->Add(e); } void InputHandlerBase::SetupJointInputs() { if (jointeventinputs.size() <= 1) { jointinput = false; } else if (jointeventinputs.size() > 1) { jointinput = true; jointindexswitch = 0; } fMaxEvents = FitPar::Config().GetParI("MAXEVENTS"); if (fMaxEvents != -1 and jointeventinputs.size() > 1) { NUIS_ABORT("Can only handle joint inputs when config MAXEVENTS = -1!"); } for (size_t i = 0; i < jointeventinputs.size(); i++) { double scale = double(fNEvents) / fEventHist->Integral("width"); scale *= jointeventinputs.at(i)->Integral("width"); scale /= double(jointindexhigh[i] - jointindexlow[i]); jointindexscale.push_back(scale); } fEventHist->SetNameTitle((fName + "_EVT").c_str(), (fName + "_EVT").c_str()); fFluxHist->SetNameTitle((fName + "_FLUX").c_str(), (fName + "_FLUX").c_str()); // Setup Max Events if (fMaxEvents > 1 && fMaxEvents < fNEvents) { - if (LOG_LEVEL(SAM)) { - std::cout << "\t\t|-> Read Max Entries : " << fMaxEvents << std::endl; - } + NUIS_LOG(SAM, "|-> Read max entries: " << fMaxEvents); fNEvents = fMaxEvents; } // Print out Status - if (LOG_LEVEL(SAM)) { - std::cout << "\t\t|-> Total Entries : " << fNEvents << std::endl - << "\t\t|-> Event Integral : " - << fEventHist->Integral("width") * 1.E-38 << " events/nucleon" - << std::endl - << "\t\t|-> Flux Integral : " << fFluxHist->Integral("width") - << " /cm2" << std::endl - << "\t\t|-> Event/Flux : " - << fEventHist->Integral("width") * 1.E-38 / - fFluxHist->Integral("width") - << " cm2/nucleon" << std::endl; - } + NUIS_LOG(SAM, "|-> Total entries : " << fNEvents); + NUIS_LOG(SAM, "|-> Event integral : " << fEventHist->Integral("width") * 1.E-38 + << " events/nucleon"); + NUIS_LOG(SAM, "|-> Flux Integral : " << fFluxHist->Integral("width") + << " /cm2"); + NUIS_LOG(SAM, "|-> Event/Flux : " + << fEventHist->Integral("width") * 1.E-38/fFluxHist->Integral("width") + << " cm2/nucleon"); } BaseFitEvt *InputHandlerBase::GetBaseEvent(const UInt_t entry) { // Do some light processing: don't calculate the kinematics return static_cast(GetNuisanceEvent(entry, true)); } double InputHandlerBase::GetInputWeight(int entry) { if (!jointinput) return 1.0; // Find Switch Scale while (entry < jointindexlow[jointindexswitch] || entry >= jointindexhigh[jointindexswitch]) { jointindexswitch++; // Loop Around if (jointindexswitch >= jointindexlow.size()) { jointindexswitch = 0; } } return jointindexscale[jointindexswitch]; }; diff --git a/src/InputHandler/InputHandler.h b/src/InputHandler/InputHandler.h index c696840..2d94e41 100644 --- a/src/InputHandler/InputHandler.h +++ b/src/InputHandler/InputHandler.h @@ -1,135 +1,135 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef INPUTHANDLER2_H #define INPUTHANDLER2_H /*! * \addtogroup InputHandler * @{ */ #include "BaseFitEvt.h" #include "FitEvent.h" #include "TH1D.h" #include "TTreePerfStats.h" /// Base InputHandler class defining how events are requested and setup. class InputHandlerBase { public: /// Base constructor resets everything to default InputHandlerBase(); /// Removes flux/event rate histograms virtual ~InputHandlerBase(); /// Return NUISANCE FitEvent Class from given event entry. /// Must be overriden by GeneratorInputHandler. Lightweight allows a faster /// option to be given where only RW information is needed. virtual FitEvent *GetNuisanceEvent(const UInt_t entry, const bool lightweight = false) = 0; /// Calls GetNuisanceEvent(entry, TRUE); virtual BaseFitEvt *GetBaseEvent(const UInt_t entry); /// Print current event information virtual void Print(); /// Return handler ID inline std::string GetName(void) { return fName; }; /// Return Handler Event Type Index inline int GetType(void) { return fEventType; }; /// Get Total Number of Events being Handled inline virtual int GetNEvents(void) { return std::max(fNEvents - fSkip, 0); }; /// Get the Total Flux Histogram these events were generated with inline virtual TH1D *GetFluxHistogram(void) { return fFluxHist; }; /// Get the Total Event Histogram these events were generated with inline virtual TH1D *GetEventHistogram(void) { return fEventHist; }; /// Get the Total Cross-section Histogram (EventHist/FluxHist) virtual TH1D *GetXSecHistogram(void); /// Return all Flux Histograms for all InputFiles. virtual std::vector GetFluxList(void); /// Return all Event Histograms for all InputFiles virtual std::vector GetEventList(void); /// Return all Xsec Histograms for all InputFiles virtual std::vector GetXSecList(void); /// Placeholder to create a cache to speed up reads in GeneratorInputHandler inline virtual void CreateCache(){}; /// Placeholder to remove optional cache to free up memory inline virtual void RemoveCache(){}; /// Return starting NUISANCE event pointer (entry=0) FitEvent *FirstNuisanceEvent(); /// Iterate to next NUISANCE event. Returns NULL when entry > fNEvents. FitEvent *NextNuisanceEvent(); /// Returns starting Base Event Pointer (entry=0) BaseFitEvt *FirstBaseEvent(); /// Iterate to next NUISANCE Base Event. Returns NULL when entry > fNEvents. BaseFitEvt *NextBaseEvent(); /// Register an input file and update event/flux information virtual void RegisterJointInput(std::string input, int n, TH1D *f, TH1D *e); /// Finalise setup of Input event/flux information and calculate /// joint input weights if joint input is provided. virtual void SetupJointInputs(); /// Calculate a weight for the event given the joint input information. /// Used to scale the relative proportion of multiple inputs correctly /// with respect to one another. virtual double GetInputWeight(int entry); /// Returns the total predicted event rate for this input given the /// low and high energy ranges. intOpt specifies the option the ROOT /// TH1D integral should use. e.g. "" or "width" double PredictedEventRate(double low = -9999.9, double high = -9999.9, std::string intOpt = ""); /// Returns the total generated flux for this input given the /// low and high energy ranges. intOpt specifies the option the ROOT /// TH1D integral should use. e.g. "" or "width" double TotalIntegratedFlux(double low = -9999.9, double high = -9999.9, std::string intOpt = ""); /// Actual data members. std::vector jointfluxinputs; std::vector jointeventinputs; std::vector jointindexlow; std::vector jointindexhigh; std::vector jointindexallowed; size_t jointindexswitch; bool jointinput; std::vector jointindexscale; std::string fName; TH1D *fFluxHist; TH1D *fEventHist; TH1D *fXSecHist; int fNEvents; int fMaxEvents; FitEvent *fNUISANCEEvent; BaseFitEvt *fBaseEvent; int fEventType; int fCurrentIndex; int fCacheSize; bool kRemoveUndefParticles; bool kRemoveFSIParticles; bool kRemoveNuclearParticles; TTreePerfStats *fTTreePerformance; int fSkip; }; /*! @} */ #endif diff --git a/src/InputHandler/InputTypes.h b/src/InputHandler/InputTypes.h index 7a78145..fdf6ec8 100644 --- a/src/InputHandler/InputTypes.h +++ b/src/InputHandler/InputTypes.h @@ -1,160 +1,160 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef INPUTTYPES_SEEN_H #define INPUTTYPES_SEEN_H /// Global Enum to define generator type being read with FitEvent /// Have to define kNORM as if its a generator for the time being. enum generator_event_type { kUNKNOWN = 999, kNEUT = 0, kNIWG = 1, kNUWRO = 2, kT2K = 3, kCUSTOM = 4, kGENIE = 5, kEVTSPLINE = 6, kNUANCE = 7, kGiBUU = 8, kNORM = 9, kEMPTY = 10, kINPUTFITEVENT = 11, kNEWSPLINE = 12, kLIKEWEIGHT = 13, kSPLINEPARAMETER = 14, kHEPMC = 15, kHISTO = 16, kSIGMAQ0HIST = 17, kLast_generator_event_type }; namespace InputUtils { enum InputType { kNEUT_Input = 0, kNUWRO_Input = 1, kGENIE_Input = 2, kGiBUU_Input, kNUANCE_Input, kEVSPLN_Input, kEMPTY_Input, kFEVENT_Input, kJOINT_Input, kSIGMAQ0HIST_Input, kHISTO_Input, kInvalid_Input, kBNSPLN_Input, // Not sure if this are currently used. }; } inline std::ostream& operator<<(std::ostream& os, generator_event_type const& gs) { switch (gs) { case kUNKNOWN: { return os << "kUNKNOWN"; } case kNEUT: { return os << "kNEUT"; } case kNIWG: { return os << "kNIWG"; } case kNUWRO: { return os << "kNUWRO"; } case kT2K: { return os << "kT2K"; } case kCUSTOM: { return os << "kCUSTOM"; } case kGENIE: { return os << "kGENIE"; } case kEVTSPLINE: { return os << "kEVTSPLINE"; } case kNUANCE: { return os << "kNUANCE"; } case kGiBUU: { return os << "kGiBUU"; } case kNORM: { return os << "kNORM"; } case kHEPMC: { return os << "kHEPMC"; } case kSIGMAQ0HIST: { return os << "kSIGMAQ0HIST"; } case kHISTO: { return os << "kHISTO"; } default: { return os << "kUNKNOWN"; } } } 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::kSIGMAQ0HIST_Input: { return os << "kSIGMAQ0HIST_Input"; } case InputUtils::kHISTO_Input: { return os << "kHISTO_Input"; } case InputUtils::kInvalid_Input: case InputUtils::kBNSPLN_Input: default: { return os << "kInvalid_Input"; } } } #endif diff --git a/src/InputHandler/InputUtils.cxx b/src/InputHandler/InputUtils.cxx index 961b81b..953b784 100644 --- a/src/InputHandler/InputUtils.cxx +++ b/src/InputHandler/InputUtils.cxx @@ -1,172 +1,172 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GeneralUtils.h" #include "InputHandler.h" #include "InputUtils.h" namespace InputUtils { std::vector ParseInputFileList(std::string const &inpFile) { std::vector inputs = GeneralUtils::ParseToStr(inpFile, ","); if (inputs.front()[0] == '(') { inputs.front() = inputs.front().substr(1); } if (inputs.back()[inputs.back().size() - 1] == ')') { inputs.back() = inputs.back().substr(0, inputs.back().size() - 1); } return inputs; } 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", "SIGMAQ0HIST", "HISTO", "HEPMCNUEVT"}; 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] != ')')) { NUIS_ABORT( "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] << "\'"); } 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 + // Can specify NEUT_DIR = "" and others in parameters/config.xml 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]; bool didRpl; do { 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); didRpl = true; } else { didRpl = false; } } while (didRpl); } bool didRpl; do { size_t torpl = expandedInputs.find("//"); if (torpl != std::string::npos) { expandedInputs.replace(torpl, 2, "/"); didRpl = true; } else { didRpl = false; } } while (didRpl); return expandedInputs; } InputType GuessInputTypeFromFile(TFile *inpF) { const std::string NEUT_TreeName = "neuttree"; const std::string NuWro_TreeName = "treeout"; const std::string GENIE_TreeName = "gtree"; const std::string GiBUU_TreeName = "giRooTracker"; if (!inpF) { return kInvalid_Input; } TTree *NEUT_Input = dynamic_cast(inpF->Get(NEUT_TreeName.c_str())); if (NEUT_Input) { return kNEUT_Input; } TTree *NUWRO_Input = dynamic_cast(inpF->Get(NuWro_TreeName.c_str())); if (NUWRO_Input) { return kNUWRO_Input; } TTree *GENIE_Input = dynamic_cast(inpF->Get(GENIE_TreeName.c_str())); if (GENIE_Input) { return kGENIE_Input; } TTree *GiBUU_Input = dynamic_cast(inpF->Get(GiBUU_TreeName.c_str())); if (GiBUU_Input) { return kGiBUU_Input; } return kInvalid_Input; } std::string PrependGuessedInputTypeToName(std::string const &inpFName) { // If it already has a name. if (inpFName.find(":") != std::string::npos) { return inpFName; } TFile *inpF = TFile::Open(inpFName.c_str(), "READ"); if (!inpF || !inpF->IsOpen()) { NUIS_ABORT("Couldn't open \"" << inpFName << "\" for reading."); } InputType iType = GuessInputTypeFromFile(inpF); if (iType == kInvalid_Input) { NUIS_ABORT("Couldn't determine input type from file: " << inpFName << "."); } 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: { NUIS_ABORT("Input type from file: " << inpFName << " was invalid."); throw; } } } } // namespace InputUtils diff --git a/src/InputHandler/InputUtils.h b/src/InputHandler/InputUtils.h index e344638..7913f2c 100644 --- a/src/InputHandler/InputUtils.h +++ b/src/InputHandler/InputUtils.h @@ -1,49 +1,49 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef INPUT_UTILS_H #define INPUT_UTILS_H #include #include "TFile.h" #include "InputTypes.h" namespace InputUtils { /// Extract Input Type from start of filename InputType ParseInputType(std::string const &inp); /// Check for comma separated joint input files bool IsJointInput(std::string const &inputs); /// Replace Input Event Diretory tags with Full Names from Config std::string ExpandInputDirectories(std::string const &inputs); /// Open ROOT file and guess what the file type is from the tree names InputType GuessInputTypeFromFile(TFile *inpF); /// Guess file input type and form an updated filename with it std::string PrependGuessedInputTypeToName(std::string const &inpFName); /// Split file inputs by commas and remove brackets before putting into a vector std::vector ParseInputFileList(std::string const& inpFile); } #endif diff --git a/src/InputHandler/InteractionModes.h b/src/InputHandler/InteractionModes.h index 22d6adf..2512ce4 100644 --- a/src/InputHandler/InteractionModes.h +++ b/src/InputHandler/InteractionModes.h @@ -1,121 +1,121 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef INTERACTION_MODES_H #define INTERACTION_MODES_H #include namespace InputHandler { enum InteractionModes { kCCQE = 1, kCC2p2h = 2, kCC1piponp = 11, kCC1pi0onn = 12, kCC1piponn = 13, kCCCoherent = 16, kCC1gamma = 17, kCCmultipi = 21, kCC1etaonn = 22, kCC1kaonp = 23, kCCDIS = 26, kNC1pi0onn = 31, kNC1pi0onp = 32, kNC1pimonn = 33, kNC1piponp = 34, kNCCoherent = 36, kNC1gamman = 38, kNC1gammap = 39, kNCmultipi = 41, kNC1etaonn = 42, kNC1etaonp = 43, kNC1kaon0 = 44, kNC1kaonp = 45, kNCDIS = 46, kNCELonp = 51, kNCELonn = 52, kNC2p2h = 53 }; } inline std::ostream &operator<<(std::ostream &os, InputHandler::InteractionModes it) { switch (it) { case InputHandler::kCCQE: return os << "CCQE"; case InputHandler::kCC2p2h: return os << "CC2p2h"; case InputHandler::kCC1piponp: return os << "CC1piponp"; case InputHandler::kCC1pi0onn: return os << "CC1pi0onn"; case InputHandler::kCC1piponn: return os << "CC1piponn"; case InputHandler::kCCCoherent: return os << "CCCoherent"; case InputHandler::kCC1gamma: return os << "CC1gamma"; case InputHandler::kCCmultipi: return os << "CCmultipi"; case InputHandler::kCC1etaonn: return os << "CC1etaonn"; case InputHandler::kCC1kaonp: return os << "CC1kaonp"; case InputHandler::kCCDIS: return os << "CCDIS"; case InputHandler::kNC1pi0onn: return os << "NC1pi0onn"; case InputHandler::kNC1pi0onp: return os << "NC1pi0onp"; case InputHandler::kNC1pimonn: return os << "NC1pimonn"; case InputHandler::kNC1piponp: return os << "NC1piponp"; case InputHandler::kNCCoherent: return os << "NCCoherent"; case InputHandler::kNC1gamman: return os << "NC1gamman"; case InputHandler::kNC1gammap: return os << "NC1gammap"; case InputHandler::kNCmultipi: return os << "NCmultipi"; case InputHandler::kNC1etaonn: return os << "NC1etaonn"; case InputHandler::kNC1etaonp: return os << "NC1etaonp"; case InputHandler::kNC1kaon0: return os << "NC1kaon0"; case InputHandler::kNC1kaonp: return os << "NC1kaonp"; case InputHandler::kNCDIS: return os << "NCDIS"; case InputHandler::kNCELonp: return os << "NCELonp"; case InputHandler::kNCELonn: return os << "NCELonn"; case InputHandler::kNC2p2h: return os << "NC2p2h"; default: return os << "UNKNOWN"; } return os << "UNKNOWN"; } #endif diff --git a/src/InputHandler/NUANCEInputHandler.h b/src/InputHandler/NUANCEInputHandler.h index a6c1b4c..7f98d2d 100644 --- a/src/InputHandler/NUANCEInputHandler.h +++ b/src/InputHandler/NUANCEInputHandler.h @@ -1,92 +1,92 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef NUANCEINPUTHANDLER_H #define NUANCEINPUTHANDLER_H #ifdef __NUANCE_ENABLED__ /*! * \addtogroup InputHandler * @{ */ #include "InputHandler.h" #include "PlotUtils.h" /// NUANCE Generator Container to save extra particle status codes. class NUANCEGeneratorInfo : public GeneratorInfoBase { public: NUANCEGeneratorInfo() {}; virtual ~NUANCEGeneratorInfo(); /// Assigns information to branches void AddBranchesToTree(TTree* tn); /// Setup reading information from branches void SetBranchesFromTree(TTree* tn); /// Allocate any dynamic arrays for a new particle stack size void AllocateParticleStack(int stacksize); /// Clear any dynamic arrays void DeallocateParticleStack(); /// Read extra NUANCE information from the event void FillGeneratorInfo(NuanceEvent* nevent); /// Reset extra information to default/empty values void Reset(); // int kMaxParticles; ///< Number of particles in stack // int* fNEUTParticleStatusCode; ///Branch("NuWroParticlePDGs", &fNuWroParticlePDGs, "NuWroParticlePDGs/I"); } void NuWroGeneratorInfo::SetBranchesFromTree(TTree *tn) { tn->SetBranchAddress("NuWroParticlePDGs", &fNuWroParticlePDGs); } void NuWroGeneratorInfo::AllocateParticleStack(int stacksize) { fNuWroParticlePDGs = new int[stacksize]; } void NuWroGeneratorInfo::DeallocateParticleStack() { delete fNuWroParticlePDGs; } void NuWroGeneratorInfo::FillGeneratorInfo(event *e) { Reset(); } void NuWroGeneratorInfo::Reset() { for (int i = 0; i < kMaxParticles; i++) { fNuWroParticlePDGs[i] = 0; } } int event1_nof(event *e, int pdg) { int c = 0; for (size_t i = 0; i < e->out.size(); i++) if (e->out[i].pdg == pdg) c++; return c; } NuWroInputHandler::NuWroInputHandler(std::string const &handle, std::string const &rawinputs) { NUIS_LOG(SAM, "Creating NuWroInputHandler : " << handle); // Run a joint input handling fName = handle; fMaxEvents = FitPar::Config().GetParI("MAXEVENTS"); fSaveExtra = false; // FitPar::Config().GetParB("NuWroSaveExtra"); // Setup the TChain fNuWroTree = new TChain("treeout"); // Loop over all inputs and grab flux, eventhist, and nevents std::vector inputs = InputUtils::ParseInputFileList(rawinputs); for (size_t inp_it = 0; inp_it < inputs.size(); ++inp_it) { // Open File for histogram access TFile *inp_file = new TFile(inputs[inp_it].c_str(), "READ"); if (!inp_file or inp_file->IsZombie()) { NUIS_ABORT("nuwro File IsZombie() at " << inputs[inp_it]); } // Get Flux/Event hist TH1D *fluxhist = (TH1D *)inp_file->Get( (PlotUtils::GetObjectWithName(inp_file, "FluxHist")).c_str()); TH1D *eventhist = (TH1D *)inp_file->Get( (PlotUtils::GetObjectWithName(inp_file, "EvtHist")).c_str()); if (!fluxhist or !eventhist) { NUIS_ERR(FTL, "nuwro FILE doesn't contain flux/xsec info"); if (FitPar::Config().GetParB("regennuwro")) { NUIS_ERR(FTL, "Regen NuWro has not been added yet. Email the developers!"); // ProcessNuWroInputFlux(inputs[inp_it]); throw; } else { NUIS_ABORT("If you would like NUISANCE to generate these for you " << "please set parameter regennuwro=1 and re-run."); } } // Get N Events TTree *nuwrotree = (TTree *)inp_file->Get("treeout"); if (!nuwrotree) { NUIS_ABORT("treeout not located in nuwro file! " << inputs[inp_it]); } int nevents = nuwrotree->GetEntries(); // Register input to form flux/event rate hists RegisterJointInput(inputs[inp_it], nevents, fluxhist, eventhist); // Add to TChain fNuWroTree->Add(inputs[inp_it].c_str()); } // Registor all our file inputs SetupJointInputs(); // Setup Events fNuWroEvent = NULL; fNuWroTree->SetBranchAddress("e", &fNuWroEvent); fNuWroTree->GetEntry(0); fNUISANCEEvent = new FitEvent(); fNUISANCEEvent->fType = kNUWRO; fNUISANCEEvent->fNuwroEvent = fNuWroEvent; fNUISANCEEvent->HardReset(); if (fSaveExtra) { fNuWroInfo = new NuWroGeneratorInfo(); fNUISANCEEvent->AddGeneratorInfo(fNuWroInfo); } }; NuWroInputHandler::~NuWroInputHandler() { if (fNuWroTree) delete fNuWroTree; } void NuWroInputHandler::CreateCache() { // fNuWroTree->SetCacheEntryRange(0, fNEvents); // fNuWroTree->AddBranchToCache("*", 1); // fNuWroTree->SetCacheSize(fCacheSize); } void NuWroInputHandler::RemoveCache() { // fNuWroTree->SetCacheEntryRange(0, fNEvents); // fNuWroTree->AddBranchToCache("*", 0); // fNuWroTree->SetCacheSize(0); } void NuWroInputHandler::ProcessNuWroInputFlux(const std::string file) {} FitEvent *NuWroInputHandler::GetNuisanceEvent(const UInt_t ent, const bool lightweight) { UInt_t entry = ent + fSkip; // Catch too large entries if (entry >= (UInt_t)fNEvents) return NULL; // Read Entry from TTree to fill NEUT Vect in BaseFitEvt; fNuWroTree->GetEntry(entry); // Run NUISANCE Vector Filler if (!lightweight) { CalcNUISANCEKinematics(); } #ifdef __PROB3PP_ENABLED__ for (size_t i = 0; i < fNUISANCEEvent->fNuwroEvent->in.size(); i++) { if (std::count(PhysConst::pdg_neutrinos, PhysConst::pdg_neutrinos + 4, fNUISANCEEvent->fNuwroEvent->in[i].pdg)) { fNUISANCEEvent->probe_E = fNUISANCEEvent->fNuwroEvent->in[i].t; fNUISANCEEvent->probe_pdg = fNUISANCEEvent->fNuwroEvent->in[i].pdg; break; } } #endif // Setup Input scaling for joint inputs fNUISANCEEvent->InputWeight = GetInputWeight(entry); #ifdef __USE_NUWRO_SRW_EVENTS__ if (!rwEvs.size()) { fNuwroParams = fNuWroEvent->par; } if (entry >= rwEvs.size()) { rwEvs.push_back(BaseFitEvt()); rwEvs.back().fType = kNUWRO; rwEvs.back().Mode = fNUISANCEEvent->Mode; rwEvs.back().fNuwroSRWEvent = SRW::SRWEvent(*fNuWroEvent); rwEvs.back().fNuwroEvent = NULL; rwEvs.back().fNuwroParams = &fNuwroParams; rwEvs.back().probe_E = rwEvs.back().fNuwroSRWEvent.NeutrinoEnergy; rwEvs.back().probe_pdg = rwEvs.back().fNuwroSRWEvent.NeutrinoPDG; } fNUISANCEEvent->fNuwroSRWEvent = SRW::SRWEvent(*fNuWroEvent); fNUISANCEEvent->fNuwroParams = &fNuwroParams; fNUISANCEEvent->probe_E = fNUISANCEEvent->fNuwroSRWEvent.NeutrinoEnergy; fNUISANCEEvent->probe_pdg = fNUISANCEEvent->fNuwroSRWEvent.NeutrinoPDG; #endif return fNUISANCEEvent; } int NuWroInputHandler::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; lambda_pdg = 3122; kaon_pdg = 311; kaon_plus_pdg = 321; // Antineutrino modes are *-1 int nu_nubar = 1; if (e->flag.anty) nu_nubar = -1; // Quasielastic if (e->flag.qel){ if (e->flag.cc) return 1*nu_nubar; else { if (event1_nof(e, proton_pdg)) return 51*nu_nubar; else if (event1_nof(e, neutron_pdg)) return 52*nu_nubar; } } if (e->flag.mec) { return 2*nu_nubar; } // Pion production if (e->flag.res) { int npions = event1_nof(e, pion_pdg) + event1_nof(e, pion_plus_pdg) + event1_nof(e, pion_minus_pdg); - int nkaons= event1_nof(e, kaon_pdg) + event1_nof(e, kaon_pdg); + int nkaons= event1_nof(e, kaon_pdg) + event1_nof(e, kaon_plus_pdg); // Multipion? - if (npions > 1 || npions == 0) { + if ((npions+nkaons) > 1 || npions == 0) { if (e->flag.cc) return 21*nu_nubar; else return 41*nu_nubar; } if (npions == 1) { if (e->flag.cc) { // CC if (e->flag.anty){ // Antineutrino if (event1_nof(e, neutron_pdg) && event1_nof(e, pion_minus_pdg)) return -11; if (event1_nof(e, neutron_pdg) && event1_nof(e, pion_pdg)) return -12; if (event1_nof(e, proton_pdg) && event1_nof(e, pion_minus_pdg)) return -13; } else { // Neutrino if (event1_nof(e, proton_pdg) && event1_nof(e, pion_plus_pdg)) return 11; if (event1_nof(e, proton_pdg) && event1_nof(e, pion_pdg)) return 12; if (event1_nof(e, neutron_pdg) && event1_nof(e, pion_plus_pdg)) return 13; } } else { // Now NC if (event1_nof(e, proton_pdg)) { if (event1_nof(e, pion_minus_pdg)) return 33*nu_nubar; else if (event1_nof(e, pion_pdg)) return 32*nu_nubar; } else if (event1_nof(e, neutron_pdg)) { if (event1_nof(e, pion_plus_pdg)) return 34*nu_nubar; else if (event1_nof(e, pion_pdg)) return 31*nu_nubar; } } } // Eta production if (event1_nof(e, eta_pdg)) { if (e->flag.cc) return 22*nu_nubar; else { if (event1_nof(e, neutron_pdg)) return 42*nu_nubar; else if (event1_nof(e, proton_pdg)) return 43*nu_nubar; } } // Resonant kaon production if (event1_nof(e, lambda_pdg) == 1 && nkaons == 1) { if (e->flag.cc && event1_nof(e, kaon_pdg)) return 23*nu_nubar; else { if (event1_nof(e, kaon_pdg)) return 44*nu_nubar; else if (event1_nof(e, kaon_plus_pdg)) return 45*nu_nubar; } } } // Coherent if (e->flag.coh) { if (e->flag.cc && (event1_nof(e, pion_minus_pdg) + event1_nof(e, pion_plus_pdg))) return 16*nu_nubar; else if (event1_nof(e, pion_pdg)) return 36*nu_nubar; } // DIS if (e->flag.dis) { if (e->flag.cc) return 26*nu_nubar; else return 46*nu_nubar; } // If we got here, something is wrong, see what happened... NUIS_ERR(WRN, "Unable to interpret NUWRO event, dumping info..."); Print(); return 9999; } void NuWroInputHandler::CalcNUISANCEKinematics() { // std::cout << "NuWro Event Address " << fNuWroEvent << std::endl; // Reset all variables fNUISANCEEvent->ResetEvent(); FitEvent *evt = fNUISANCEEvent; // Sort Event Info evt->Mode = ConvertNuwroMode(fNuWroEvent); if (abs(evt->Mode) > 60) { evt->Mode = 0; } evt->fEventNo = 0.0; evt->fTotCrs = 0.0; evt->fTargetA = fNuWroEvent->par.nucleus_p + fNuWroEvent->par.nucleus_n; evt->fTargetZ = fNuWroEvent->par.nucleus_p; evt->fTargetPDG = TargetUtils::GetTargetPDGFromZA(evt->fTargetZ, evt->fTargetA); evt->fTargetH = 0; evt->fBound = (evt->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; UInt_t kmax = evt->kMaxParticles; if (npart > kmax) { NUIS_ERR(WRN, "NUWRO has too many particles. Expanding stack."); fNUISANCEEvent->ExpandParticleStack(npart); } evt->fNParticles = 0; std::vector::iterator p_iter; // Get the Initial State for (p_iter = fNuWroEvent->in.begin(); p_iter != fNuWroEvent->in.end(); p_iter++) { AddNuWroParticle(fNUISANCEEvent, (*p_iter), kInitialState, true); } // Try to find the FSI state particles // Loop over the primary vertex particles // If they match the post-FSI they haven't undergone FSI. // If they don't match post-FSI they have undergone FSI. for (p_iter = fNuWroEvent->out.begin(); p_iter != fNuWroEvent->out.end(); p_iter++) { // Get the particle particle p = (*p_iter); // Check against all the post particles, match them std::vector::iterator p2_iter; bool match = false; for (p2_iter = fNuWroEvent->post.begin(); p2_iter != fNuWroEvent->post.end(); p2_iter++) { particle p2 = (*p2_iter); // Check energy and pdg // A very small cascade which changes the energy by 1E-5 MeV should be // matched match = (fabs(p2.E() - p.E()) < 1E-5 && p2.pdg == p.pdg); // If we match p to p2 break the loop if (match) break; } // If we've looped through the whole particle stack of post-FSI and haven't // found a match it's a primary particle that has been FSIed if (!match) AddNuWroParticle(fNUISANCEEvent, (*p_iter), kFSIState, true); } // Loop over the final state particles for (p_iter = fNuWroEvent->post.begin(); p_iter != fNuWroEvent->post.end(); p_iter++) { particle p = (*p_iter); // To find if it's primary or not we have to loop through the primary ones // and match, just like above bool match = false; std::vector::iterator p2_iter; for (p2_iter = fNuWroEvent->out.begin(); p2_iter != fNuWroEvent->out.end(); p2_iter++) { particle p2 = (*p2_iter); match = (fabs(p2.E() - p.E()) < 1E-5 && p2.pdg == p.pdg); if (match) break; } AddNuWroParticle(fNUISANCEEvent, (*p_iter), kFinalState, match); } // Fill Generator Info if (fSaveExtra) fNuWroInfo->FillGeneratorInfo(fNuWroEvent); // Run Initial, FSI, Final, Other ordering. fNUISANCEEvent->OrderStack(); FitParticle *ISAnyLepton = fNUISANCEEvent->GetHMISAnyLeptons(); if (ISAnyLepton) { fNUISANCEEvent->probe_E = ISAnyLepton->E(); fNUISANCEEvent->probe_pdg = ISAnyLepton->PDG(); } return; } void NuWroInputHandler::AddNuWroParticle(FitEvent *evt, particle &p, int state, bool primary = false) { // Add Mom evt->fParticleMom[evt->fNParticles][0] = static_cast(p).x; evt->fParticleMom[evt->fNParticles][1] = static_cast(p).y; evt->fParticleMom[evt->fNParticles][2] = static_cast(p).z; evt->fParticleMom[evt->fNParticles][3] = static_cast(p).t; // For NuWro a particle that we've given a FSI state is a pre-FSI particle // An initial state particle is also a primary vertex praticle evt->fPrimaryVertex[evt->fNParticles] = primary; // Status/PDG evt->fParticleState[evt->fNParticles] = state; evt->fParticlePDG[evt->fNParticles] = p.pdg; // Add to particle count evt->fNParticles++; } void NuWroInputHandler::Print(){ - NUIS_LOG(EVT, "NuWro event information:" << std::endl + NUIS_LOG(SAM, "NuWro event information:" << std::endl << "\t\t|-> dyn = " << fNuWroEvent->dyn << std::endl << "\t\t|-> qel = " << fNuWroEvent->flag.qel << std::endl << "\t\t|-> res = " << fNuWroEvent->flag.res << std::endl << "\t\t|-> dis = " << fNuWroEvent->flag.dis << std::endl << "\t\t|-> coh = " << fNuWroEvent->flag.coh << std::endl << "\t\t|-> mec = " << fNuWroEvent->flag.mec << std::endl << "\t\t|-> hip = " << fNuWroEvent->flag.hip << std::endl << "\t\t|-> nc = " << fNuWroEvent->flag.nc << std::endl << "\t\t|-> cc = " << fNuWroEvent->flag.cc << std::endl << "\t\t|-> anty = " << fNuWroEvent->flag.anty << std::endl - << "\t\t|-> res_delta = " << fNuWroEvent->flag.res_delta); + << "\t\t|-> res_delta = " << fNuWroEvent->flag.res_delta << std::endl + << "\t\t|-> npi+ = " << event1_nof(fNuWroEvent, 211) << std::endl + << "\t\t|-> npi+ = " << event1_nof(fNuWroEvent, 211) << std::endl + << "\t\t|-> npi- = " << event1_nof(fNuWroEvent, -211) << std::endl + << "\t\t|-> npi0 = " << event1_nof(fNuWroEvent, 111) << std::endl + << "\t\t|-> neta = " << event1_nof(fNuWroEvent, 221) << std::endl + << "\t\t|-> nK+ = " << event1_nof(fNuWroEvent, 321) << std::endl + << "\t\t|-> nK0 = " << event1_nof(fNuWroEvent, 311) << std::endl + << "\t\t|-> nlamda = " << event1_nof(fNuWroEvent, 3122) << std::endl + << "\t\t|-> nproton = " << event1_nof(fNuWroEvent, 2212) << std::endl + << "\t\t|-> nneutron = " << event1_nof(fNuWroEvent, 2112)); } #endif diff --git a/src/InputHandler/NuanceEvent.cxx b/src/InputHandler/NuanceEvent.cxx index dd9118c..68ad817 100644 --- a/src/InputHandler/NuanceEvent.cxx +++ b/src/InputHandler/NuanceEvent.cxx @@ -1,59 +1,59 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /*! * \addtogroup FitBase * @{ */ #ifdef __NUANCE_ENABLED__ #include "NuanceEvent.h" void NuanceEvent::SetBranchAddresses(TTree* tn) { tn->SetBranchAddress("neutrino", &neutrino); tn->SetBranchAddress("target", &target); tn->SetBranchAddress("channel", &channel); tn->SetBranchAddress("iniQ", &iniQ); tn->SetBranchAddress("finQ", &finQ); tn->SetBranchAddress("lepton0", &lepton0); tn->SetBranchAddress("polar", &polar); tn->SetBranchAddress("qsq", &qsq); tn->SetBranchAddress("w", &w); tn->SetBranchAddress("x", &x); tn->SetBranchAddress("y", &y); tn->SetBranchAddress("p_neutrino", p_neutrino); tn->SetBranchAddress("p_targ", p_targ); tn->SetBranchAddress("vertex", vertex); tn->SetBranchAddress("start", start); tn->SetBranchAddress("depth", &depth); tn->SetBranchAddress("flux", &flux); tn->SetBranchAddress("n_leptons", &n_leptons); tn->SetBranchAddress("p_ltot", p_ltot); tn->SetBranchAddress("lepton", lepton); tn->SetBranchAddress("p_lepton", p_lepton); tn->SetBranchAddress("n_hadrons", &n_hadrons); tn->SetBranchAddress("p_htot", p_htot); tn->SetBranchAddress("hadron", hadron); tn->SetBranchAddress("p_hadron", p_hadron); } #endif diff --git a/src/InputHandler/NuanceEvent.h b/src/InputHandler/NuanceEvent.h index 09c620e..9826897 100644 --- a/src/InputHandler/NuanceEvent.h +++ b/src/InputHandler/NuanceEvent.h @@ -1,74 +1,74 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef NUANCE_H_SEEN #define NUANCE_H_SEEN /*! * \addtogroup FitBase * @{ */ #ifdef __NUANCE_ENABLED__ #include "TTree.h" /// TTree Reader for Nuance TTree Events class NuanceEvent { public: /// Empty constructor NuanceEvent(){}; /// Reads values from the tTree void SetBranchAddresses(TTree* tn); bool cc; ///< Is Charged Current bool bound; ///< On Bound Target int neutrino; ///< Neutrino PDG int target; ///< Target PDG float iniQ; float finQ; int lepton0; float polar; int channel; float qsq; float w; float x; ///< Event Bjorken x float y; ///< Event Bjorken y float p_neutrino[4]; ///< Neutrino 4-Mom float p_targ[5]; ///< Target 5-mom float vertex[4]; ///< Vertex Position float start[4]; ///< Start Position float depth; float flux; int n_leptons; ///< Number of final state leptons float p_ltot[5]; ///< Total 5-momentum of leptonic side int lepton[200]; ///< Lepton PDGs float p_lepton[5][200]; ///< Lepton 5-momentum int n_hadrons; ///< Number of final state hadrons float p_htot[5]; ///< Total 5-momentum of hadronic side int hadron[200]; ///< Hadron PDGs float p_hadron[5][200]; ///< Hadron 5-momentum }; #endif /*! @} */ #endif diff --git a/src/InputHandler/StdHepEvt.cxx b/src/InputHandler/StdHepEvt.cxx index 17b7622..e8e244f 100644 --- a/src/InputHandler/StdHepEvt.cxx +++ b/src/InputHandler/StdHepEvt.cxx @@ -1,136 +1,136 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include #include #include #include "StdHepEvt.h" // Include logging #include "FitLogger.h" StdHepReader::StdHepReader(){}; bool StdHepReader::SetBranchAddresses(TChain *chain) { bool ok = true; int SBAStatus = 0; SBAStatus = chain->SetBranchAddress("StdHepN", &StdHepN); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"StdHepN\": " << SBAStatus); } SBAStatus = chain->SetBranchAddress("StdHepPdg", StdHepPdg); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"StdHepPdg\": " << SBAStatus); } SBAStatus = chain->SetBranchAddress("StdHepStatus", StdHepStatus); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"StdHepStatus\": " << SBAStatus); } SBAStatus = chain->SetBranchAddress("StdHepP4", StdHepP4); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"StdHepP4\": " << SBAStatus); } return ok; } bool GiBUUStdHepReader::SetBranchAddresses(TChain *chain) { bool ok = true; int SBAStatus = 0; ok = ok && StdHepReader::SetBranchAddresses(chain); SBAStatus = chain->SetBranchAddress("GiBUU2NeutCode", &GiBUU2NeutCode); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"GiBUU2NeutCode\": " << SBAStatus); } SBAStatus = chain->SetBranchAddress("GiBUUReactionCode", &GiBUUReactionCode); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"GiBUUReactionCode\": " << SBAStatus); } SBAStatus = chain->SetBranchAddress("EvtWght", &EvtWght); ok = ok && (SBAStatus || SBAStatus == 5); if (!(!SBAStatus || SBAStatus == 5)) { NUIS_ERR(WRN, "Failed to set branch address for \"EvtWght\": " << SBAStatus); } return ok; } std::string NegSpacer(double const &num) { return (num >= 0) ? " " : ""; } std::ostream &operator<<(std::ostream &os, TLorentzVector const &tlv) { std::streamsize prec = os.precision(); std::ios_base::fmtflags flags = os.flags(); os.precision(2); os.flags(std::ios::scientific); os << "[" << NegSpacer(tlv[0]) << tlv[0] << "," << NegSpacer(tlv[1]) << tlv[1] << "," << NegSpacer(tlv[2]) << tlv[2] << "," << NegSpacer(tlv[3]) << tlv[3] << ":M(" << tlv.M() << ")]"; os.precision(prec); os.flags(flags); return os; } std::string WriteGiBUUEvent(GiBUUStdHepReader const &gi) { std::stringstream ss(""); ss << "[INFO]: contained " << gi.StdHepN << ", Event Weight: " << std::setprecision(3) << gi.EvtWght << ", NeutConventionReactionCode: " << gi.GiBUU2NeutCode << "\n\t[Lep In](" << std::setw(3) << gi.StdHepPdg[0] << ") " << TLorentzVector(gi.StdHepP4[0][StdHepReader::kStdHepIdxPx], gi.StdHepP4[0][StdHepReader::kStdHepIdxPy], gi.StdHepP4[0][StdHepReader::kStdHepIdxPz], gi.StdHepP4[0][StdHepReader::kStdHepIdxE]) << std::endl; ss << "\t[Target] : " << gi.StdHepPdg[1] << std::endl; ss << "\t[Nuc In] : " << TLorentzVector(gi.StdHepP4[3][StdHepReader::kStdHepIdxPx], gi.StdHepP4[3][StdHepReader::kStdHepIdxPy], gi.StdHepP4[3][StdHepReader::kStdHepIdxPz], gi.StdHepP4[3][StdHepReader::kStdHepIdxE]) << " (" << std::setw(4) << gi.StdHepPdg[3] << ")" << std::endl; for (Int_t stdHepInd = 4; stdHepInd < gi.StdHepN; ++stdHepInd) { ss << "\t[" << std::setw(2) << (stdHepInd - (4)) << "](" << std::setw(5) << gi.StdHepPdg[stdHepInd] << ") " << TLorentzVector(gi.StdHepP4[stdHepInd][StdHepReader::kStdHepIdxPx], gi.StdHepP4[stdHepInd][StdHepReader::kStdHepIdxPy], gi.StdHepP4[stdHepInd][StdHepReader::kStdHepIdxPz], gi.StdHepP4[stdHepInd][StdHepReader::kStdHepIdxE]) << std::endl; } ss << "\t[Lep Out](" << std::setw(3) << gi.StdHepPdg[2] << ") " << TLorentzVector(gi.StdHepP4[2][StdHepReader::kStdHepIdxPx], gi.StdHepP4[2][StdHepReader::kStdHepIdxPy], gi.StdHepP4[2][StdHepReader::kStdHepIdxPz], gi.StdHepP4[2][StdHepReader::kStdHepIdxE]) << std::endl; return ss.str(); } diff --git a/src/InputHandler/StdHepEvt.h b/src/InputHandler/StdHepEvt.h index 96f280c..b99dd48 100644 --- a/src/InputHandler/StdHepEvt.h +++ b/src/InputHandler/StdHepEvt.h @@ -1,116 +1,116 @@ #ifndef __STDHEPEVT_SEEN__ #define __STDHEPEVT_SEEN__ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "TChain.h" #include "TLorentzVector.h" struct StdHepReader { public: const static int kStdHepIdxPx = 0; const static int kStdHepIdxPy = 1; const static int kStdHepIdxPz = 2; const static int kStdHepIdxE = 3; const static int kStdHepNPmax = 100; StdHepReader(); ///\brief The number of StdHep particles in this event. Int_t StdHepN; ///\brief The PDG codes of particles in this event. /// /// This is determined from the GiBUU particle number by /// GiBUUUtils::GiBUUToPDG. ///\warning This is not a one-to-one mapping, e.g. resonances are not uniquely /// determined by the GiBUU scheme. Int_t StdHepPdg[kStdHepNPmax]; //[StdHepN] ///\brief The StdHep Status of particles in this event. /// /// Status Codes in use: /// - -1: Initial state real particle. /// - 1: Final state real particle. Int_t StdHepStatus[kStdHepNPmax]; //[StdHepN] ///\brief Four momentum for particles in this event. Double_t StdHepP4[kStdHepNPmax][4]; bool SetBranchAddresses(TChain*); }; struct GiBUUStdHepReader : public StdHepReader { GiBUUStdHepReader() : StdHepReader(){}; ///\brief GiBUU interaction code /// /// See https://gibuu.hepforge.org/trac/wiki/LesHouches for details Int_t GiBUUReactionCode; ///\brief NEUT equivalent reaction code. /// CC: /// * 1 : QE /// * 2 : 2p2h /// * 10 : Single pion background (non-resonant) /// * 11 : Delta++ ( -11 : Delta- for nubar) /// * 12 : Delta+ (-12 : Delta0 for nubar) /// * 21 : Multi pion production /// * 26 : DIS /// * 4 : Higher resonance, charge: -1 /// * 5 : Higher resonance, charge: 0 /// * 6 : Higher resonance, charge: +1 /// * 7 : Higher resonance, charge: +2 /// /// NC: /// * 30 : Single pion background (non-resonant) /// * 31 : Delta0 /// * 32 : Delta+ /// * 41 : Multi pion production /// * 42 : 2p2h /// * 46 : DIS /// * 47 : Higher resonance, charge: -1 /// * 48 : Higher resonance, charge: 0 /// * 49 : Higher resonance, charge: +1 /// * 50 : Higher resonance, charge: +2 /// * 51 : NCEL proton-target /// * 52 : NCEL neutron-target /// Int_t GiBUU2NeutCode; ///\brief The total XSec weighting that should be applied to this event. Double_t EvtWght; ///\brief Weighting which takes account of multiple input numu species. /// /// Defined such that W_numu + W_numubar = 1 Double_t SpeciesWght_numu; ///\brief Weighting which takes account of multiple input nue species. /// /// Defined such that W_nue + W_nuebar = 1 Double_t SpeciesWght_nue; ///\brief Weighting which takes account of multiple input neutrino species. /// /// Defined such that \Sum_species W_species = 1 Double_t SpeciesWght; bool SetBranchAddresses(TChain*); }; std::string WriteGiBUUEvent(GiBUUStdHepReader const& gi); #endif diff --git a/src/K2K/CMakeLists.txt b/src/K2K/CMakeLists.txt index 6d0a3c5..99392f0 100644 --- a/src/K2K/CMakeLists.txt +++ b/src/K2K/CMakeLists.txt @@ -1,47 +1,47 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES K2K_NC1pi0_Evt_1Dppi0_nu.cxx ) set(HEADERFILES K2K_NC1pi0_Evt_1Dppi0_nu.h ) set(LIBNAME expK2K) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/K2K) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx b/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx index 07c4c00..1bb3cf4 100644 --- a/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx +++ b/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.cxx @@ -1,72 +1,72 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "K2K_NC1pi0_Evt_1Dppi0_nu.h" // The constructor K2K_NC1pi0_Evt_1Dppi0_nu::K2K_NC1pi0_Evt_1Dppi0_nu(nuiskey samplekey){ // Sample overview --------------------------------------------------- std::string descrip = "K2K_NC1pi0_Evt_1Dppi0_nu sample. \n" \ "Target: D2 \n" \ "Flux: \n" \ "Signal: \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi^{0}} (MeV/c)"); fSettings.SetYTitle("Number of events"); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG/MASK"); fSettings.SetEnuRange(0.0, 5.0); fSettings.DefineAllowedTargets("H,O"); // plot information fSettings.SetTitle("K2K_NC1pi0_Evt_1Dppi0_nu"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( FitPar::GetDataBase() + "K2K/nc1pi0/ppi0.csv"); FinaliseSampleSettings(); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Scale for shape fScaleFactor = fDataHist->Integral()/double(fNEvents); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void K2K_NC1pi0_Evt_1Dppi0_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(111) == 0) return; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double ppi0 = FitUtils::p(Ppi0)*1000.; fXVar = ppi0; return; }; bool K2K_NC1pi0_Evt_1Dppi0_nu::isSignal(FitEvent *event) { return SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax); // Check this signal definition } diff --git a/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.h b/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.h index d9ae82c..2dcc0d9 100644 --- a/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.h +++ b/src/K2K/K2K_NC1pi0_Evt_1Dppi0_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef K2K_NC1PI0_EVT_1DPPI0_NU_H_SEEN #define K2K_NC1PI0_EVT_1DPPI0_NU_H_SEEN #include "Measurement1D.h" class K2K_NC1pi0_Evt_1Dppi0_nu : public Measurement1D { public: K2K_NC1pi0_Evt_1Dppi0_nu(nuiskey samplekey); virtual ~K2K_NC1pi0_Evt_1Dppi0_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/K2K/SAMPLEREADME b/src/K2K/SAMPLEREADME deleted file mode 100644 index 3bb9818..0000000 --- a/src/K2K/SAMPLEREADME +++ /dev/null @@ -1,5 +0,0 @@ -./K2K_CC0pi_XSec_1DCosThetaMu_subtrks.cxx -./K2K_CC0pi_XSec_1DDelPhi_nu_Ntrks.cxx -./K2K_CC0pi_XSec_1DPmu_nu_Ntrks.cxx -./K2K_CC0pi_XSec_1DQ2_nu_subtrks.cxx -./K2K_CC0pi_XSec_1DThetaMu_nu_Ntrks.cxx diff --git a/src/Logger/CMakeLists.txt b/src/Logger/CMakeLists.txt index f6c8e27..b022aae 100644 --- a/src/Logger/CMakeLists.txt +++ b/src/Logger/CMakeLists.txt @@ -1,53 +1,53 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(HEADERFILES FitLogger.h Initialiser.h ) set(IMPLFILES PythiaQuiet.f FitLogger.cxx Initialiser.cxx ) set(LIBNAME Logger) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Logger) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Logger/FitLogger.cxx b/src/Logger/FitLogger.cxx index 4b7f178..aa6b591 100644 --- a/src/Logger/FitLogger.cxx +++ b/src/Logger/FitLogger.cxx @@ -1,327 +1,327 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitLogger.h" #include #include namespace Logger { // Logger Variables int log_verb = 4; bool use_colors = true; bool showtrace = true; std::ostream* __LOG_outstream(&std::cout); std::ofstream __LOG_nullstream; // Error Variables int err_verb = 0; std::ostream* __ERR_outstream(&std::cerr); // Extra Variables bool external_verb = true; bool super_rainbow_mode = true; //!< For when fitting gets boring. unsigned int super_rainbow_mode_colour = 0; std::streambuf* default_cout = std::cout.rdbuf(); std::streambuf* default_cerr = std::cerr.rdbuf(); std::ofstream redirect_stream("/dev/null"); int silentfd = open("/dev/null", O_WRONLY); int savedstdoutfd = dup(fileno(stdout)); int savedstderrfd = dup(fileno(stderr)); int nloggercalls = 0; int timelastlog = 0; } // -------- Logging Functions --------- // bool LOGGING(int level) { // std::cout << "LOGGING : " << __FILENAME__ << " " << __FUNCTION__ << // std::endl; return (Logger::log_verb >= (int)__GETLOG_LEVEL(level, __FILENAME__, __FUNCTION__)); }; int __GETLOG_LEVEL(int level, const char* filename, const char* funct) { #ifdef __DEBUG__ int logfile = FitPar::Config().GetParI("logging." + std::string(filename)); if (logfile >= DEB and logfile <= EVT) { level = logfile; } int logfunc = FitPar::Config().GetParI("logging." + std::string(funct)); if (logfunc >= DEB and logfunc <= EVT) { level = logfunc; } #endif return level; }; std::ostream& __OUTLOG(int level, const char* filename, const char* funct, int line) { if (Logger::log_verb < (int)level && Logger::log_verb != (int)DEB) { return (Logger::__LOG_nullstream); } else { if (Logger::use_colors) { switch (level) { case FIT: std::cout << BOLDGREEN; break; case MIN: std::cout << BOLDBLUE; break; case SAM: std::cout << MAGENTA; break; case REC: std::cout << BLUE; break; case SIG: std::cout << GREEN; break; case DEB: std::cout << CYAN; break; default: break; } } switch (level) { case FIT: std::cout << "[LOG Fitter]"; break; case MIN: std::cout << "[LOG Minmzr]"; break; case SAM: std::cout << "[LOG Sample]"; break; case REC: std::cout << "[LOG Reconf]"; break; case SIG: std::cout << "[LOG Signal]"; break; case EVT: std::cout << "[LOG Event ]"; break; case DEB: std::cout << "[LOG DEBUG ]"; break; default: std::cout << "[LOG INFO ]"; break; } // Apply indent if (true) { switch (level) { case FIT: std::cout << ": "; break; case MIN: std::cout << ":- "; break; case SAM: std::cout << ":-- "; break; case REC: std::cout << ":--- "; break; case SIG: std::cout << ":---- "; break; case EVT: std::cout << ":----- "; break; case DEB: std::cout << ":------ "; break; default: std::cout << " "; break; } } if (Logger::use_colors) std::cout << RESET; if (Logger::showtrace) { std::cout << " : " << filename << "::" << funct << "[l. " << line << "] : "; } return *(Logger::__LOG_outstream); } } void SETVERBOSITY(int level) { Logger::log_verb = level; } void SETERRVERBOSITY(int level) { Logger::err_verb = level; } void SETVERBOSITY(std::string verb) { if (!verb.compare("DEB")) Logger::log_verb = -1; else if (!verb.compare("QUIET")) Logger::log_verb = 0; else if (!verb.compare("FIT")) Logger::log_verb = 1; else if (!verb.compare("MIN")) Logger::log_verb = 2; else if (!verb.compare("SAM")) Logger::log_verb = 3; else if (!verb.compare("REC")) Logger::log_verb = 4; else if (!verb.compare("SIG")) Logger::log_verb = 5; else if (!verb.compare("EVT")) Logger::log_verb = 6; else Logger::log_verb = std::atoi(verb.c_str()); } //****************************************** void SETERRVERBOSITY(std::string verb) { //****************************************** std::cout << "Setting ERROR VERB" << std::endl; if (!verb.compare("ERRQUIET")) Logger::err_verb = 0; else if (!verb.compare("FTL")) Logger::err_verb = 1; else if (!verb.compare("WRN")) Logger::err_verb = 2; // else Logger::err_verb = GeneralUtils::StrToInt(verb); std::cout << "Set error verbosity to : " << Logger::err_verb << std::endl; return; } /// Set Trace Option void SETTRACE(bool val) { Logger::showtrace = val; } // ------ ERROR FUNCTIONS ---------- // std::ostream& __OUTERR(int level, const char* filename, const char* funct, int line) { if (Logger::use_colors) std::cerr << RED; switch (level) { case FTL: std::cerr << "[ERR FATAL ]: "; break; case WRN: std::cerr << "[ERR WARN ]: "; break; } if (Logger::use_colors) std::cerr << RESET; // Allows enable error debugging trace if (true or Logger::showtrace) { std::cout << filename << "::" << funct << "[l. " << line << "] : "; } return *(Logger::__ERR_outstream); } // ----------- External Logging ----------- // void SETEXTERNALVERBOSITY(int level) { Logger::external_verb = (level > 0); } void StopTalking() { // Check verbosity set correctly if (!Logger::external_verb) return; // Only redirect if we're not debugging if (Logger::log_verb == (int)DEB) return; std::cout.rdbuf(Logger::redirect_stream.rdbuf()); std::cerr.rdbuf(Logger::redirect_stream.rdbuf()); shhnuisancepythiaitokay_(); fflush(stdout); fflush(stderr); dup2(Logger::silentfd, fileno(stdout)); dup2(Logger::silentfd, fileno(stderr)); } void StartTalking() { // Check verbosity set correctly if (!Logger::external_verb) return; std::cout.rdbuf(Logger::default_cout); std::cerr.rdbuf(Logger::default_cerr); canihaznuisancepythia_(); fflush(stdout); fflush(stderr); dup2(Logger::savedstdoutfd, fileno(stdout)); dup2(Logger::savedstderrfd, fileno(stderr)); } //****************************************** bool LOG_LEVEL(int level) { //****************************************** if (Logger::log_verb == (int)DEB) { return true; } if (Logger::log_verb < (int)level) { return false; } return true; } void SET_TRACE(bool val) { Logger::showtrace = val; } //****************************************** std::ostream& _LOG(int level, const char* filename, const char* func, int line) //****************************************** { return __OUTLOG(level, filename, func, line); } //****************************************** std::ostream& _ERR(int level, const char* filename, const char* func, int line) //****************************************** { if (Logger::use_colors) std::cerr << RED; if (Logger::showtrace) { std::cout << filename << "::" << func << "[l. " << line << "] : "; } switch (level) { case FTL: std::cerr << "[ERR FATAL ]: "; break; case WRN: std::cerr << "[ERR WARN ] : "; break; } if (Logger::use_colors) std::cerr << RESET; return *Logger::__ERR_outstream; } diff --git a/src/Logger/FitLogger.h b/src/Logger/FitLogger.h index ed308ed..e812eae 100644 --- a/src/Logger/FitLogger.h +++ b/src/Logger/FitLogger.h @@ -1,202 +1,202 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FITLOGGER_HPP #define FITLOGGER_HPP /*! * \addtogroup FitBase * @{ */ #include #include #include #include #include "TRandom3.h" #include "Initialiser.h" #include "NuisConfig.h" #define RESET "\033[0m" #define BLACK "\033[30m" /* Black */ #define RED "\033[31m" /* Red */ #define GREEN "\033[32m" /* Green */ #define YELLOW "\033[33m" /* Yellow */ #define BLUE "\033[34m" /* Blue */ #define MAGENTA "\033[35m" /* Magenta */ #define CYAN "\033[36m" /* Cyan */ #define WHITE "\033[37m" /* White */ #define BOLDBLACK "\033[1m\033[30m" /* Bold Black */ #define BOLDRED "\033[1m\033[31m" /* Bold Red */ #define BOLDGREEN "\033[1m\033[32m" /* Bold Green */ #define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */ #define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */ #define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */ #define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */ #define BOLDWHITE "\033[1m\033[37m" /* Bold White */ namespace Logger { extern int log_verb; //!< Current VERBOSITY extern int err_verb; //!< Current ERROR VERBOSITY extern bool external_verb; extern bool use_colors; //!< Use BASH Terminal Colors Flag extern bool super_rainbow_mode; //!< For when fitting gets boring. extern unsigned int super_rainbow_mode_colour; extern bool showtrace; // Quick Tracing for debugging extern int nloggercalls; extern int timelastlog; extern std::streambuf *default_cout; //!< Where the STDOUT stream is currently directed extern std::streambuf *default_cerr; //!< Where the STDERR stream is currently directed extern std::ofstream redirect_stream; //!< Where should unwanted messages be thrown } // namespace Logger /// Returns full path to file currently in #define __FILENAME__ \ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) // ------ LOGGER FUNCTIONS ------------ // namespace Logger { /// NULL Output Stream extern std::ofstream __LOG_nullstream; /// Logging Stream extern std::ostream *__LOG_outstream; } // namespace Logger /// Fitter VERBOSITY Enumerations /// These go through the different depths of the fitter. /// /// 0 QUIET - Little output. /// 1 FIT - Top Level Minimizer Status /// 2 MIN - Output from the FCN Minimizer Functions /// 3 SAM - Output from each of the samples during setup etc /// 4 REC - Output during each reconfigure. Percentage progress etc. /// 5 SIG - Output during every signal event that is found. /// 6 EVT - Output during every event. /// 7 DEB - Will print only debugging info wherever a NUIS_LOG(DEB) statement /// was made enum __LOG_levels { QUIET = 0, FIT, MIN, SAM, REC, SIG, EVT, DEB }; /// Returns log level for a given file/function int __GETLOG_LEVEL(int level, const char *filename, const char *funct); bool LOG_LEVEL(int level); /// Actually runs the logger std::ostream &__OUTLOG(int level, const char *filename, const char *funct, int line); /// Global Logging Definitions #define NUIS_LOGN(level, stream) \ { \ if (LOG_LEVEL(level)) { \ __OUTLOG(level, __FILENAME__, __FUNCTION__, __LINE__) << stream; \ } \ }; /// Global Logging Definitions #define NUIS_LOG(level, stream) NUIS_LOGN(level, stream << std::endl) #define BREAK(level) \ { \ \ if (LOG_LEVEL(level)) { \ __OUTLOG(level, __FILENAME__, __FUNCTION__, __LINE__) << std::endl; \ } \ }; /// Return whether logging level is valid bool LOGGING(int level); /// Set Global Verbosity void SETVERBOSITY(int level); /// Set Global Verbosity from String void SETVERBOSITY(std::string verb); /// Set Global Verbosity void SETERRVERBOSITY(int level); /// Set Global Verbosity from String void SETERRVERBOSITY(std::string verb); /// Set Trace Option void SETTRACE(bool val); // ----------- ERROR FUNCTIONS ---------- // /// Error Stream extern std::ostream *__ERR_outstream; /// Fitter ERROR VERBOSITY Enumerations /// /// 0 QUIET - No Error Output /// 1 FTL - Show errors only if fatal /// 2 WRN - Show Warning messages enum __ERR_levels { ERRQUIET = 0, FTL, WRN }; /// Actually runs the error messager std::ostream &__OUTERR(int level, const char *filename, const char *funct, int line); /// Error Logging Function #define NUIS_ERR(level, stream) \ { \ __OUTERR(level, __FILENAME__, __FUNCTION__, __LINE__) \ << stream << std::endl; \ }; // ----------- ERROR HANDLING ------------- // /// Exit the program with given error message stream #define NUIS_ABORT(stream) \ { \ __OUTERR(FTL, __FILENAME__, __FUNCTION__, __LINE__) \ << stream << std::endl; \ __OUTERR(FTL, __FILENAME__, __FUNCTION__, __LINE__) \ << "Attempting to save output file." << std::endl; \ if (Config::Get().out && Config::Get().out->IsOpen()) { \ Config::Get().out->Write(); \ Config::Get().out->Close(); \ __OUTERR(FTL, __FILENAME__, __FUNCTION__, __LINE__) \ << "Done." << std::endl; \ } else { \ __OUTERR(FTL, __FILENAME__, __FUNCTION__, __LINE__) \ << "No output file set." << std::endl; \ } \ __OUTERR(FTL, __FILENAME__, __FUNCTION__, __LINE__) \ << "Exiting!" << std::endl; \ std::abort(); \ } // ----------- External Logging ----------- // void SETEXTERNALVERBOSITY(int level); void StopTalking(); void StartTalking(); extern "C" { void shhnuisancepythiaitokay_(void); void canihaznuisancepythia_(void); } #endif diff --git a/src/MCStudies/CMakeLists.txt b/src/MCStudies/CMakeLists.txt index 1fae655..602db4c 100644 --- a/src/MCStudies/CMakeLists.txt +++ b/src/MCStudies/CMakeLists.txt @@ -1,83 +1,83 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx GenericFlux_Tester.cxx GenericFlux_Vectors.cxx #MCStudy_KaonPreSelection.cxx MCStudy_MuonValidation.cxx ElectronFlux_FlatTree.cxx T2K2017_FakeData.cxx MCStudy_CCQEHistograms.cxx OfficialNIWGPlots.cxx Smearceptance_Tester.cxx Simple_Osc.cxx Smear_SVDUnfold_Propagation_Osc.cxx SigmaEnuHists.cxx ) set(HEADERFILES ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h GenericFlux_Tester.h GenericFlux_Vectors.h #MCStudy_KaonPreSelection.h MCStudy_MuonValidation.h ElectronFlux_FlatTree.h T2K2017_FakeData.h MCStudy_CCQEHistograms.h OfficialNIWGPlots.h Smearceptance_Tester.h Simple_Osc.h Smear_SVDUnfold_Propagation_Osc.h SigmaEnuHists.h ) set(LIBNAME MCStudies) 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(${MINIMUM_INCLUDE_DIRECTORIES}) # Needed for experiment specific signal flags include_directories(${CMAKE_SOURCE_DIR}/src/T2K) include_directories(${CMAKE_SOURCE_DIR}/src/MINERvA) include_directories(${CMAKE_SOURCE_DIR}/src/Smearceptance) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() if(USE_PROB3PP) add_dependencies(${LIBNAME} prob3pp) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/MCStudies) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MCStudies/ElectronFlux_FlatTree.cxx b/src/MCStudies/ElectronFlux_FlatTree.cxx index 7411811..846f029 100644 --- a/src/MCStudies/ElectronFlux_FlatTree.cxx +++ b/src/MCStudies/ElectronFlux_FlatTree.cxx @@ -1,559 +1,559 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ElectronFlux_FlatTree.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement ElectronFlux_FlatTree::ElectronFlux_FlatTree(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); // 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 = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); NUIS_LOG(SAM," Generic Flux Scaling Factor = " << fScaleFactor); if (fScaleFactor <= 0.0) { NUIS_ERR(WRN,"SCALE FACTOR TOO LOW "); sleep(20); } // Setup our TTrees this->AddEventVariablesToTree(); this->AddSignalFlagsToTree(); } void ElectronFlux_FlatTree::AddEventVariablesToTree() { // Setup the TTree to save everything if (!eventVariables) { Config::Get().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding Event Variables"); 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("Nother", &Nother, "Nother/I"); 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) { 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 ElectronFlux_FlatTree::AddSignalFlagsToTree() { if (!eventVariables) { Config::Get().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding Samples" ); // 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"); }; //******************************************************************** void ElectronFlux_FlatTree::FillEventVariables(FitEvent *event) { //******************************************************************** // Fill Signal Variables FillSignalFlags(event); NUIS_LOG(DEB, "Filling signal"); // 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); (*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 and event->PartInfo(i)->Status() == kFinalState; if (!part_alive) continue; // PDG Particle int PDGpart = event->PartInfo(i)->fPID; TLorentzVector part_4mom = event->PartInfo(i)->fP; Nparticles++; // Get Charged Lepton if (PDGpart == 11){ 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.; 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; } } else { Nother++; } } // 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 && 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 (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 = GetFluxHistogram()->GetBinContent(GetFluxHistogram()->FindBin(Enu)) / GetFluxHistogram()->Integral(); xsecScaling = fScaleFactor; if (fScaleFactor <= 0.0) { NUIS_ERR(WRN, "SCALE FACTOR TOO LOW "); sleep(20); } // Fill the eventVariables Tree eventVariables->Fill(); return; }; //******************************************************************** void ElectronFlux_FlatTree::Write(std::string drawOpt) { //******************************************************************** // First save the TTree eventVariables->Write(); // Save Flux and Event Histograms too GetInput()->GetFluxHistogram()->Write(); GetInput()->GetEventHistogram()->Write(); return; } //******************************************************************** void ElectronFlux_FlatTree::FillSignalFlags(FitEvent *event) { //******************************************************************** // Some example flags are given from SignalDef. // See src/Utils/SignalDef.cxx for more. int nuPDG = event->PartInfo(0)->fPID; // Generic signal flags 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); } // ------------------------------------------------------------------- // Purely MC Plot // Following functions are just overrides to handle this // ------------------------------------------------------------------- //******************************************************************** /// Everything is classed as signal... bool ElectronFlux_FlatTree::isSignal(FitEvent *event) { //******************************************************************** (void)event; return true; }; //******************************************************************** void ElectronFlux_FlatTree::ScaleEvents() { //******************************************************************** // Saving everything to a TTree so no scaling required return; } //******************************************************************** void ElectronFlux_FlatTree::ApplyNormScale(float norm) { //******************************************************************** // Saving everything to a TTree so no scaling required this->fCurrentNorm = norm; return; } //******************************************************************** void ElectronFlux_FlatTree::FillHistograms() { //******************************************************************** // No Histograms need filling........ return; } //******************************************************************** void ElectronFlux_FlatTree::ResetAll() { //******************************************************************** eventVariables->Reset(); return; } //******************************************************************** float ElectronFlux_FlatTree::GetChi2() { //******************************************************************** // No Likelihood to test, purely MC return 0.0; } diff --git a/src/MCStudies/ElectronFlux_FlatTree.h b/src/MCStudies/ElectronFlux_FlatTree.h index 568e8d0..c167208 100644 --- a/src/MCStudies/ElectronFlux_FlatTree.h +++ b/src/MCStudies/ElectronFlux_FlatTree.h @@ -1,188 +1,188 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ElectronFlux_FlatTree_H_SEEN #define ElectronFlux_FlatTree_H_SEEN #include "Measurement1D.h" //******************************************************************** class ElectronFlux_FlatTree : public Measurement1D { //******************************************************************** public: ElectronFlux_FlatTree(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~ElectronFlux_FlatTree() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Fill Custom Histograms void FillHistograms(); //! ResetAll void ResetAll(); //! Scale void ScaleEvents(); //! Norm void ApplyNormScale(float norm); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); //! Get Chi2 float GetChi2(); //! Fill all signal flags we currently have void FillSignalFlags(FitEvent *event); void AddEventVariablesToTree(); void AddSignalFlagsToTree(); private: // Lighter flat trees that don't include vectors bool liteMode; TTree* eventVariables; TLorentzVector *nu_4mom; TLorentzVector *pmu; TLorentzVector *ppip; TLorentzVector *ppim; TLorentzVector *ppi0; TLorentzVector *pprot; TLorentzVector *pneut; // Saved Variables float Enu_true; float Enu_QE; int PDGnu; float Q2_true; float Q2_QE; float W_nuc_rest; float bjorken_x; float bjorken_y; int Mode; int Nprotons; int Nneutrons; int Npiplus; int Npineg; int Npi0; int PDGLep; float TLep; float CosLep; float ELep; float PLep; float MLep; float PPr; //!< Highest Mom Proton float CosPr; //!< Highest Mom Proton float EPr; float TPr; float MPr; float PNe; float CosNe; float ENe; float TNe; float MNe; float PPiP; float CosPiP; float EPiP; float TPiP; float MPiP; float PPiN; float CosPiN; float EPiN; float TPiN; float MPiN; float PPi0; float CosPi0; float EPi0; float TPi0; float MPi0; float CosPmuPpip; float CosPmuPpim; float CosPmuPpi0; float CosPmuPprot; float CosPmuPneut; float CosPpipPprot; float CosPpipPneut; float CosPpipPpim; float CosPpipPpi0; float CosPpimPprot; float CosPpimPneut; float CosPpimPpi0; float CosPi0Pprot; float CosPi0Pneut; float CosPprotPneut; float q0_true; float q3_true; int Nparticles; int Nleptons; int Nother; float Erecoil_true; float Erecoil_charged; float Erecoil_minerva; float Weight; float RWWeight; float InputWeight; float FluxWeight; // Generic signal flags bool flagCCINC; bool flagNCINC; bool flagCCQE; bool flagCC0pi; bool flagCCQELike; bool flagNCEL; bool flagNC0pi; bool flagCCcoh; bool flagNCcoh; bool flagCC1pip; bool flagNC1pip; bool flagCC1pim; bool flagNC1pim; bool flagCC1pi0; bool flagNC1pi0; float xsecScaling; }; #endif diff --git a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx index 971fa22..4e0201c 100644 --- a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx +++ b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.cxx @@ -1,154 +1,154 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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); // Use the name to define what variable to measure int nbins = 0; double binlow = 0.0; double binhigh = 0.0; 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; } // 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 = (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; } 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_1DVar_FakeStudy.h b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h index 7a7546f..af8c3ca 100644 --- a/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h +++ b/src/MCStudies/ExpMultDist_CCQE_XSec_1DVar_FakeStudy.h @@ -1,45 +1,45 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ExpMultDist_CCQE_XSec_1DVar_FakeStudy_H_SEEN #define ExpMultDist_CCQE_XSec_1DVar_FakeStudy_H_SEEN #include "Measurement1D.h" //******************************************************************** class ExpMultDist_CCQE_XSec_1DVar_FakeStudy : public Measurement1D { //******************************************************************** public: ExpMultDist_CCQE_XSec_1DVar_FakeStudy(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~ExpMultDist_CCQE_XSec_1DVar_FakeStudy() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Define this samples signal bool isSignal(FitEvent *nvect); private: double q2qe, Tmu, CosThetaMu; int plottype; }; #endif diff --git a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx index cc6d26d..0f4c456 100644 --- a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx +++ b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.cxx @@ -1,172 +1,172 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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); // Use the name to define what variable to measure int nbinsx = 0; int nbinsy = 0; double binlowx = 0.0; double binhighx = 0.0; double binlowy = 0.0; double binhighy = 0.0; 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 = (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; } 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/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h index 4fe9169..a99e0ae 100644 --- a/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h +++ b/src/MCStudies/ExpMultDist_CCQE_XSec_2DVar_FakeStudy.h @@ -1,45 +1,45 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ExpMultDist_CCQE_XSec_2DVar_FakeStudy_H_SEEN #define ExpMultDist_CCQE_XSec_2DVar_FakeStudy_H_SEEN #include "Measurement2D.h" //******************************************************************** class ExpMultDist_CCQE_XSec_2DVar_FakeStudy : public Measurement2D { //******************************************************************** public: ExpMultDist_CCQE_XSec_2DVar_FakeStudy(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~ExpMultDist_CCQE_XSec_2DVar_FakeStudy() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Define this samples signal bool isSignal(FitEvent *nvect); private: double q2qe, Tmu, CosThetaMu; int plottype; }; #endif diff --git a/src/MCStudies/GenericFlux_Tester.cxx b/src/MCStudies/GenericFlux_Tester.cxx index 959a1bd..7133c08 100644 --- a/src/MCStudies/GenericFlux_Tester.cxx +++ b/src/MCStudies/GenericFlux_Tester.cxx @@ -1,591 +1,591 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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 = 1E10; // 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); // 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 = Config::Get().GetParB("isLiteMode"); if (Config::HasPar("EnuMin")) { EnuMin = Config::GetParD("EnuMin"); } if (Config::HasPar("EnuMax")) { EnuMax = Config::GetParD("EnuMax"); } // 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. // N.B. MeasurementBase::PredictedEventRate includes the 1E-38 factor that is // often included here in other classes that directly integrate the event // histogram. This method is used here as it now respects EnuMin and EnuMax // correctly. this->fScaleFactor = (this->PredictedEventRate("width", 0, 1000) / double(fNEvents)) / this->TotalIntegratedFlux(); if (fScaleFactor <= 0.0) { NUIS_ABORT("SCALE FACTOR TOO LOW "); } NUIS_LOG(SAM, " Generic Flux Scaling Factor = " << fScaleFactor << " [= " << (GetEventHistogram()->Integral("width") * 1E-38) << "/(" << (fNEvents + 0.) << "*" << this->TotalIntegratedFlux() << ")]"); // Setup our TTrees this->AddEventVariablesToTree(); this->AddSignalFlagsToTree(); } void GenericFlux_Tester::AddEventVariablesToTree() { // Setup the TTree to save everything if (!eventVariables) { Config::Get().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding Event Variables"); 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"); // all sensible eventVariables->Branch("MLep", &MLep, "MLep/F"); eventVariables->Branch("ELep", &ELep, "ELep/F"); // negative -999 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("Nother", &Nother, "Nother/I"); 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) { 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) { Config::Get().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding signal flags"); // 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"); }; //******************************************************************** void GenericFlux_Tester::ResetVariables() { //******************************************************************** // Reset neutrino PDG PDGnu = 0; // Reset energies Enu_true = Enu_QE = __BAD_FLOAT__; // Reset auxillaries Q2_true = Q2_QE = W_nuc_rest = bjorken_x = bjorken_y = q0_true = q3_true = Erecoil_true = Erecoil_charged = Erecoil_minerva = __BAD_FLOAT__; // Reset particle counters Nparticles = Nleptons = Nother = Nprotons = Nneutrons = Npiplus = Npineg = Npi0 = 0; // Reset Lepton PDG PDGLep = 0; // Reset Lepton variables TLep = CosLep = ELep = PLep = MLep = __BAD_FLOAT__; // Rset proton variables PPr = CosPr = EPr = TPr = MPr = __BAD_FLOAT__; // Reset neutron variables PNe = CosNe = ENe = TNe = MNe = __BAD_FLOAT__; // Reset pi+ variables PPiP = CosPiP = EPiP = TPiP = MPiP = __BAD_FLOAT__; // Reset pi- variables PPiN = CosPiN = EPiN = TPiN = MPiN = __BAD_FLOAT__; // Reset pi0 variables PPi0 = CosPi0 = EPi0 = TPi0 = MPi0 = __BAD_FLOAT__; // Reset the cos angles CosPmuPpip = CosPmuPpim = CosPmuPpi0 = CosPmuPprot = CosPmuPneut = CosPpipPprot = CosPpipPneut = CosPpipPpim = CosPpipPpi0 = CosPpimPprot = CosPpimPneut = CosPpimPpi0 = CosPi0Pprot = CosPi0Pneut = CosPprotPneut = __BAD_FLOAT__; } //******************************************************************** void GenericFlux_Tester::FillEventVariables(FitEvent *event) { //******************************************************************** // Fill Signal Variables FillSignalFlags(event); NUIS_LOG(DEB, "Filling signal"); // Reset the private variables (see header) ResetVariables(); // Function used to extract any variables of interest to the event Mode = event->Mode; // Reset the highest momentum variables float proton_highmom = __BAD_FLOAT__; float neutron_highmom = __BAD_FLOAT__; float piplus_highmom = __BAD_FLOAT__; float pineg_highmom = __BAD_FLOAT__; float pi0_highmom = __BAD_FLOAT__; (*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); (*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 and event->PartInfo(i)->Status() == kFinalState; 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.; 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; } } else { Nother++; } } // 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 && 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 (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 = GetFluxHistogram()->GetBinContent(GetFluxHistogram()->FindBin(Enu)) / GetFluxHistogram()->Integral(); // 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; // Generic signal flags 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); } // ------------------------------------------------------------------- // 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/GenericFlux_Tester.h b/src/MCStudies/GenericFlux_Tester.h index a14cc0e..5cfa030 100644 --- a/src/MCStudies/GenericFlux_Tester.h +++ b/src/MCStudies/GenericFlux_Tester.h @@ -1,199 +1,199 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GenericFlux_Tester_H_SEEN #define GenericFlux_Tester_H_SEEN #include "Measurement1D.h" #ifndef __BAD__FLOAT__ #define __BAD_FLOAT__ -999.99 #endif //******************************************************************** class GenericFlux_Tester : public Measurement1D { //******************************************************************** public: GenericFlux_Tester(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~GenericFlux_Tester() {}; //! Clear private variables inline void ResetVariables(); //! Grab info from event void FillEventVariables(FitEvent *event); //! Fill Custom Histograms void FillHistograms(); //! ResetAll void ResetAll(); //! Scale void ScaleEvents(); //! Norm void ApplyNormScale(float norm); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); //! Get Chi2 float GetChi2(); //! Fill all signal flags we currently have void FillSignalFlags(FitEvent *event); void AddEventVariablesToTree(); void AddSignalFlagsToTree(); private: // Lighter flat trees that don't include vectors bool liteMode; TTree* eventVariables; TLorentzVector *nu_4mom; TLorentzVector *pmu; TLorentzVector *ppip; TLorentzVector *ppim; TLorentzVector *ppi0; TLorentzVector *pprot; TLorentzVector *pneut; // Saved Variables float Enu_true; float Enu_QE; int PDGnu; // Auxillairies float Q2_true; float Q2_QE; float W_nuc_rest; float bjorken_x; float bjorken_y; float q0_true; float q3_true; float Erecoil_true; float Erecoil_charged; float Erecoil_minerva; // Interaction mode int Mode; // Particle counters int Nparticles; int Nleptons; int Nother; int Nprotons; int Nneutrons; int Npiplus; int Npineg; int Npi0; // Lepton variables int PDGLep; float TLep; float CosLep; float ELep; float PLep; float MLep; // Proton variables float PPr; //!< Highest Mom Proton float CosPr; //!< Highest Mom Proton float EPr; float TPr; float MPr; // Neutron variables float PNe; float CosNe; float ENe; float TNe; float MNe; // Pi+ variables float PPiP; float CosPiP; float EPiP; float TPiP; float MPiP; // Pi- variables float PPiN; float CosPiN; float EPiN; float TPiN; float MPiN; float PPi0; float CosPi0; float EPi0; float TPi0; float MPi0; // Angular variables float CosPmuPpip; float CosPmuPpim; float CosPmuPpi0; float CosPmuPprot; float CosPmuPneut; float CosPpipPprot; float CosPpipPneut; float CosPpipPpim; float CosPpipPpi0; float CosPpimPprot; float CosPpimPneut; float CosPpimPpi0; float CosPi0Pprot; float CosPi0Pneut; float CosPprotPneut; // Weights float Weight; float RWWeight; float InputWeight; float FluxWeight; // Generic signal flags bool flagCCINC; bool flagNCINC; bool flagCCQE; bool flagCC0pi; bool flagCCQELike; bool flagNCEL; bool flagNC0pi; bool flagCCcoh; bool flagNCcoh; bool flagCC1pip; bool flagNC1pip; bool flagCC1pim; bool flagNC1pim; bool flagCC1pi0; bool flagNC1pi0; }; #endif diff --git a/src/MCStudies/GenericFlux_Vectors.cxx b/src/MCStudies/GenericFlux_Vectors.cxx index 2fc224f..1dacc51 100644 --- a/src/MCStudies/GenericFlux_Vectors.cxx +++ b/src/MCStudies/GenericFlux_Vectors.cxx @@ -1,502 +1,502 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GenericFlux_Vectors.h" #ifndef __NO_MINERvA__ #include "MINERvA_SignalDef.h" #endif #ifndef __NO_T2K__ #include "T2K_SignalDef.h" #endif GenericFlux_Vectors::GenericFlux_Vectors(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 = 1E10; // Arbritrarily high energy limit if (Config::HasPar("EnuMin")) { EnuMin = Config::GetParD("EnuMin"); } if (Config::HasPar("EnuMax")) { EnuMax = Config::GetParD("EnuMax"); } SavePreFSI = Config::Get().GetParB("nuisflat_SavePreFSI"); NUIS_LOG(SAM, "Running GenericFlux_Vectors saving pre-FSI particles? " << SavePreFSI); SaveSignalFlags = Config::Get().GetParB("nuisflat_SaveSignalFlags"); NUIS_LOG(SAM, "Running GenericFlux_Vectors saving signal flags? " << SaveSignalFlags); // 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); eventVariables = NULL; // 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. // N.B. MeasurementBase::PredictedEventRate includes the 1E-38 factor that is // often included here in other classes that directly integrate the event // histogram. This method is used here as it now respects EnuMin and EnuMax // correctly. this->fScaleFactor = (this->PredictedEventRate("width", 0, EnuMax) / double(fNEvents)) / this->TotalIntegratedFlux("width"); - NUIS_LOG(SAM, " Generic Flux Scaling Factor = " + NUIS_LOG(SAM, "Generic Flux Scaling Factor = " << fScaleFactor << " [= " << (GetEventHistogram()->Integral("width") * 1E-38) << "/(" << (fNEvents + 0.) << "*" << TotalIntegratedFlux("width") << ")]"); if (fScaleFactor <= 0.0) { NUIS_ABORT("SCALE FACTOR TOO LOW"); } // Setup our TTrees this->AddEventVariablesToTree(); if (SaveSignalFlags) this->AddSignalFlagsToTree(); } void GenericFlux_Vectors::AddEventVariablesToTree() { // Setup the TTree to save everything if (!eventVariables) { Config::Get().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding Event Variables"); eventVariables->Branch("Mode", &Mode, "Mode/I"); eventVariables->Branch("cc", &cc, "cc/B"); eventVariables->Branch("PDGnu", &PDGnu, "PDGnu/I"); eventVariables->Branch("Enu_true", &Enu_true, "Enu_true/F"); eventVariables->Branch("tgt", &tgt, "tgt/I"); eventVariables->Branch("tgta", &tgta, "tgta/I"); eventVariables->Branch("tgtz", &tgtz, "tgtz/I"); eventVariables->Branch("PDGLep", &PDGLep, "PDGLep/I"); eventVariables->Branch("ELep", &ELep, "ELep/F"); eventVariables->Branch("CosLep", &CosLep, "CosLep/F"); // Basic interaction kinematics eventVariables->Branch("Q2", &Q2, "Q2/F"); eventVariables->Branch("q0", &q0, "q0/F"); eventVariables->Branch("q3", &q3, "q3/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("W", &W, "W/F"); eventVariables->Branch("W_genie", &W_genie, "W_genie/F"); eventVariables->Branch("x", &x, "x/F"); eventVariables->Branch("y", &y, "y/F"); eventVariables->Branch("Eav", &Eav, "Eav/F"); eventVariables->Branch("EavAlt", &EavAlt, "EavAlt/F"); eventVariables->Branch("CosThetaAdler", &CosThetaAdler, "CosThetaAdler/F"); eventVariables->Branch("PhiAdler", &PhiAdler, "PhiAdler/F"); eventVariables->Branch("dalphat", &dalphat, "dalphat/F"); eventVariables->Branch("dpt", &dpt, "dpt/F"); eventVariables->Branch("dphit", &dphit, "dphit/F"); eventVariables->Branch("pnreco_C", &pnreco_C, "pnreco_C/F"); // Save outgoing particle vectors eventVariables->Branch("nfsp", &nfsp, "nfsp/I"); eventVariables->Branch("px", px, "px[nfsp]/F"); eventVariables->Branch("py", py, "py[nfsp]/F"); eventVariables->Branch("pz", pz, "pz[nfsp]/F"); eventVariables->Branch("E", E, "E[nfsp]/F"); eventVariables->Branch("pdg", pdg, "pdg[nfsp]/I"); eventVariables->Branch("pdg_rank", pdg_rank, "pdg_rank[nfsp]/I"); // Save init particle vectors eventVariables->Branch("ninitp", &ninitp, "ninitp/I"); eventVariables->Branch("px_init", px_init, "px_init[ninitp]/F"); eventVariables->Branch("py_init", py_init, "py_init[ninitp]/F"); eventVariables->Branch("pz_init", pz_init, "pz_init[ninitp]/F"); eventVariables->Branch("E_init", E_init, "E_init[ninitp]/F"); eventVariables->Branch("pdg_init", pdg_init, "pdg_init[ninitp]/I"); // Save pre-FSI vectors eventVariables->Branch("nvertp", &nvertp, "nvertp/I"); eventVariables->Branch("px_vert", px_vert, "px_vert[nvertp]/F"); eventVariables->Branch("py_vert", py_vert, "py_vert[nvertp]/F"); eventVariables->Branch("pz_vert", pz_vert, "pz_vert[nvertp]/F"); eventVariables->Branch("E_vert", E_vert, "E_vert[nvertp]/F"); eventVariables->Branch("pdg_vert", pdg_vert, "pdg_vert[nvertp]/I"); // Event Scaling Information eventVariables->Branch("Weight", &Weight, "Weight/F"); eventVariables->Branch("InputWeight", &InputWeight, "InputWeight/F"); eventVariables->Branch("RWWeight", &RWWeight, "RWWeight/F"); // Should be a double because may be 1E-39 and less eventVariables->Branch("fScaleFactor", &fScaleFactor, "fScaleFactor/D"); // The customs eventVariables->Branch("CustomWeight", &CustomWeight, "CustomWeight/F"); eventVariables->Branch("CustomWeightArray", CustomWeightArray, "CustomWeightArray[6]/F"); return; } void GenericFlux_Vectors::FillEventVariables(FitEvent *event) { ResetVariables(); // Fill Signal Variables if (SaveSignalFlags) FillSignalFlags(event); NUIS_LOG(DEB, "Filling signal"); // Now fill the information Mode = event->Mode; cc = event->IsCC(); // Get the incoming neutrino and outgoing lepton FitParticle *nu = event->GetBeamPart(); FitParticle *lep = event->GetHMFSAnyLepton(); PDGnu = nu->fPID; Enu_true = nu->fP.E() / 1E3; tgt = event->fTargetPDG; tgta = event->fTargetA; tgtz = event->fTargetZ; TLorentzVector ISP4 = nu->fP; if (lep != NULL) { PDGLep = lep->fPID; ELep = lep->fP.E() / 1E3; CosLep = cos(nu->fP.Vect().Angle(lep->fP.Vect())); // Basic interaction kinematics Q2 = -1 * (nu->fP - lep->fP).Mag2() / 1E6; q0 = (nu->fP - lep->fP).E() / 1E3; q3 = (nu->fP - lep->fP).Vect().Mag() / 1E3; // These assume C12 binding from MINERvA... not ideal Enu_QE = FitUtils::EnuQErec(lep->fP, CosLep, 34., true); Q2_QE = FitUtils::Q2QErec(lep->fP, CosLep, 34., true); Eav = FitUtils::GetErecoil_MINERvA_LowRecoil(event) / 1.E3; EavAlt = FitUtils::Eavailable(event) / 1.E3; // Check if this is a 1pi+ or 1pi0 event if ((SignalDef::isCC1pi(event, PDGnu, 211) || SignalDef::isCC1pi(event, PDGnu, -211) || SignalDef::isCC1pi(event, PDGnu, 111)) && event->NumFSNucleons() == 1) { TLorentzVector Pnu = nu->fP; TLorentzVector Pmu = lep->fP; TLorentzVector Ppi = event->GetHMFSPions()->fP; TLorentzVector Pprot = event->GetHMFSNucleons()->fP; CosThetaAdler = FitUtils::CosThAdler(Pnu, Pmu, Ppi, Pprot); PhiAdler = FitUtils::PhiAdler(Pnu, Pmu, Ppi, Pprot); } // Get W_true with assumption of initial state nucleon at rest float m_n = (float)PhysConst::mass_proton; // Q2 assuming nucleon at rest W_nuc_rest = sqrt(-Q2 + 2 * m_n * q0 + m_n * m_n); W = W_nuc_rest; // For want of a better thing to do // True Q2 x = Q2 / (2 * m_n * q0); y = 1 - ELep / Enu_true; dalphat = FitUtils::Get_STV_dalphat_HMProton(event, PDGnu, true); dpt = FitUtils::Get_STV_dpt_HMProton(event, PDGnu, true); dphit = FitUtils::Get_STV_dphit_HMProton(event, PDGnu, true); pnreco_C = FitUtils::Get_pn_reco_C_HMProton(event, PDGnu, true); } // Loop over the particles and store all the final state particles in a vector for (UInt_t i = 0; i < event->Npart(); ++i) { if (event->PartInfo(i)->fIsAlive && event->PartInfo(i)->Status() == kFinalState) partList.push_back(event->PartInfo(i)); if (SavePreFSI && event->fPrimaryVertex[i]) vertList.push_back(event->PartInfo(i)); if (SavePreFSI && event->PartInfo(i)->IsInitialState()) initList.push_back(event->PartInfo(i)); if (event->PartInfo(i)->IsInitialState()) { ISP4 += event->PartInfo(i)->fP; } } // Save outgoing particle vectors nfsp = (int)partList.size(); std::map > > pdgMap; for (int i = 0; i < nfsp; ++i) { px[i] = partList[i]->fP.X() / 1E3; py[i] = partList[i]->fP.Y() / 1E3; pz[i] = partList[i]->fP.Z() / 1E3; E[i] = partList[i]->fP.E() / 1E3; pdg[i] = partList[i]->fPID; pdgMap[pdg[i]].push_back(std::make_pair(partList[i]->fP.Vect().Mag(), i)); } for (std::map > >::iterator iter = pdgMap.begin(); iter != pdgMap.end(); ++iter) { std::vector > thisVect = iter->second; std::sort(thisVect.begin(), thisVect.end()); // Now save the order... a bit funky to avoid inverting int nPart = (int)thisVect.size() - 1; for (int i = nPart; i >= 0; --i) { pdg_rank[thisVect[i].second] = nPart - i; } } // Save pre-FSI particles nvertp = (int)vertList.size(); for (int i = 0; i < nvertp; ++i) { px_vert[i] = vertList[i]->fP.X() / 1E3; py_vert[i] = vertList[i]->fP.Y() / 1E3; pz_vert[i] = vertList[i]->fP.Z() / 1E3; E_vert[i] = vertList[i]->fP.E() / 1E3; pdg_vert[i] = vertList[i]->fPID; } // Save init particles ninitp = (int)initList.size(); for (int i = 0; i < ninitp; ++i) { px_init[i] = initList[i]->fP.X() / 1E3; py_init[i] = initList[i]->fP.Y() / 1E3; pz_init[i] = initList[i]->fP.Z() / 1E3; E_init[i] = initList[i]->fP.E() / 1E3; pdg_init[i] = initList[i]->fPID; } #ifdef __GENIE_ENABLED__ if (event->fType == kGENIE) { EventRecord *gevent = static_cast(event->genie_event->event); const Interaction *interaction = gevent->Summary(); const Kinematics &kine = interaction->Kine(); W_genie = kine.W(); } #endif // Fill event weights Weight = event->RWWeight * event->InputWeight; RWWeight = event->RWWeight; InputWeight = event->InputWeight; // And the Customs CustomWeight = event->CustomWeight; for (int i = 0; i < 6; ++i) { CustomWeightArray[i] = event->CustomWeightArray[i]; } // Fill the eventVariables Tree eventVariables->Fill(); return; }; //******************************************************************** void GenericFlux_Vectors::ResetVariables() { //******************************************************************** cc = false; // Reset all Function used to extract any variables of interest to the event Mode = PDGnu = tgt = tgta = tgtz = PDGLep = 0; Enu_true = ELep = CosLep = Q2 = q0 = q3 = Enu_QE = Q2_QE = W_nuc_rest = W = x = y = Eav = EavAlt = CosThetaAdler = PhiAdler = -999.9; W_genie = -999; // Other fun variables // MINERvA-like ones dalphat = dpt = dphit = pnreco_C = -999.99; nfsp = ninitp = nvertp = 0; for (int i = 0; i < kMAX; ++i) { px[i] = py[i] = pz[i] = E[i] = -999; pdg[i] = pdg_rank[i] = 0; px_init[i] = py_init[i] = pz_init[i] = E_init[i] = -999; pdg_init[i] = 0; px_vert[i] = py_vert[i] = pz_vert[i] = E_vert[i] = -999; pdg_vert[i] = 0; } Weight = InputWeight = RWWeight = 0.0; CustomWeight = 0.0; for (int i = 0; i < 6; ++i) CustomWeightArray[i] = 0.0; partList.clear(); initList.clear(); vertList.clear(); flagCCINC = flagNCINC = flagCCQE = flagCC0pi = flagCCQELike = flagNCEL = flagNC0pi = flagCCcoh = flagNCcoh = flagCC1pip = flagNC1pip = flagCC1pim = flagNC1pim = flagCC1pi0 = flagNC1pi0 = false; #ifndef __NO_MINERvA__ flagCC0piMINERvA = false; #endif #ifndef __NO_T2K__ flagCC0Pi_T2K_AnaI = false; flagCC0Pi_T2K_AnaII = false; #endif } //******************************************************************** void GenericFlux_Vectors::FillSignalFlags(FitEvent *event) { //******************************************************************** // Some example flags are given from SignalDef. // See src/Utils/SignalDef.cxx for more. int nuPDG = event->PartInfo(0)->fPID; // Generic signal flags 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); #ifndef __NO_MINERvA__ flagCC0piMINERvA = SignalDef::isCC0pi_MINERvAPTPZ(event, 14); #endif #ifndef __NO_T2K__ flagCC0Pi_T2K_AnaI = SignalDef::isT2K_CC0pi(event, EnuMin, EnuMax, SignalDef::kAnalysis_I); flagCC0Pi_T2K_AnaII = SignalDef::isT2K_CC0pi(event, EnuMin, EnuMax, SignalDef::kAnalysis_II); #endif } void GenericFlux_Vectors::AddSignalFlagsToTree() { if (!eventVariables) { Config::Get().out->cd(); eventVariables = new TTree((this->fName + "_VARS").c_str(), (this->fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding signal flags"); // 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"); #ifndef __NO_MINERvA__ eventVariables->Branch("flagCC0piMINERvA", &flagCC0piMINERvA, "flagCC0piMINERvA/O"); #endif #ifndef __NO_T2K__ eventVariables->Branch("flagCC0Pi_T2K_AnaI", &flagCC0Pi_T2K_AnaI, "flagCC0Pi_T2K_AnaI/O"); eventVariables->Branch("flagCC0Pi_T2K_AnaII", &flagCC0Pi_T2K_AnaII, "flagCC0Pi_T2K_AnaII/O"); #endif }; void GenericFlux_Vectors::Write(std::string drawOpt) { // First save the TTree eventVariables->Write(); // Save Flux and Event Histograms too GetInput()->GetFluxHistogram()->Write(); GetInput()->GetEventHistogram()->Write(); return; } // Override functions which aren't really necessary bool GenericFlux_Vectors::isSignal(FitEvent *event) { (void)event; return true; }; void GenericFlux_Vectors::ScaleEvents() { return; } void GenericFlux_Vectors::ApplyNormScale(float norm) { this->fCurrentNorm = norm; return; } void GenericFlux_Vectors::FillHistograms() { return; } void GenericFlux_Vectors::ResetAll() { // eventVariables->Reset(); return; } float GenericFlux_Vectors::GetChi2() { return 0.0; } diff --git a/src/MCStudies/GenericFlux_Vectors.h b/src/MCStudies/GenericFlux_Vectors.h index 0b1f4a4..e15c65c 100644 --- a/src/MCStudies/GenericFlux_Vectors.h +++ b/src/MCStudies/GenericFlux_Vectors.h @@ -1,166 +1,166 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GenericFlux_Vectors_H_SEEN #define GenericFlux_Vectors_H_SEEN #include "Measurement1D.h" #include "FitEvent.h" class GenericFlux_Vectors : public Measurement1D { public: GenericFlux_Vectors(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~GenericFlux_Vectors() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Fill signal flags void FillSignalFlags(FitEvent *event); void ResetVariables(); //! Fill Custom Histograms void FillHistograms(); //! ResetAll void ResetAll(); //! Scale void ScaleEvents(); //! Norm void ApplyNormScale(float norm); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); //! Get Chi2 float GetChi2(); void AddEventVariablesToTree(); void AddSignalFlagsToTree(); private: TTree* eventVariables; std::vector partList; std::vector initList; std::vector vertList; bool SavePreFSI; bool SaveSignalFlags; int Mode; bool cc; int PDGnu; int tgt; int tgta; int tgtz; int PDGLep; float ELep; float CosLep; // Basic interaction kinematics float Q2; float q0; float q3; float Enu_QE; float Enu_true; float Q2_QE; float W_nuc_rest; float W; float x; float y; float Eav; float EavAlt; float dalphat; float W_genie; float dpt; float dphit; float pnreco_C; float CosThetaAdler; float PhiAdler; // Save outgoing particle vectors int nfsp; static const int kMAX = 200; float px[kMAX]; float py[kMAX]; float pz[kMAX]; float E[kMAX]; int pdg[kMAX]; int pdg_rank[kMAX]; // Save incoming particle info int ninitp; float px_init[kMAX]; float py_init[kMAX]; float pz_init[kMAX]; float E_init[kMAX]; int pdg_init[kMAX]; // Save pre-FSI particle info int nvertp; float px_vert[kMAX]; float py_vert[kMAX]; float pz_vert[kMAX]; float E_vert[kMAX]; int pdg_vert[kMAX]; // Basic event info float Weight; float InputWeight; float RWWeight; double fScaleFactor; // Custom weights float CustomWeight; float CustomWeightArray[6]; // Generic signal flags bool flagCCINC; bool flagNCINC; bool flagCCQE; bool flagCC0pi; bool flagCCQELike; bool flagNCEL; bool flagNC0pi; bool flagCCcoh; bool flagNCcoh; bool flagCC1pip; bool flagNC1pip; bool flagCC1pim; bool flagNC1pim; bool flagCC1pi0; bool flagNC1pi0; #ifndef __NO_MINERvA__ bool flagCC0piMINERvA; #endif bool flagCC0Pi_T2K_AnaI; bool flagCC0Pi_T2K_AnaII; }; #endif diff --git a/src/MCStudies/MCStudy_CCQEHistograms.cxx b/src/MCStudies/MCStudy_CCQEHistograms.cxx index a232b54..17f10fd 100644 --- a/src/MCStudies/MCStudy_CCQEHistograms.cxx +++ b/src/MCStudies/MCStudy_CCQEHistograms.cxx @@ -1,230 +1,230 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MCStudy_CCQEHistograms.h" #include "T2K_SignalDef.h" #include "MINERvA_SignalDef.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement MCStudy_CCQEHistograms::MCStudy_CCQEHistograms(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->TotalIntegratedFlux(); hist_Enu = new TH1D("MCStudy_CCQE_Enu","MCStudy_CCQE_Enu",30,0.0,2.0); hist_TLep = new TH1D("MCStudy_CCQE_TLep","MCStudy_CCQE_TLep",30,0.0,4.0); hist_CosLep = new TH1D("MCStudy_CCQE_CosLep","MCStudy_CCQE_CosLep",30,-1.0,1.0); hist_Q2 = new TH1D("MCStudy_CCQE_Q2;Q^{2} (GeV^{2});d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})","MCStudy_CCQE_Q2",30,0.0,3.0); hist_Q2QE = new TH1D("MCStudy_CCQE_Q2QE","MCStudy_CCQE_Q2QE",30,0.0,3.0); hist_EQE = new TH1D("MCStudy_CCQE_EQE","MCStudy_CCQE_EQE",30,0.0,5.0); hist_q0 = new TH1D("MCStudy_CCQE_q0","MCStudy_CCQE_q0",30,0.0,2.0); hist_q3 = new TH1D("MCStudy_CCQE_q3","MCStudy_CCQE_q3",30,0.0,2.0); hist_TLepCosLep = new TH2D("MCStudy_CCQE_TLepCosLep","MCStudy_CCQE_TLepCosLep",15,0.0,5.0,15,-1.0,1.0); hist_Total = new TH1D("MCStudy_CCQE_TotalXSec","MXStudy_CCQE_TotalXSec",1,0.0,1.0); hist_q0q3 = new TH2D("MCStudy_CCQE_q0q3","MCStudy_CCQE_q0q3;q_{3} (GeV); q_{0} (GeV); d#sigma/dq_{0}dq_{3} (cm^{2}/nucleon/GeV^{2})",40,0.0,2.0,40,0.0,2.0); return; } //******************************************************************** void MCStudy_CCQEHistograms::FillEventVariables(FitEvent *event) { //******************************************************************** // std::cout << "Event fBound = " << event->fBound << " " << event->Mode << std::endl; // if (event->fBound > 0) return; if (abs(event->Mode) != 1) return; // std::cout << "Event fBound = " << event->fBound << " " << event->Mode << "-> Signal " << std::endl; 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() )); 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 (abs(Mode) == 1 and Signal){ hist_Enu->Fill(Enu,event->Weight); hist_TLep->Fill(TLep,event->Weight); hist_CosLep->Fill(CosLep,event->Weight); hist_Q2->Fill(Q2,event->Weight); hist_Q2QE->Fill(Q2QE,event->Weight); hist_EQE->Fill(EQE,event->Weight); hist_q0->Fill(q0,event->Weight); hist_q3->Fill(q3,event->Weight); hist_TLepCosLep->Fill(TLep,CosLep,event->Weight); hist_q0q3->Fill(q3,q0,event->Weight); hist_Total->Fill(0.5,event->Weight); fXVar = Q2; } return; }; //******************************************************************** void MCStudy_CCQEHistograms::Write(std::string drawOpt) { //******************************************************************** // Measurement1D::Write(drawOpt); NUIS_LOG(FIT, "Writing MCStudy_CCQEHistograms "); // Config::Get().out->cd(); hist_Enu->Write(); hist_TLep->Write(); hist_CosLep->Write(); hist_Q2->Write(); hist_Q2QE->Write(); hist_EQE->Write(); hist_q0->Write(); hist_q3->Write(); hist_TLepCosLep->Write(); hist_q0q3->Write(); hist_Total->Write(); return; } //******************************************************************** void MCStudy_CCQEHistograms::ResetAll(){ //******************************************************************** hist_Enu->Reset(); hist_TLep->Reset(); hist_CosLep->Reset(); hist_Q2->Reset(); hist_Q2QE->Reset(); hist_EQE->Reset(); hist_q0->Reset(); hist_q3->Reset(); hist_q0q3->Reset(); hist_TLepCosLep->Reset(); hist_Total->Reset(); return; } //******************************************************************** void MCStudy_CCQEHistograms::ScaleEvents(){ //******************************************************************** hist_Enu->Scale(fScaleFactor,"width"); hist_TLep->Scale(fScaleFactor,"width"); hist_CosLep->Scale(fScaleFactor,"width"); hist_Q2->Scale(fScaleFactor,"width"); hist_Q2QE->Scale(fScaleFactor,"width"); hist_EQE->Scale(fScaleFactor,"width"); hist_q0->Scale(fScaleFactor,"width"); hist_q3->Scale(fScaleFactor,"width"); hist_q0q3->Scale(fScaleFactor,"width"); hist_TLepCosLep->Scale(fScaleFactor,"width"); hist_Total->Scale(fScaleFactor,"width"); return; } //******************************************************************** /// Select only events with final state Muons bool MCStudy_CCQEHistograms::isSignal(FitEvent *event) { //******************************************************************** if (abs(event->Mode) != 1) return false; //if (event->fBound > 0) return false; // if (!event->HasFSMuon()) return false; // Do we want any other signal? return true; }; diff --git a/src/MCStudies/MCStudy_CCQEHistograms.h b/src/MCStudies/MCStudy_CCQEHistograms.h index 4799ef3..4827837 100644 --- a/src/MCStudies/MCStudy_CCQEHistograms.h +++ b/src/MCStudies/MCStudy_CCQEHistograms.h @@ -1,76 +1,76 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MCStudy_CCQEHistograms_H_SEEN #define MCStudy_CCQEHistograms_H_SEEN #include "Measurement1D.h" //******************************************************************** class MCStudy_CCQEHistograms : public Measurement1D { //******************************************************************** public: MCStudy_CCQEHistograms(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~MCStudy_CCQEHistograms() {}; //! Grab info from event void FillEventVariables(FitEvent *event); void ScaleEvents(); void ResetAll(); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); private: double fEventScaleFactor; TTree* fEventTree; TH1D* hist_Enu; float Enu; TH1D* hist_TLep; float TLep ; TH1D* hist_CosLep; float CosLep; TH1D* hist_Q2; float Q2 ; TH1D* hist_Q2QE; float Q2QE ; TH1D* hist_EQE; float EQE ; TH1D* hist_q0; float q0 ; TH1D* hist_q3; float q3 ; TH2D* hist_q0q3; TH1D* hist_Total; TH2D* hist_TLepCosLep; double LocalRWWeight; double LocalInputWeight; }; #endif diff --git a/src/MCStudies/MCStudy_KaonPreSelection.cxx b/src/MCStudies/MCStudy_KaonPreSelection.cxx index 02640e4..a06a766 100644 --- a/src/MCStudies/MCStudy_KaonPreSelection.cxx +++ b/src/MCStudies/MCStudy_KaonPreSelection.cxx @@ -1,233 +1,233 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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 = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Create a new TTree and add Nuisance Events Branches Config::Get().out->cd(); fEventTree = new TTree("nuisance_events","nuisance_events"); GetInput()->GetNuisanceEvent(0)->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 fEventTree->Branch("EventScaleFactor", &fEventScaleFactor, "EventScaleFactor/D"); 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. // 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 // 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"); */ // Logging Flag fKaonLogging = FitPar::Config().GetParB("KaonLogging"); return; } //******************************************************************** void MCStudy_KaonPreSelection::FillEventVariables(FitEvent *event) { //******************************************************************** // Reset kplusmom = -999.9; // Save Some Extra Information nkplus = event->NumFSParticle(PhysConst::pdg_kplus); // Nmuons nlep = event->NumFSParticle(13) + event->NumFSParticle(-13); // Leading K+ Mom if (event->GetHMFSParticle(PhysConst::pdg_kplus)){ kplusmom = FitUtils::T(event->GetHMFSParticle(PhysConst::pdg_kplus)->fP)*1000.0; } // Fill XVar fXVar = kplusmom / 1.E3; // Fill If Signal if (isSignal(event)){ fEventTree->Fill(); if (fKaonLogging){ int nstrangemesons = event->NumParticle(321); int nstrangefsmesons = event->NumFSParticle(321); if (nstrangemesons > 0){ std::cout << "New Event ----------------------------" << std::endl; std::cout << "N S Mesons vs NFS S Mesons : " << nstrangemesons << " : " << nstrangefsmesons << std::endl; event->fNeutVect->Dump(); } } } return; }; //******************************************************************** void MCStudy_KaonPreSelection::Write(std::string 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) { //******************************************************************** // Update to include all events return true; // 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}; */ 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_KaonPreSelection.h b/src/MCStudies/MCStudy_KaonPreSelection.h index cae037b..32cd502 100644 --- a/src/MCStudies/MCStudy_KaonPreSelection.h +++ b/src/MCStudies/MCStudy_KaonPreSelection.h @@ -1,54 +1,54 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MCStudy_KaonPreSelection_H_SEEN #define MCStudy_KaonPreSelection_H_SEEN #include "Measurement1D.h" //******************************************************************** class MCStudy_KaonPreSelection : public Measurement1D { //******************************************************************** public: MCStudy_KaonPreSelection(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~MCStudy_KaonPreSelection() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); private: double fEventScaleFactor; TTree* fEventTree; int nlep; int nkplus; int nkaon; double kplusmom; double kaonmom; bool fKaonLogging; }; #endif diff --git a/src/MCStudies/MCStudy_MuonValidation.cxx b/src/MCStudies/MCStudy_MuonValidation.cxx index 6ad9a9b..486539a 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 +// Copyright 2016-2021 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 . *******************************************************************************/ #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 = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Create a new TTree and add Nuisance Events Branches Config::Get().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 fEventTree->Branch("EventScaleFactor", &fEventScaleFactor, "EventScaleFactor/D"); 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() )); 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/MCStudies/MCStudy_MuonValidation.h b/src/MCStudies/MCStudy_MuonValidation.h index 44a902c..fa22287 100644 --- a/src/MCStudies/MCStudy_MuonValidation.h +++ b/src/MCStudies/MCStudy_MuonValidation.h @@ -1,59 +1,59 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MCStudy_MuonValidation_H_SEEN #define MCStudy_MuonValidation_H_SEEN #include "Measurement1D.h" //******************************************************************** class MCStudy_MuonValidation : public Measurement1D { //******************************************************************** public: MCStudy_MuonValidation(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~MCStudy_MuonValidation() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); private: double fEventScaleFactor; TTree* fEventTree; float Enu; float TLep ; float CosLep; float Q2 ; float Q2QE ; float EQE ; float q0 ; float q3 ; double LocalRWWeight; double LocalInputWeight; }; #endif diff --git a/src/MCStudies/MCStudy_NCpi0PreSelection.cxx b/src/MCStudies/MCStudy_NCpi0PreSelection.cxx index 9873ce3..5522631 100644 --- a/src/MCStudies/MCStudy_NCpi0PreSelection.cxx +++ b/src/MCStudies/MCStudy_NCpi0PreSelection.cxx @@ -1,214 +1,214 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MCStudy_NCpi0PreSelection.h" #include "T2K_SignalDef.h" #include "MINERvA_SignalDef.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement MCStudy_NCpi0PreSelection::MCStudy_NCpi0PreSelection(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 = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Create a new TTree and add Nuisance Events Branches Config::Get().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 fEventTree->Branch("EventScaleFactor", &fEventScaleFactor, "EventScaleFactor/D"); 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. // 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 // 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"); */ // Logging Flag fNCpi0Logging = FitPar::Config().GetParB("NCpi0Logging"); return; } //******************************************************************** void MCStudy_NCpi0PreSelection::FillEventVariables(FitEvent *event) { //******************************************************************** // Reset kplusmom = -999.9; // Save Some Extra Information nkplus = event->NumFSParticle(PhysConst::pdg_kplus); // Nmuons nlep = event->NumFSParticle(13) + event->NumFSParticle(-13); // Leading K+ Mom if (event->GetHMFSParticle(PhysConst::pdg_kplus)){ kplusmom = FitUtils::T(event->GetHMFSParticle(PhysConst::pdg_kplus)->fP)*1000.0; } // Fill XVar fXVar = kplusmom / 1.E3; // Fill If Signal if (isSignal(event)){ fEventTree->Fill(); if (fNCpi0Logging){ int nstrangemesons = event->NumParticle(321); int nstrangefsmesons = event->NumFSParticle(321); if (nstrangemesons > 0){ std::cout << "New Event ----------------------------" << std::endl; std::cout << "N S Mesons vs NFS S Mesons : " << nstrangemesons << " : " << nstrangefsmesons << std::endl; event->fNeutVect->Dump(); } } } return; }; //******************************************************************** void MCStudy_NCpi0PreSelection::Write(std::string 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 NCpi0s bool MCStudy_NCpi0PreSelection::isSignal(FitEvent *event) { //******************************************************************** // Apply a NCpi0 Pre-selection // Search for Strange Mesons (included full list from MC PDG) int npi0 = event->NumParticle(111); if (npi0 <= 0) return false; int nlep = (event->NumFSParticle(11) + event->NumFSParticle(13) + event->NumFSParticle(15) + event->NumFSParticle(-11) + event->NumFSParticle(-13) + event->NumFSParticle(-15)); if (nlep > 0) return false; // Do we want any other signal? return true; }; diff --git a/src/MCStudies/MCStudy_NCpi0PreSelection.h b/src/MCStudies/MCStudy_NCpi0PreSelection.h index a05dd5b..74e073f 100644 --- a/src/MCStudies/MCStudy_NCpi0PreSelection.h +++ b/src/MCStudies/MCStudy_NCpi0PreSelection.h @@ -1,53 +1,53 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MCStudy_NCpi0PreSelection_H_SEEN #define MCStudy_NCpi0PreSelection_H_SEEN #include "Measurement1D.h" //******************************************************************** class MCStudy_NCpi0PreSelection : public Measurement1D { //******************************************************************** public: MCStudy_NCpi0PreSelection(std::string name, std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~MCStudy_NCpi0PreSelection() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); private: double fEventScaleFactor; TTree* fEventTree; int nlep; int nkplus; int nkaon; double kplusmom; double kaonmom; }; #endif diff --git a/src/MCStudies/OfficialNIWGPlots.cxx b/src/MCStudies/OfficialNIWGPlots.cxx index 1c05bfc..c2a7573 100644 --- a/src/MCStudies/OfficialNIWGPlots.cxx +++ b/src/MCStudies/OfficialNIWGPlots.cxx @@ -1,679 +1,679 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "OfficialNIWGPlots.h" #include "T2K_SignalDef.h" #include "MINERvA_SignalDef.h" //******************************************************************** OfficialNIWGPlots::OfficialNIWGPlots(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "NIWG Official plots sample. \n" \ "Target: Any \n" \ "Flux: T2K Flux \n" \ "Signal: CC Inclusive \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 30.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("NIWG Official Plots 2017"); fSettings.SetOnlyMC(1); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); fScaleFactorEnuXSec = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); fScaleFactorDifXSec = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- fHist_NuMu_Enu = new TH1D("NuMu_Enu_MC", "NuMu_Enu_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_NuMu_Enu_Modes = new MCStudies::OfficialNIWGStack("NuMu_Enu_MC_MODES", "NuMu_Enu_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMu_Enu); fHist_NuMu_Enu_Pions = new MCStudies::OfficialPionStack("NuMu_Enu_MC_PIONS", "NuMu_Enu_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMu_Enu); fHist_NuMu_EnuRates = new TH1D("NuMu_EnuRates_MC", "NuMu_EnuRates_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_NuMu_EnuRates_Modes = new MCStudies::OfficialNIWGStack("NuMu_EnuRates_MC_MODES", "NuMu_EnuRates_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMu_Enu); fHist_NuMu_EnuRates_Pions = new MCStudies::OfficialPionStack("NuMu_EnuRates_MC_PIONS", "NuMu_EnuRates_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMu_Enu); fHist_NuMu_Q2 = new TH1D("NuMu_Q2_MC", "NuMu_Q2_MC;Q^{2} (GeV);d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})", 45, 0.0, 3.0); fHist_NuMu_Q2_Modes = new MCStudies::OfficialNIWGStack("NuMu_Q2_MC_MODES", "NuMu_Q2_MC_MODES;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_NuMu_Q2); fHist_NuMu_Q2_Pions = new MCStudies::OfficialPionStack("NuMu_Q2_MC_PIONS", "NuMu_Q2_MC_PIONS;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_NuMu_Q2); fHist_NuMu_Pmu = new TH1D("NuMu_Pmu_MC", "NuMu_Pmu_MC;P_{#mu} (GeV);#sigma (cm^{2}/nucleon/GeV)", 45, 0.0, 3.0); fHist_NuMu_Pmu_Modes = new MCStudies::OfficialNIWGStack("NuMu_Pmu_MC_MODES", "NuMu_Pmu_MC_MODES;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_NuMu_Pmu); fHist_NuMu_Pmu_Pions = new MCStudies::OfficialPionStack("NuMu_Pmu_MC_PIONS", "NuMu_Pmu_MC_PIONS;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_NuMu_Pmu); fHist_NuMu_Cosmu = new TH1D("NuMu_Cosmu_MC", "NuMu_Cosmu_MC;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", 45, -1.0, 1.0); fHist_NuMu_Cosmu_Modes = new MCStudies::OfficialNIWGStack("NuMu_Cosmu_MC_MODES", "NuMu_Cosmu_MC_MODES;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_NuMu_Cosmu); fHist_NuMu_Cosmu_Pions = new MCStudies::OfficialPionStack("NuMu_Cosmu_MC_PIONS", "NuMu_Cosmu_MC_PIONS;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_NuMu_Cosmu); fHist_NuMuBar_Enu = new TH1D("NuMuBar_Enu_MC", "NuMuBar_Enu_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_NuMuBar_Enu_Modes = new MCStudies::OfficialNIWGStack("NuMuBar_Enu_MC_MODES", "NuMuBar_Enu_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMuBar_Enu); fHist_NuMuBar_Enu_Pions = new MCStudies::OfficialPionStack("NuMuBar_Enu_MC_PIONS", "NuMuBar_Enu_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMuBar_Enu); fHist_NuMuBar_EnuRates = new TH1D("NuMuBar_EnuRates_MC", "NuMuBar_EnuRates_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_NuMuBar_EnuRates_Modes = new MCStudies::OfficialNIWGStack("NuMuBar_EnuRates_MC_MODES", "NuMuBar_EnuRates_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMuBar_Enu); fHist_NuMuBar_EnuRates_Pions = new MCStudies::OfficialPionStack("NuMuBar_EnuRates_MC_PIONS", "NuMuBar_EnuRates_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NuMuBar_Enu); fHist_NuMuBar_Q2 = new TH1D("NuMuBar_Q2_MC", "NuMuBar_Q2_MC;Q^{2} (GeV);d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})", 45, 0.0, 3.0); fHist_NuMuBar_Q2_Modes = new MCStudies::OfficialNIWGStack("NuMuBar_Q2_MC_MODES", "NuMuBar_Q2_MC_MODES;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_NuMuBar_Q2); fHist_NuMuBar_Q2_Pions = new MCStudies::OfficialPionStack("NuMuBar_Q2_MC_PIONS", "NuMuBar_Q2_MC_PIONS;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_NuMuBar_Q2); fHist_NuMuBar_Pmu = new TH1D("NuMuBar_Pmu_MC", "NuMuBar_Pmu_MC;P_{#mu} (GeV);#sigma (cm^{2}/nucleon/GeV)", 45, 0.0, 3.0); fHist_NuMuBar_Pmu_Modes = new MCStudies::OfficialNIWGStack("NuMuBar_Pmu_MC_MODES", "NuMuBar_Pmu_MC_MODES;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_NuMuBar_Pmu); fHist_NuMuBar_Pmu_Pions = new MCStudies::OfficialPionStack("NuMuBar_Pmu_MC_PIONS", "NuMuBar_Pmu_MC_PIONS;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_NuMuBar_Pmu); fHist_NuMuBar_Cosmu = new TH1D("NuMuBar_Cosmu_MC", "NuMuBar_Cosmu_MC;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", 45, -1.0, 1.0); fHist_NuMuBar_Cosmu_Modes = new MCStudies::OfficialNIWGStack("NuMuBar_Cosmu_MC_MODES", "NuMuBar_Cosmu_MC_MODES;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_NuMuBar_Cosmu); fHist_NuMuBar_Cosmu_Pions = new MCStudies::OfficialPionStack("NuMuBar_Cosmu_MC_PIONS", "NuMuBar_Cosmu_MC_PIONS;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_NuMuBar_Cosmu); fHist_Nue_Enu = new TH1D("Nue_Enu_MC", "Nue_Enu_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_Nue_Enu_Modes = new MCStudies::OfficialNIWGStack("Nue_Enu_MC_MODES", "Nue_Enu_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_Nue_Enu); fHist_Nue_Enu_Pions = new MCStudies::OfficialPionStack("Nue_Enu_MC_PIONS", "Nue_Enu_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_Nue_Enu); fHist_Nue_EnuRates = new TH1D("Nue_EnuRates_MC", "Nue_EnuRates_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_Nue_EnuRates_Modes = new MCStudies::OfficialNIWGStack("Nue_EnuRates_MC_MODES", "Nue_EnuRates_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_Nue_Enu); fHist_Nue_EnuRates_Pions = new MCStudies::OfficialPionStack("Nue_EnuRates_MC_PIONS", "Nue_EnuRates_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_Nue_Enu); fHist_Nue_Q2 = new TH1D("Nue_Q2_MC", "Nue_Q2_MC;Q^{2} (GeV);d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})", 45, 0.0, 3.0); fHist_Nue_Q2_Modes = new MCStudies::OfficialNIWGStack("Nue_Q2_MC_MODES", "Nue_Q2_MC_MODES;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_Nue_Q2); fHist_Nue_Q2_Pions = new MCStudies::OfficialPionStack("Nue_Q2_MC_PIONS", "Nue_Q2_MC_PIONS;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_Nue_Q2); fHist_Nue_Pmu = new TH1D("Nue_Pmu_MC", "Nue_Pmu_MC;P_{#mu} (GeV);#sigma (cm^{2}/nucleon/GeV)", 45, 0.0, 3.0); fHist_Nue_Pmu_Modes = new MCStudies::OfficialNIWGStack("Nue_Pmu_MC_MODES", "Nue_Pmu_MC_MODES;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_Nue_Pmu); fHist_Nue_Pmu_Pions = new MCStudies::OfficialPionStack("Nue_Pmu_MC_PIONS", "Nue_Pmu_MC_PIONS;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_Nue_Pmu); fHist_Nue_Cosmu = new TH1D("Nue_Cosmu_MC", "Nue_Cosmu_MC;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", 45, -1.0, 1.0); fHist_Nue_Cosmu_Modes = new MCStudies::OfficialNIWGStack("Nue_Cosmu_MC_MODES", "Nue_Cosmu_MC_MODES;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_Nue_Cosmu); fHist_Nue_Cosmu_Pions = new MCStudies::OfficialPionStack("Nue_Cosmu_MC_PIONS", "Nue_Cosmu_MC_PIONS;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_Nue_Cosmu); fHist_NueBar_Enu = new TH1D("NueBar_Enu_MC", "NueBar_Enu_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_NueBar_Enu_Modes = new MCStudies::OfficialNIWGStack("NueBar_Enu_MC_MODES", "NueBar_Enu_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NueBar_Enu); fHist_NueBar_Enu_Pions = new MCStudies::OfficialPionStack("NueBar_Enu_MC_PIONS", "NueBar_Enu_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NueBar_Enu); fHist_NueBar_EnuRates = new TH1D("NueBar_EnuRates_MC", "NueBar_EnuRates_MC;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", 45, 0.0, 3.0); fHist_NueBar_EnuRates_Modes = new MCStudies::OfficialNIWGStack("NueBar_EnuRates_MC_MODES", "NueBar_EnuRates_MC_MODES;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NueBar_Enu); fHist_NueBar_EnuRates_Pions = new MCStudies::OfficialPionStack("NueBar_EnuRates_MC_PIONS", "NueBar_EnuRates_MC_PIONS;E_{#nu}^{True} (GeV);#sigma (cm^{2}/nucleon)", fHist_NueBar_Enu); fHist_NueBar_Q2 = new TH1D("NueBar_Q2_MC", "NueBar_Q2_MC;Q^{2} (GeV);d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})", 45, 0.0, 3.0); fHist_NueBar_Q2_Modes = new MCStudies::OfficialNIWGStack("NueBar_Q2_MC_MODES", "NueBar_Q2_MC_MODES;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_NueBar_Q2); fHist_NueBar_Q2_Pions = new MCStudies::OfficialPionStack("NueBar_Q2_MC_PIONS", "NueBar_Q2_MC_PIONS;Q^{2} (GeV);#sigma (cm^{2}/nucleon/GeV^{2})", fHist_NueBar_Q2); fHist_NueBar_Pmu = new TH1D("NueBar_Pmu_MC", "NueBar_Pmu_MC;P_{#mu} (GeV);#sigma (cm^{2}/nucleon/GeV)", 45, 0.0, 3.0); fHist_NueBar_Pmu_Modes = new MCStudies::OfficialNIWGStack("NueBar_Pmu_MC_MODES", "NueBar_Pmu_MC_MODES;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_NueBar_Pmu); fHist_NueBar_Pmu_Pions = new MCStudies::OfficialPionStack("NueBar_Pmu_MC_PIONS", "NueBar_Pmu_MC_PIONS;P_{#mu} (GeV);d#sigma/dP_{#mu} (cm^{2}/nucleon/GeV)", fHist_NueBar_Pmu); fHist_NueBar_Cosmu = new TH1D("NueBar_Cosmu_MC", "NueBar_Cosmu_MC;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", 45, -1.0, 1.0); fHist_NueBar_Cosmu_Modes = new MCStudies::OfficialNIWGStack("NueBar_Cosmu_MC_MODES", "NueBar_Cosmu_MC_MODES;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_NueBar_Cosmu); fHist_NueBar_Cosmu_Pions = new MCStudies::OfficialPionStack("NueBar_Cosmu_MC_PIONS", "NueBar_Cosmu_MC_PIONS;cos#theta_{#mu};d#sigma/dcos#theta_{#mu} (cm^{2}/nucleon)", fHist_NueBar_Cosmu); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void OfficialNIWGPlots::FillEventVariables(FitEvent *event) { //******************************************************************** if (!event->GetNeutrinoIn() or abs(event->Mode) > 30) return; TLorentzVector vectnu = event->GetNeutrinoIn()->fP; int leptons[] = {12,-12,14,-14}; if (!event->GetHMFSParticle(leptons))return; TLorentzVector vectlep = event->GetHMFSParticle(leptons)->fP; double Q2 = fabs((vectlep - vectnu).Mag2()) / 1.E6; double Enu = vectnu.E() / 1.E3; double Pmu = vectlep.Vect().Mag() / 1.E3; double Cosmu = cos(vectlep.Vect().Angle(vectnu.Vect())); bool nue = (abs(event->GetNeutrinoIn()->fPID) == 12); bool nubar = (event->GetNeutrinoIn()->fPID > 0); if (OfficialNIWGPlots::isSignal(event)) { if (!nue and !nubar) { fHist_NuMu_Enu->Fill(Enu, Weight); fHist_NuMu_Enu_Modes->Fill(event, Enu, Weight); fHist_NuMu_Enu_Pions->Fill(event, Enu, Weight); fHist_NuMu_EnuRates->Fill(Enu, Weight); fHist_NuMu_EnuRates_Modes->Fill(event, Enu, Weight); fHist_NuMu_EnuRates_Pions->Fill(event, Enu, Weight); fHist_NuMu_Q2->Fill(Q2, Weight); fHist_NuMu_Q2_Modes->Fill(event, Q2, Weight); fHist_NuMu_Q2_Pions->Fill(event, Q2, Weight); fHist_NuMu_Pmu->Fill(Pmu, Weight); fHist_NuMu_Pmu_Modes->Fill(event, Pmu, Weight); fHist_NuMu_Pmu_Pions->Fill(event, Pmu, Weight); fHist_NuMu_Cosmu->Fill(Cosmu, Weight); fHist_NuMu_Cosmu_Modes->Fill(event, Cosmu, Weight); fHist_NuMu_Cosmu_Pions->Fill(event, Cosmu, Weight); } else if (!nue and nubar){ fHist_NuMuBar_Enu->Fill(Enu, Weight); fHist_NuMuBar_Enu_Modes->Fill(event, Enu, Weight); fHist_NuMuBar_Enu_Pions->Fill(event, Enu, Weight); fHist_NuMuBar_EnuRates->Fill(Enu, Weight); fHist_NuMuBar_EnuRates_Modes->Fill(event, Enu, Weight); fHist_NuMuBar_EnuRates_Pions->Fill(event, Enu, Weight); fHist_NuMuBar_Q2->Fill(Q2, Weight); fHist_NuMuBar_Q2_Modes->Fill(event, Q2, Weight); fHist_NuMuBar_Q2_Pions->Fill(event, Q2, Weight); fHist_NuMuBar_Pmu->Fill(Pmu, Weight); fHist_NuMuBar_Pmu_Modes->Fill(event, Pmu, Weight); fHist_NuMuBar_Pmu_Pions->Fill(event, Pmu, Weight); fHist_NuMuBar_Cosmu->Fill(Cosmu, Weight); fHist_NuMuBar_Cosmu_Modes->Fill(event, Cosmu, Weight); fHist_NuMuBar_Cosmu_Pions->Fill(event, Cosmu, Weight); } else if (nue and !nubar){ fHist_Nue_Enu->Fill(Enu, Weight); fHist_Nue_Enu_Modes->Fill(event, Enu, Weight); fHist_Nue_Enu_Pions->Fill(event, Enu, Weight); fHist_Nue_EnuRates->Fill(Enu, Weight); fHist_Nue_EnuRates_Modes->Fill(event, Enu, Weight); fHist_Nue_EnuRates_Pions->Fill(event, Enu, Weight); fHist_Nue_Q2->Fill(Q2, Weight); fHist_Nue_Q2_Modes->Fill(event, Q2, Weight); fHist_Nue_Q2_Pions->Fill(event, Q2, Weight); fHist_Nue_Pmu->Fill(Pmu, Weight); fHist_Nue_Pmu_Modes->Fill(event, Pmu, Weight); fHist_Nue_Pmu_Pions->Fill(event, Pmu, Weight); fHist_Nue_Cosmu->Fill(Cosmu, Weight); fHist_Nue_Cosmu_Modes->Fill(event, Cosmu, Weight); fHist_Nue_Cosmu_Pions->Fill(event, Cosmu, Weight); } else if (nue and nubar){ fHist_NueBar_Enu->Fill(Enu, Weight); fHist_NueBar_Enu_Modes->Fill(event, Enu, Weight); fHist_NueBar_Enu_Pions->Fill(event, Enu, Weight); fHist_NueBar_EnuRates->Fill(Enu, Weight); fHist_NueBar_EnuRates_Modes->Fill(event, Enu, Weight); fHist_NueBar_EnuRates_Pions->Fill(event, Enu, Weight); fHist_NueBar_Q2->Fill(Q2, Weight); fHist_NueBar_Q2_Modes->Fill(event, Q2, Weight); fHist_NueBar_Q2_Pions->Fill(event, Q2, Weight); fHist_NueBar_Pmu->Fill(Pmu, Weight); fHist_NueBar_Pmu_Modes->Fill(event, Pmu, Weight); fHist_NueBar_Pmu_Pions->Fill(event, Pmu, Weight); fHist_NueBar_Cosmu->Fill(Cosmu, Weight); fHist_NueBar_Cosmu_Modes->Fill(event, Cosmu, Weight); fHist_NueBar_Cosmu_Pions->Fill(event, Cosmu, Weight); } } return; }; //******************************************************************** void OfficialNIWGPlots::Write(std::string drawOpt) { //******************************************************************** NUIS_LOG(FIT,"Writing OfficialNIWGPlots "); fHist_NuMu_Enu->Write(); fHist_NuMu_Enu_Modes->Write(); fHist_NuMu_Enu_Pions->Write(); fHist_NuMu_EnuRates->Write(); fHist_NuMu_EnuRates_Modes->Write(); fHist_NuMu_EnuRates_Pions->Write(); fHist_NuMu_Q2->Write(); fHist_NuMu_Q2_Modes->Write(); fHist_NuMu_Q2_Pions->Write(); fHist_NuMu_Pmu->Write(); fHist_NuMu_Pmu_Modes->Write(); fHist_NuMu_Pmu_Pions->Write(); fHist_NuMu_Cosmu->Write(); fHist_NuMu_Cosmu_Modes->Write(); fHist_NuMu_Cosmu_Pions->Write(); fHist_NuMuBar_Enu->Write(); fHist_NuMuBar_Enu_Modes->Write(); fHist_NuMuBar_Enu_Pions->Write(); fHist_NuMuBar_EnuRates->Write(); fHist_NuMuBar_EnuRates_Modes->Write(); fHist_NuMuBar_EnuRates_Pions->Write(); fHist_NuMuBar_Q2->Write(); fHist_NuMuBar_Q2_Modes->Write(); fHist_NuMuBar_Q2_Pions->Write(); fHist_NuMuBar_Pmu->Write(); fHist_NuMuBar_Pmu_Modes->Write(); fHist_NuMuBar_Pmu_Pions->Write(); fHist_NuMuBar_Cosmu->Write(); fHist_NuMuBar_Cosmu_Modes->Write(); fHist_NuMuBar_Cosmu_Pions->Write(); fHist_Nue_Enu->Write(); fHist_Nue_Enu_Modes->Write(); fHist_Nue_Enu_Pions->Write(); fHist_Nue_EnuRates->Write(); fHist_Nue_EnuRates_Modes->Write(); fHist_Nue_EnuRates_Pions->Write(); fHist_Nue_Q2->Write(); fHist_Nue_Q2_Modes->Write(); fHist_Nue_Q2_Pions->Write(); fHist_Nue_Pmu->Write(); fHist_Nue_Pmu_Modes->Write(); fHist_Nue_Pmu_Pions->Write(); fHist_Nue_Cosmu->Write(); fHist_Nue_Cosmu_Modes->Write(); fHist_Nue_Cosmu_Pions->Write(); fHist_NueBar_Enu->Write(); fHist_NueBar_Enu_Modes->Write(); fHist_NueBar_Enu_Pions->Write(); fHist_NueBar_EnuRates->Write(); fHist_NueBar_EnuRates_Modes->Write(); fHist_NueBar_EnuRates_Pions->Write(); fHist_NueBar_Q2->Write(); fHist_NueBar_Q2_Modes->Write(); fHist_NueBar_Q2_Pions->Write(); fHist_NueBar_Pmu->Write(); fHist_NueBar_Pmu_Modes->Write(); fHist_NueBar_Pmu_Pions->Write(); fHist_NueBar_Cosmu->Write(); fHist_NueBar_Cosmu_Modes->Write(); fHist_NueBar_Cosmu_Pions->Write(); return; } //******************************************************************** void OfficialNIWGPlots::ResetAll() { //******************************************************************** fHist_NuMu_Enu->Reset(); fHist_NuMu_Enu_Modes->Reset(); fHist_NuMu_Enu_Pions->Reset(); fHist_NuMu_EnuRates->Reset(); fHist_NuMu_EnuRates_Modes->Reset(); fHist_NuMu_EnuRates_Pions->Reset(); fHist_NuMu_Q2->Reset(); fHist_NuMu_Q2_Modes->Reset(); fHist_NuMu_Q2_Pions->Reset(); fHist_NuMu_Pmu->Reset(); fHist_NuMu_Pmu_Modes->Reset(); fHist_NuMu_Pmu_Pions->Reset(); fHist_NuMu_Cosmu->Reset(); fHist_NuMu_Cosmu_Modes->Reset(); fHist_NuMu_Cosmu_Pions->Reset(); fHist_NuMuBar_Enu->Reset(); fHist_NuMuBar_Enu_Modes->Reset(); fHist_NuMuBar_Enu_Pions->Reset(); fHist_NuMuBar_EnuRates->Reset(); fHist_NuMuBar_EnuRates_Modes->Reset(); fHist_NuMuBar_EnuRates_Pions->Reset(); fHist_NuMuBar_Q2->Reset(); fHist_NuMuBar_Q2_Modes->Reset(); fHist_NuMuBar_Q2_Pions->Reset(); fHist_NuMuBar_Pmu->Reset(); fHist_NuMuBar_Pmu_Modes->Reset(); fHist_NuMuBar_Pmu_Pions->Reset(); fHist_NuMuBar_Cosmu->Reset(); fHist_NuMuBar_Cosmu_Modes->Reset(); fHist_NuMuBar_Cosmu_Pions->Reset(); fHist_Nue_Enu->Reset(); fHist_Nue_Enu_Modes->Reset(); fHist_Nue_Enu_Pions->Reset(); fHist_Nue_EnuRates->Reset(); fHist_Nue_EnuRates_Modes->Reset(); fHist_Nue_EnuRates_Pions->Reset(); fHist_Nue_Q2->Reset(); fHist_Nue_Q2_Modes->Reset(); fHist_Nue_Q2_Pions->Reset(); fHist_Nue_Pmu->Reset(); fHist_Nue_Pmu_Modes->Reset(); fHist_Nue_Pmu_Pions->Reset(); fHist_Nue_Cosmu->Reset(); fHist_Nue_Cosmu_Modes->Reset(); fHist_Nue_Cosmu_Pions->Reset(); fHist_NueBar_Enu->Reset(); fHist_NueBar_Enu_Modes->Reset(); fHist_NueBar_Enu_Pions->Reset(); fHist_NueBar_EnuRates->Reset(); fHist_NueBar_EnuRates_Modes->Reset(); fHist_NueBar_EnuRates_Pions->Reset(); fHist_NueBar_Q2->Reset(); fHist_NueBar_Q2_Modes->Reset(); fHist_NueBar_Q2_Pions->Reset(); fHist_NueBar_Pmu->Reset(); fHist_NueBar_Pmu_Modes->Reset(); fHist_NueBar_Pmu_Pions->Reset(); fHist_NueBar_Cosmu->Reset(); fHist_NueBar_Cosmu_Modes->Reset(); fHist_NueBar_Cosmu_Pions->Reset(); return; } //******************************************************************** void OfficialNIWGPlots::ScaleEvents() { //******************************************************************** fHist_NuMu_EnuRates->Scale(fScaleFactorEnuXSec); fHist_NuMu_EnuRates_Modes->Scale(fScaleFactorEnuXSec); fHist_NuMu_EnuRates_Pions->Scale(fScaleFactorEnuXSec); PlotUtils::FluxUnfoldedScaling(fHist_NuMu_Enu, GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NuMu_Enu_Modes->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NuMu_Enu_Pions->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NuMu_Q2->Scale(fScaleFactor, "width"); fHist_NuMu_Q2_Modes->Scale(fScaleFactor, "width"); fHist_NuMu_Q2_Pions->Scale(fScaleFactor, "width"); fHist_NuMu_Pmu->Scale(fScaleFactor, "width"); fHist_NuMu_Pmu_Modes->Scale(fScaleFactor, "width"); fHist_NuMu_Pmu_Pions->Scale(fScaleFactor, "width"); fHist_NuMu_Cosmu->Scale(fScaleFactor, "width"); fHist_NuMu_Cosmu_Modes->Scale(fScaleFactor, "width"); fHist_NuMu_Cosmu_Pions->Scale(fScaleFactor, "width"); fHist_NuMu_EnuRates->Scale(fScaleFactorEnuXSec); fHist_NuMu_EnuRates_Modes->Scale(fScaleFactorEnuXSec); fHist_NuMu_EnuRates_Pions->Scale(fScaleFactorEnuXSec); PlotUtils::FluxUnfoldedScaling(fHist_NuMuBar_Enu, GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NuMuBar_Enu_Modes->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NuMuBar_Enu_Pions->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NuMuBar_Q2->Scale(fScaleFactor, "width"); fHist_NuMuBar_Q2_Modes->Scale(fScaleFactor, "width"); fHist_NuMuBar_Q2_Pions->Scale(fScaleFactor, "width"); fHist_NuMuBar_Pmu->Scale(fScaleFactor, "width"); fHist_NuMuBar_Pmu_Modes->Scale(fScaleFactor, "width"); fHist_NuMuBar_Pmu_Pions->Scale(fScaleFactor, "width"); fHist_NuMuBar_Cosmu->Scale(fScaleFactor, "width"); fHist_NuMuBar_Cosmu_Modes->Scale(fScaleFactor, "width"); fHist_NuMuBar_Cosmu_Pions->Scale(fScaleFactor, "width"); fHist_Nue_EnuRates->Scale(fScaleFactorEnuXSec); fHist_Nue_EnuRates_Modes->Scale(fScaleFactorEnuXSec); fHist_Nue_EnuRates_Pions->Scale(fScaleFactorEnuXSec); PlotUtils::FluxUnfoldedScaling(fHist_Nue_Enu, GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_Nue_Enu_Modes->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_Nue_Enu_Pions->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_Nue_Q2->Scale(fScaleFactor, "width"); fHist_Nue_Q2_Modes->Scale(fScaleFactor, "width"); fHist_Nue_Q2_Pions->Scale(fScaleFactor, "width"); fHist_Nue_Pmu->Scale(fScaleFactor, "width"); fHist_Nue_Pmu_Modes->Scale(fScaleFactor, "width"); fHist_Nue_Pmu_Pions->Scale(fScaleFactor, "width"); fHist_Nue_Cosmu->Scale(fScaleFactor, "width"); fHist_Nue_Cosmu_Modes->Scale(fScaleFactor, "width"); fHist_Nue_Cosmu_Pions->Scale(fScaleFactor, "width"); fHist_Nue_EnuRates->Scale(fScaleFactorEnuXSec); fHist_Nue_EnuRates_Modes->Scale(fScaleFactorEnuXSec); fHist_Nue_EnuRates_Pions->Scale(fScaleFactorEnuXSec); PlotUtils::FluxUnfoldedScaling(fHist_NueBar_Enu, GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NueBar_Enu_Modes->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NueBar_Enu_Pions->FluxUnfold(GetFluxHistogram(), GetEventHistogram(), fScaleFactorEnuXSec, fNEvents); fHist_NueBar_Q2->Scale(fScaleFactor, "width"); fHist_NueBar_Q2_Modes->Scale(fScaleFactor, "width"); fHist_NueBar_Q2_Pions->Scale(fScaleFactor, "width"); fHist_NueBar_Pmu->Scale(fScaleFactor, "width"); fHist_NueBar_Pmu_Modes->Scale(fScaleFactor, "width"); fHist_NueBar_Pmu_Pions->Scale(fScaleFactor, "width"); fHist_NueBar_Cosmu->Scale(fScaleFactor, "width"); fHist_NueBar_Cosmu_Modes->Scale(fScaleFactor, "width"); fHist_NueBar_Cosmu_Pions->Scale(fScaleFactor, "width"); return; } //******************************************************************** /// Select only events with final state Muons bool OfficialNIWGPlots::isSignal(FitEvent *event) { //******************************************************************** if (abs(event->Mode) > 30) return false; // Do we want any other signal? return true; }; /// Functions to deal with the SB mode stacks MCStudies::OfficialNIWGStack::OfficialNIWGStack(std::string name, std::string title, TH1* hist) { fName = name; fTitle = title; AddMode(0, "CC0PI", "CC-0#pi", kRed, 2, 1001); AddMode(1, "CC1PI", "CC-1#pi", kBlue, 2, 1001); AddMode(2, "CCOther", "CC-Other", kMagenta, 2, 1001); AddMode(3, "CCCOH", "CC-Coherent", kGreen, 2, 1001); AddMode(4, "OTHER", "Other", kYellow, 2, 1001); StackBase::SetupStack(hist); }; int MCStudies::OfficialNIWGStack::ConvertModeToIndex(FitEvent* event) { // Other if (((event->NumFSParticle(13) + event->NumFSParticle(-13)) != 1)) return 4; // CC 0 PI if ((event->NumFSMesons() == 0)) return 0; // CC Coherent if (abs(event->Mode) == 16) return 3; // CC 1 PI if ((event->NumFSParticle(PhysConst::pdg_charged_pions)) == 1) return 1; // CC Other return 2; }; void MCStudies::OfficialNIWGStack::Fill(FitEvent* evt, double x, double y, double z, double weight) { StackBase::FillStack(this->ConvertModeToIndex(evt), x, y, z, weight); }; /// Functions to deal with the SB mode stacks MCStudies::OfficialPionStack::OfficialPionStack(std::string name, std::string title, TH1* hist) { fName = name; fTitle = title; AddMode(0, "CC0PI", "CC-0#pi", kRed, 2, 1001); AddMode(1, "CC1PI", "CC-1#pi", kBlue, 2, 1001); AddMode(2, "CCNPI", "CC-N#pi", kGreen, 2, 1001); AddMode(3, "OTHER", "Other", kYellow, 2, 1001); StackBase::SetupStack(hist); }; int MCStudies::OfficialPionStack::ConvertModeToIndex(FitEvent* event) { // Other if (((event->NumFSParticle(13) + event->NumFSParticle(-13)) != 1)) return 3; // CC 0 PI int npi = (event->NumFSParticle(PhysConst::pdg_charged_pions)); if (npi == 0) return 0; if (npi == 1) return 1; if (npi > 1) return 2; return 3; }; void MCStudies::OfficialPionStack::Fill(FitEvent* evt, double x, double y, double z, double weight) { StackBase::FillStack(this->ConvertModeToIndex(evt), x, y, z, weight); }; diff --git a/src/MCStudies/OfficialNIWGPlots.h b/src/MCStudies/OfficialNIWGPlots.h index 72ce3bc..ad3f554 100644 --- a/src/MCStudies/OfficialNIWGPlots.h +++ b/src/MCStudies/OfficialNIWGPlots.h @@ -1,173 +1,173 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef OfficialNIWGPlots_H_SEEN #define OfficialNIWGPlots_H_SEEN #include "Measurement1D.h" namespace MCStudies { class OfficialNIWGStack : public StackBase { public: /// Main constructor listing true mode categories. OfficialNIWGStack(std::string name, std::string title, TH1* hist); /// List to convert Modes to Index. /// Should be kept in sync with constructor. int ConvertModeToIndex(FitEvent* evt); /// Extracts Mode from FitEvent and fills void Fill(FitEvent* evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; class OfficialPionStack : public StackBase { public: /// Main constructor listing true mode categories. OfficialPionStack(std::string name, std::string title, TH1* hist); /// List to convert Modes to Index. /// Should be kept in sync with constructor. int ConvertModeToIndex(FitEvent* evt); /// Extracts Mode from FitEvent and fills void Fill(FitEvent* evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; }; //******************************************************************** class OfficialNIWGPlots : public Measurement1D { //******************************************************************** public: OfficialNIWGPlots(nuiskey samplekey); virtual ~OfficialNIWGPlots() {}; //! Grab info from event void FillEventVariables(FitEvent *event); void ScaleEvents(); void ResetAll(); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); private: double fScaleFactorDifXSec; double fScaleFactorEnuXSec; TH1D* fHist_NuMu_Enu; MCStudies::OfficialNIWGStack* fHist_NuMu_Enu_Modes; MCStudies::OfficialPionStack* fHist_NuMu_Enu_Pions; TH1D* fHist_NuMu_EnuRates; MCStudies::OfficialNIWGStack* fHist_NuMu_EnuRates_Modes; MCStudies::OfficialPionStack* fHist_NuMu_EnuRates_Pions; TH1D* fHist_NuMu_Q2; MCStudies::OfficialNIWGStack* fHist_NuMu_Q2_Modes; MCStudies::OfficialPionStack* fHist_NuMu_Q2_Pions; TH1D* fHist_NuMu_Pmu; MCStudies::OfficialNIWGStack* fHist_NuMu_Pmu_Modes; MCStudies::OfficialPionStack* fHist_NuMu_Pmu_Pions; TH1D* fHist_NuMu_Cosmu; MCStudies::OfficialNIWGStack* fHist_NuMu_Cosmu_Modes; MCStudies::OfficialPionStack* fHist_NuMu_Cosmu_Pions; TH1D* fHist_NuMuBar_Enu; MCStudies::OfficialNIWGStack* fHist_NuMuBar_Enu_Modes; MCStudies::OfficialPionStack* fHist_NuMuBar_Enu_Pions; TH1D* fHist_NuMuBar_EnuRates; MCStudies::OfficialNIWGStack* fHist_NuMuBar_EnuRates_Modes; MCStudies::OfficialPionStack* fHist_NuMuBar_EnuRates_Pions; TH1D* fHist_NuMuBar_Q2; MCStudies::OfficialNIWGStack* fHist_NuMuBar_Q2_Modes; MCStudies::OfficialPionStack* fHist_NuMuBar_Q2_Pions; TH1D* fHist_NuMuBar_Pmu; MCStudies::OfficialNIWGStack* fHist_NuMuBar_Pmu_Modes; MCStudies::OfficialPionStack* fHist_NuMuBar_Pmu_Pions; TH1D* fHist_NuMuBar_Cosmu; MCStudies::OfficialNIWGStack* fHist_NuMuBar_Cosmu_Modes; MCStudies::OfficialPionStack* fHist_NuMuBar_Cosmu_Pions; TH1D* fHist_Nue_Enu; MCStudies::OfficialNIWGStack* fHist_Nue_Enu_Modes; MCStudies::OfficialPionStack* fHist_Nue_Enu_Pions; TH1D* fHist_Nue_EnuRates; MCStudies::OfficialNIWGStack* fHist_Nue_EnuRates_Modes; MCStudies::OfficialPionStack* fHist_Nue_EnuRates_Pions; TH1D* fHist_Nue_Q2; MCStudies::OfficialNIWGStack* fHist_Nue_Q2_Modes; MCStudies::OfficialPionStack* fHist_Nue_Q2_Pions; TH1D* fHist_Nue_Pmu; MCStudies::OfficialNIWGStack* fHist_Nue_Pmu_Modes; MCStudies::OfficialPionStack* fHist_Nue_Pmu_Pions; TH1D* fHist_Nue_Cosmu; MCStudies::OfficialNIWGStack* fHist_Nue_Cosmu_Modes; MCStudies::OfficialPionStack* fHist_Nue_Cosmu_Pions; TH1D* fHist_NueBar_Enu; MCStudies::OfficialNIWGStack* fHist_NueBar_Enu_Modes; MCStudies::OfficialPionStack* fHist_NueBar_Enu_Pions; TH1D* fHist_NueBar_EnuRates; MCStudies::OfficialNIWGStack* fHist_NueBar_EnuRates_Modes; MCStudies::OfficialPionStack* fHist_NueBar_EnuRates_Pions; TH1D* fHist_NueBar_Q2; MCStudies::OfficialNIWGStack* fHist_NueBar_Q2_Modes; MCStudies::OfficialPionStack* fHist_NueBar_Q2_Pions; TH1D* fHist_NueBar_Pmu; MCStudies::OfficialNIWGStack* fHist_NueBar_Pmu_Modes; MCStudies::OfficialPionStack* fHist_NueBar_Pmu_Pions; TH1D* fHist_NueBar_Cosmu; MCStudies::OfficialNIWGStack* fHist_NueBar_Cosmu_Modes; MCStudies::OfficialPionStack* fHist_NueBar_Cosmu_Pions; }; #endif diff --git a/src/MCStudies/SigmaEnuHists.cxx b/src/MCStudies/SigmaEnuHists.cxx index 72b29a4..6c5a709 100644 --- a/src/MCStudies/SigmaEnuHists.cxx +++ b/src/MCStudies/SigmaEnuHists.cxx @@ -1,257 +1,257 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "SigmaEnuHists.h" #include void PerEify(TH1 *h) { for (int i = 0; i < h->GetXaxis()->GetNbins(); ++i) { double cont = h->GetBinContent(i + 1); double err = h->GetBinError(i + 1); double e = h->GetXaxis()->GetBinCenter(i + 1); if (!e) { h->SetBinContent(i + 1, 0); h->SetBinError(i + 1, 0); } else { h->SetBinContent(i + 1, cont / e); h->SetBinError(i + 1, err / e); } } } SigmaEnuHists::SigmaEnuHists(nuiskey samplekey) { fSettings = LoadSampleSettings(samplekey); PerE = (fName.find("PerE") != std::string::npos); // Define our energy range for flux calcs EnuMin = 0.; EnuMax = 1E10; // Arbritrarily high energy limit // Setup fDataHist as a placeholder fDataHist = new TH1D(("empty_data"), ("empty-data"), 1, 0, 1); FinaliseSampleSettings(); // 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. // N.B. MeasurementBase::PredictedEventRate includes the 1E-38 factor that is // often included here in other classes that directly integrate the event // histogram. This method is used here as it now respects EnuMin and EnuMax // correctly. fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); NUIS_LOG(SAM, " Generic Flux Scaling Factor = " << fScaleFactor << " [= " << (GetEventHistogram()->Integral("width") * 1E-38) << "/(" << (fNEvents + 0.) << "*" << TotalIntegratedFlux("width") << ")]"); if (fScaleFactor <= 0.0) { NUIS_ABORT("SCALE FACTOR TOO LOW"); } // If we have binning if (samplekey.Has("NBins") && samplekey.Has("MinEnuGev") && samplekey.Has("MaxEnuGev")) { int nbins = samplekey.GetI("NBins"); double low_gev = samplekey.GetD("MinEnuGev"); double up_gev = samplekey.GetD("MaxEnuGev"); std::vector bins; bool LogE = samplekey.Has("UseLogE") && samplekey.GetB("UseLogE"); std::cout << "[INFO]: Setting up binning: N = " << nbins << " min = " << low_gev << " GeV, max = " << up_gev << " max, LogE = " << (LogE ? "true" : "false") << std::endl; double step = (LogE ? (std::log10(up_gev) - std::log10(low_gev)) : (up_gev - low_gev)) / double(nbins); bins.push_back(low_gev); std::cout << "bin: " << bins.back() << std::endl; for (int i = 0; i < nbins; ++i) { if (LogE) { bins.push_back(pow(10, std::log10(bins.back()) + step)); std::cout << "bin: " << bins.back() << std::endl; } else { bins.push_back(bins.back() + step); std::cout << "bin: " << bins.back() << std::endl; } } std::cout << "nbin: " << bins.size() << std::endl; BinningHist = new TH1D("BinningHist", "", bins.size() - 1, bins.data()); } else { // use the flux hist BinningHist = static_cast(fFluxHist->Clone("BinningHist")); } BinningHist->SetDirectory(NULL); TopologyNames[kCC] = "CCInc"; TopologyNames[kCC0Pi] = "CC0Pi"; TopologyNames[kCC1Pi] = "CC1Pi"; TopologyNames[kCC1Pip] = "CC1Pip"; TopologyNames[kCC1Pi0] = "CC1Pi0"; TopologyNames[kCC1Pim] = "CC1Pim"; TopologyNames[kCCNPi] = "CCNPi"; TopologyNames[kNC] = "NCInc"; TopologyNames[kNC0Pi] = "NC0Pi"; TopologyNames[kNC1Pi] = "NC1Pi"; TopologyNames[kNCNPi] = "NCNPi"; for (int t = kCC; t < kNTopologies; ++t) { TopologyHists[t] = static_cast(BinningHist->Clone(TopologyNames[t].c_str())); TopologyHists[t]->SetTitle( ";#it{E}_{#nu} (GeV); #sigma(#it{E_{#nu}}) 10^{-38} cm^{2} /nucleon"); TopologyHists[t]->Reset(); } NEUTModeHists[0] = static_cast(BinningHist->Clone("TotalXSec")); NEUTModeHists[0]->SetTitle( ";#it{E}_{#nu} (GeV); #sigma(#it{E_{#nu}}) 10^{-38} cm^{2} /nucleon"); NEUTModeHists[0]->Reset(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); } void SigmaEnuHists::FillEventVariables(FitEvent *event) { // Now fill the information if (!NEUTModeHists.count(event->Mode)) { std::stringstream ss; ss << "NeutMode_" << (event->Mode < 0 ? "m" : "") << abs(event->Mode); NEUTModeHists[event->Mode] = static_cast(BinningHist->Clone(ss.str().c_str())); NEUTModeHists[event->Mode]->SetTitle( ";#it{E}_{#nu} (GeV); #sigma(#it{E_{#nu}}) 10^{-38} cm^{2} /nucleon"); NEUTModeHists[event->Mode]->Reset(); } FitParticle *nu = event->GetBeamPart(); double enu_gev = nu->fP.E() * 1E-3; double w = event->Weight; NEUTModeHists[event->Mode]->Fill(enu_gev, w); NEUTModeHists[0]->Fill(enu_gev, w); #ifdef __GENIE_ENABLED__ if (event->fType == kGENIE) { EventRecord *gevent = static_cast(event->genie_event->event); const Interaction *interaction = gevent->Summary(); int gmode = interaction->ProcInfo().ScatteringTypeId(); int isNC = !interaction->ProcInfo().IsWeakCC(); int isnu = nu->fPID > 0; int nuis_gmode = (gmode + 30 * isNC) * (isnu ? 1 : -1); if (!GENIEModeHists.count(nuis_gmode)) { std::stringstream ss; ss << "GENIEMode_" << (isNC ? "NC_" : "CC_") << (isnu ? "nu_" : "nubar_") << interaction->ProcInfo().ScatteringTypeAsString(); GENIEModeHists[nuis_gmode] = static_cast(BinningHist->Clone(ss.str().c_str())); GENIEModeHists[nuis_gmode]->SetTitle( ";#it{E}_{#nu} (GeV); #sigma(#it{E_{#nu}}) 10^{-38} cm^{2} /nucleon"); GENIEModeHists[nuis_gmode]->Reset(); } GENIEModeHists[nuis_gmode]->Fill(enu_gev, w); } #endif int NPi = event->GetAllFSPionsIndices().size(); int NPip = event->GetAllFSPiPlusIndices().size(); int NPim = event->GetAllFSPiMinusIndices().size(); if (event->IsCC()) { TopologyHists[kCC]->Fill(enu_gev, w); if (NPi == 0) { TopologyHists[kCC0Pi]->Fill(enu_gev, w); } else if (NPi == 1) { TopologyHists[kCC1Pi]->Fill(enu_gev, w); if (NPip == 1) { TopologyHists[kCC1Pip]->Fill(enu_gev, w); } else if (NPim == 1) { TopologyHists[kCC1Pim]->Fill(enu_gev, w); } else { TopologyHists[kCC1Pi0]->Fill(enu_gev, w); } } else { TopologyHists[kCCNPi]->Fill(enu_gev, w); } } else { TopologyHists[kNC]->Fill(enu_gev, w); if (NPi == 0) { TopologyHists[kNC0Pi]->Fill(enu_gev, w); } else if (NPi == 1) { TopologyHists[kNC1Pi]->Fill(enu_gev, w); } else { TopologyHists[kNCNPi]->Fill(enu_gev, w); } } }; void SigmaEnuHists::Write(std::string drawOpt) { for (std::map::iterator h = NEUTModeHists.begin(); h != NEUTModeHists.end(); ++h) { PlotUtils::FluxUnfoldedScaling(h->second, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); if (PerE) { PerEify(h->second); } h->second->Write(); } for (std::map::iterator h = GENIEModeHists.begin(); h != GENIEModeHists.end(); ++h) { PlotUtils::FluxUnfoldedScaling(h->second, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); if (PerE) { PerEify(h->second); } h->second->Write(); } for (std::map::iterator h = TopologyHists.begin(); h != TopologyHists.end(); ++h) { PlotUtils::FluxUnfoldedScaling(h->second, GetFluxHistogram(), GetEventHistogram(), fScaleFactor, fNEvents); if (PerE) { PerEify(h->second); } h->second->Write(); } } // Override functions which aren't really necessary bool SigmaEnuHists::isSignal(FitEvent *event) { (void)event; return true; }; diff --git a/src/MCStudies/SigmaEnuHists.h b/src/MCStudies/SigmaEnuHists.h index fe72467..e844b0e 100644 --- a/src/MCStudies/SigmaEnuHists.h +++ b/src/MCStudies/SigmaEnuHists.h @@ -1,66 +1,66 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SigmaEnuHists_H_SEEN #define SigmaEnuHists_H_SEEN #include "FitEvent.h" #include "Measurement1D.h" class SigmaEnuHists : public Measurement1D { public: SigmaEnuHists(nuiskey samplekey); virtual ~SigmaEnuHists(){}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); double GetLikelihood() { return 0; } private: TH1D * BinningHist; std::map NEUTModeHists; std::map GENIEModeHists; enum Topologies { kCC = 0, kCC0Pi, kCC1Pi, kCC1Pip, kCC1Pi0, kCC1Pim, kCCNPi, kNC, kNC0Pi, kNC1Pi, kNCNPi, kNTopologies }; std::map TopologyNames; std::map TopologyHists; bool PerE; }; #endif diff --git a/src/MCStudies/Simple_Osc.cxx b/src/MCStudies/Simple_Osc.cxx index b45505b..762310c 100644 --- a/src/MCStudies/Simple_Osc.cxx +++ b/src/MCStudies/Simple_Osc.cxx @@ -1,77 +1,77 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "Simple_Osc.h" //******************************************************************** Simple_Osc::Simple_Osc(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "Simple measurement class for doing fake data oscillation studies.\n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("Osc Studies"); fSettings.SetDescription(descrip); fSettings.SetXTitle("XXX"); fSettings.SetYTitle("Number of events"); fSettings.SetEnuRange(0.0, 50); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("*"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.); // Plot Setup ------------------------------------------------------- if (samplekey.Has("Target_Simple_Osc_File")) { SetDataFromRootFile(samplekey.GetS("Target_Simple_Osc_File"), (fSettings.GetName() + "_MC").c_str()); } else { fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), fSettings.GetFullTitles().c_str(), 200, 0, 3); } SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void Simple_Osc::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) { // Final state particles return; } TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); fXVar = FitUtils::EnuQErec(Pmu, cos(ThetaMu), 34, true); return; }; bool Simple_Osc::isSignal(FitEvent *event) { return SignalDef::isCCINC(event, 14, EnuMin, EnuMax); } diff --git a/src/MCStudies/Simple_Osc.h b/src/MCStudies/Simple_Osc.h index 03bd18c..bc3b7b0 100644 --- a/src/MCStudies/Simple_Osc.h +++ b/src/MCStudies/Simple_Osc.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SIMPLE_OSC_H_SEEN #define SIMPLE_OSC_H_SEEN #include "Measurement1D.h" class Simple_Osc : public Measurement1D { public: Simple_Osc(nuiskey samplekey); virtual ~Simple_Osc() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.cxx b/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.cxx index 60590a7..100d82c 100644 --- a/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.cxx +++ b/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.cxx @@ -1,924 +1,924 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "Smear_SVDUnfold_Propagation_Osc.h" #include "SmearceptanceUtils.h" #include "OscWeightEngine.h" #include "HistogramInputHandler.h" void Smear_SVDUnfold_Propagation_Osc::AddNDInputs(nuiskey &samplekey) { NDSample nds; // Plot Setup ------------------------------------------------------- // Check that we have the relevant near detector histograms specified. if (!NDSamples.size()) { // If this is the first ND sample, take from the // sample input InputHandlerBase *InputBase = GetInput(); if (InputBase->GetType() != kHISTO) { NUIS_ABORT( "Smear_SVDUnfold_Propagation_Osc expects a Histogram input that " "contains the ND observed spectrum."); } HistoInputHandler *HInput = dynamic_cast(InputBase); if (!HInput) { NUIS_ABORT( "Smear_SVDUnfold_Propagation_Osc expects a Histogram input that " "contains the ND observed spectrum."); } if (HInput->NHistograms() != 2) { NUIS_ABORT( "Input expected to contain 2 histograms. " "HISTO:input.root[NDObs_TH1D,NDSmear_TH2D]"); } nds.NDDataHist = dynamic_cast(HInput->GetHistogram(0)); nds.NDToSpectrumSmearingMatrix = dynamic_cast(HInput->GetHistogram(1)); if (!nds.NDDataHist) { NUIS_ABORT("Expected a valid TH1D input for the ND observed spectrum."); } if (!nds.NDToSpectrumSmearingMatrix) { NUIS_ABORT("Expected a valid TH2D input for the ND observed smearing."); } } else { std::vector NDObsInputs = PlotUtils::GetTH1sFromRootFile(samplekey.GetS("ObsInput")); if (NDObsInputs.size() < 2) { NUIS_ABORT( "Near detector sample must contain the observed ERec spectrum and " "the " "ND ETrue/ERec smearing matrix. e.g. " "ObsInput=\"input.root[NDObs_species,NDSmearing_species]\""); } nds.NDDataHist = dynamic_cast(NDObsInputs[0]); if (!nds.NDDataHist) { NUIS_ERR(FTL, "First histogram from ObsInput attribute was not a TH1D containing " "the near detector observed ERec spectrum (" << samplekey.GetS("ObsInput") << ")."); NUIS_ABORT( "Near detector sample must contain the observed ERec spectrum and " "the " "ND ETrue/ERec smearing matrix. e.g. " "ObsInput=\"input.root[FDObs_species,FDSmearing_species]\""); } nds.NDToSpectrumSmearingMatrix = dynamic_cast(NDObsInputs[1]); if (!nds.NDToSpectrumSmearingMatrix) { NUIS_ERR( FTL, "Second histogram from ObsInput attribute was not a TH2D containing " "the near detector ETrue/ERec smearing matrix (" << samplekey.GetS("ObsInput") << ")."); NUIS_ABORT( "Near detector sample must contain the observed ERec spectrum and " "the " "ND ETrue/ERec smearing matrix. e.g. " "ObsInput=\"input.root[FDObs_species,FDSmearing_species]\""); } } nds.NDDataHist->Scale(ScalePOT); if (UseRateErrors) { for (Int_t bi_it = 1; bi_it < nds.NDDataHist->GetXaxis()->GetNbins() + 1; ++bi_it) { nds.NDDataHist->SetBinError(bi_it, sqrt(nds.NDDataHist->GetBinContent(bi_it))); } } nds.TruncateStart = 0; if (samplekey.Has("TruncateStart")) { nds.TruncateStart = samplekey.GetI("TruncateStart"); } nds.TruncateUpTo = 0; if (samplekey.Has("TruncateUpTo")) { nds.TruncateUpTo = samplekey.GetI("TruncateUpTo"); NUIS_LOG(SAM, "\tAllowed to truncate unfolding matrix by up to " << nds.TruncateUpTo << " singular values to limit negative ENu spectra."); } nds.NuPDG = 14; if (samplekey.Has("NuPDG")) { nds.NuPDG = samplekey.GetI("NuPDG"); } NDSamples.push_back(nds); } void Smear_SVDUnfold_Propagation_Osc::SetupNDInputs() { for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { NDSample &nds = NDSamples[nd_it]; TMatrixD NDToSpectrumResponseMatrix_l = SmearceptanceUtils::GetMatrix( SmearceptanceUtils::SVDGetInverse(nds.NDToSpectrumSmearingMatrix)); nds.NDToSpectrumResponseMatrix.ResizeTo(NDToSpectrumResponseMatrix_l); nds.NDToSpectrumResponseMatrix = NDToSpectrumResponseMatrix_l; if (nds.TruncateStart != 0) { TMatrixD NDToSpectrumResponseMatrix_l = SmearceptanceUtils::GetMatrix(SmearceptanceUtils::SVDGetInverse( nds.NDToSpectrumSmearingMatrix, nds.TruncateStart)); nds.NDToSpectrumResponseMatrix.ResizeTo(NDToSpectrumResponseMatrix_l); nds.NDToSpectrumResponseMatrix = NDToSpectrumResponseMatrix_l; } if (nds.TruncateStart >= nds.TruncateUpTo) { nds.TruncateUpTo = nds.TruncateStart + 1; } UnfoldToNDETrueSpectrum(nd_it); } } void Smear_SVDUnfold_Propagation_Osc::ReadExtraConfig(nuiskey &samplekey) { UseRateErrors = false; if (samplekey.Has("SetErrorsFromRate")) { UseRateErrors = samplekey.GetI("SetErrorsFromRate"); } NDetectorInfo.first = 0xdeadbeef; if (samplekey.Has("DetectorVolume") && samplekey.Has("DetectorDensity")) { NDetectorInfo.first = samplekey.GetD("DetectorVolume"); NDetectorInfo.second = samplekey.GetD("DetectorDensity"); double TargetMass_kg = NDetectorInfo.first * NDetectorInfo.second; NUIS_LOG(SAM, "\tND sample detector mass : "); NUIS_LOG(SAM, "\t\tTarget volume : " << NDetectorInfo.first); NUIS_LOG(SAM, "\t\tTarget density : " << NDetectorInfo.second); NUIS_LOG(SAM, "\t\tTarget mass : " << TargetMass_kg << " kg"); } ScalePOT = 1; if (samplekey.Has("ScalePOT")) { ScalePOT = samplekey.GetD("ScalePOT"); } } void Smear_SVDUnfold_Propagation_Osc::AddFDTarget(nuiskey &nk) { FDSample fds; fds.FitRegion_Min = 0xdeadbeef; if (nk.Has("FitRegion_Min")) { fds.FitRegion_Min = nk.GetD("FitRegion_Min"); NUIS_LOG(SAM, "FD Sample [" << FDSamples.size() << "] imposes FitRegion E_nu > " << fds.FitRegion_Min); } if ((FitRegion_Min == 0xdeadbeef) || FitRegion_Min > fds.FitRegion_Min) { FitRegion_Min = fds.FitRegion_Min; } nk.Print(); fds.FitRegion_Max = 0xdeadbeef; if (nk.Has("FitRegion_Max")) { fds.FitRegion_Max = nk.GetD("FitRegion_Max"); NUIS_LOG(SAM, "FD Sample [" << FDSamples.size() << "] imposes FitRegion E_nu < " << fds.FitRegion_Max); } if ((FitRegion_Max == 0xdeadbeef) || FitRegion_Max < fds.FitRegion_Max) { FitRegion_Max = fds.FitRegion_Max; } fds.OscillateToPDG = 0; if (nk.Has("OscillateToPDG")) { fds.OscillateToPDG = nk.GetD("OscillateToPDG"); } std::vector FDNDRatioElements = nk.GetListOfChildNodes("FDNDRatio"); for (size_t fdnd_it = 0; fdnd_it < FDNDRatioElements.size(); ++fdnd_it) { nuiskey &fnr = FDNDRatioElements[fdnd_it]; if (fnr.Has("FromPDG") && fnr.Has("DivergenceFactor")) { fds.FDNDRatios[fnr.GetI("FromPDG")] = fnr.GetD("DivergenceFactor"); NUIS_LOG(SAM, "FDND DivergenceFactor for far detector sample index: " << FDSamples.size() << " for PDG: " << fnr.GetI("FromPDG") << " -> " << fds.OscillateToPDG << " = " << fnr.GetD("DivergenceFactor")); } else { NUIS_ABORT( "Far detector sample contained FDNDRatio element, but couldn't find " "both FromPDG and Factor attributes."); } } fds.FDNDMassRatio = 1; if (NDetectorInfo.first != 0xdeadbeef) { if ((!nk.Has("DetectorVolume")) || (!nk.Has("DetectorDensity"))) { NUIS_ABORT( "Near detector sample has specified volume but FD doesn't. This is " "needed to scale the predicted event rate by the mass ratio."); } fds.DetectorInfo.first = nk.GetD("DetectorVolume"); fds.DetectorInfo.second = nk.GetD("DetectorDensity"); double TargetMass_kg = fds.DetectorInfo.first * fds.DetectorInfo.second; fds.FDNDMassRatio = TargetMass_kg / (NDetectorInfo.first * NDetectorInfo.second); NUIS_LOG(SAM, "\tFD[" << FDSamples.size() << "] Event rate prediction : "); NUIS_LOG(SAM, "\t\tTarget volume : " << fds.DetectorInfo.first); NUIS_LOG(SAM, "\t\tTarget density : " << fds.DetectorInfo.second); NUIS_LOG(SAM, "\t\tFD/ND mass : " << fds.FDNDMassRatio); } if (!nk.Has("ObsInput")) { NUIS_ABORT("Far detector sample must specify at least ObsInput."); } std::vector FDObsInputs = PlotUtils::GetTH1sFromRootFile(nk.GetS("ObsInput")); if (FDObsInputs.size() < 2) { NUIS_ABORT( "Far detector sample must contain the observed ERec spectrum and the " "FD ETrue/ERec smearing matrix. " "ObsInput=\"input.root[FDObs_species,FDSmearing_species]\""); } fds.FDDataHist = NULL; for (size_t hist_it = 0; hist_it < FDObsInputs.size() - 1; ++hist_it) { if (!dynamic_cast(FDObsInputs[hist_it])) { NUIS_ERR(FTL, "Input spectrum index " << hist_it << " from ObsInput attribute was not a TH1D containing " "a far detector observed ERec spectrum (" << nk.GetS("ObsInput") << ")."); NUIS_ABORT( "Far detector sample must contain the observed ERec spectrum and the " "FD ETrue/ERec smearing matrix. " "ObsInput=\"input.root[FDObs_species,(FDObs_species2),FDSmearing_" "species]\""); } FDObsInputs[hist_it]->Scale(ScalePOT); if (!fds.FDDataHist) { fds.FDDataHist = dynamic_cast(FDObsInputs[hist_it]); } else { fds.FDDataHist->Add(dynamic_cast(FDObsInputs[hist_it])); } NUIS_LOG(SAM, "Added " << (FDObsInputs.size() - 1) << " far detector component spectra to form Observed " "spectra for sample index " << FDSamples.size() << "."); } fds.SpectrumToFDSmearingMatrix_TH2 = dynamic_cast(FDObsInputs.back()); if (!fds.SpectrumToFDSmearingMatrix_TH2) { NUIS_ERR(FTL, "last histogram from ObsInput attribute was not a TH2D containing " "the far detector ETrue/ERec smearing matrix (" << nk.GetS("ObsInput") << ")."); NUIS_ABORT( "Far detector sample must contain the observed ERec spectrum and the " "FD ETrue/ERec smearing matrix. " "ObsInput=\"input.root[FDObs_species,FDSmearing_species]\""); } TMatrixD SpectrumToFDSmearingMatrix_l = SmearceptanceUtils::GetMatrix(fds.SpectrumToFDSmearingMatrix_TH2); fds.SpectrumToFDSmearingMatrix.ResizeTo(SpectrumToFDSmearingMatrix_l); fds.SpectrumToFDSmearingMatrix = SpectrumToFDSmearingMatrix_l; FDSamples.push_back(fds); } void Smear_SVDUnfold_Propagation_Osc::FinaliseFDSamples() { std::stringstream ss(""); for (size_t fds_it = 0; fds_it < FDSamples.size(); ++fds_it) { FDSample &fds = FDSamples[fds_it]; // Set up FD histograms. // ============================== for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { NDSample &nds = NDSamples[nd_it]; TH1D *sampleHist = static_cast(nds.ND_Unfolded_Spectrum_Hist->Clone()); sampleHist->Reset(); ss.str(""); ss << "FD_Propagated_Spectrum_Hist_" << fds_it << "_NDSample_" << nd_it; sampleHist->SetName(ss.str().c_str()); fds.FD_Propagated_Spectrum_Hist_NDSamples.push_back(sampleHist); } fds.FD_Propagated_Spectrum_Hist = static_cast( fds.FD_Propagated_Spectrum_Hist_NDSamples[0]->Clone()); fds.FD_Propagated_Spectrum_Hist->Reset(); ss.str(""); ss << "FD_Propagated_Spectrum_Hist_" << fds_it; fds.FD_Propagated_Spectrum_Hist->SetName(ss.str().c_str()); for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { //NDSample &nds = NDSamples[nd_it]; TH1D *sampleHist = static_cast(fds.FD_Propagated_Spectrum_Hist->Clone()); sampleHist->Reset(); ss.str(""); ss << "NDFD_Corrected_Spectrum_Hist_" << fds_it << "_NDSample_" << nd_it; sampleHist->SetName(ss.str().c_str()); fds.NDFD_Corrected_Spectrum_Hist_NDSamples.push_back(sampleHist); } fds.NDFD_Corrected_Spectrum_Hist = static_cast(fds.FD_Propagated_Spectrum_Hist->Clone()); fds.NDFD_Corrected_Spectrum_Hist->Reset(); ss.str(""); ss << "NDFD_Corrected_Spectrum_Hist_" << fds_it; fds.NDFD_Corrected_Spectrum_Hist->SetName(ss.str().c_str()); fds.FD_Smeared_Spectrum_Hist = new TH1D(*fds.SpectrumToFDSmearingMatrix_TH2->ProjectionX()); fds.FD_Smeared_Spectrum_Hist->SetDirectory(NULL); fds.FD_Smeared_Spectrum_Hist->Reset(); ss.str(""); ss << "FD_Smeared_Spectrum_Hist_" << fds_it; fds.FD_Smeared_Spectrum_Hist->SetName(ss.str().c_str()); for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { NDSample &nds = NDSamples[nd_it]; if (!fds.FDNDRatios.count(nds.NuPDG)) { NUIS_ERR(WRN, "Have an ND sample that provides PDG:" << nds.NuPDG << " neutrinos but far detector sample index " << fds_it << " doesn't have an NDFD ratio for this sample. " "Setting to 0 (contribution from sample ignored.)"); fds.FDNDRatios[nds.NuPDG] = 0; } } } } Int_t Smear_SVDUnfold_Propagation_Osc::GetFDSampleNAnalysisBins(size_t fds_it) { if (fds_it >= FDSamples.size()) { NUIS_ABORT("Requested FD sample index " << fds_it << " but only initialised " << FDSamples.size()); } FDSample &fds = FDSamples[fds_it]; Int_t NAnalysisBins = 0; for (Int_t bi_it = 1; bi_it < fds.FDDataHist->GetXaxis()->GetNbins() + 1; ++bi_it) { if ((fds.FitRegion_Min != 0xdeadbeef) && (fds.FDDataHist->GetXaxis()->GetBinUpEdge(bi_it) <= fds.FitRegion_Min)) { continue; } if ((fds.FitRegion_Max != 0xdeadbeef) && (fds.FDDataHist->GetXaxis()->GetBinLowEdge(bi_it) > fds.FitRegion_Max)) { continue; } NAnalysisBins++; } return NAnalysisBins; } void Smear_SVDUnfold_Propagation_Osc::SetupChi2Hists() { fDataHist = new TH1D("SmearSVDUnfold", "", NFDAnalysisBins, 0, NFDAnalysisBins); fDataHist->SetNameTitle((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str()); Int_t CurrAnalysisBin = 1; for (size_t fds_it = 0; fds_it < FDSamples.size(); ++fds_it) { FDSample &fds = FDSamples[fds_it]; for (Int_t bi_it = 1; bi_it < fds.FDDataHist->GetXaxis()->GetNbins() + 1; ++bi_it) { if ((fds.FitRegion_Min != 0xdeadbeef) && (fds.FDDataHist->GetXaxis()->GetBinUpEdge(bi_it) <= fds.FitRegion_Min)) { continue; } if ((fds.FitRegion_Max != 0xdeadbeef) && (fds.FDDataHist->GetXaxis()->GetBinLowEdge(bi_it) > fds.FitRegion_Max)) { continue; } fDataHist->SetBinContent(CurrAnalysisBin, fds.FDDataHist->GetBinContent(bi_it)); if (UseRateErrors) { fDataHist->SetBinError(CurrAnalysisBin, sqrt(fds.FDDataHist->GetBinContent(bi_it))); } else { fDataHist->SetBinError(CurrAnalysisBin, fds.FDDataHist->GetBinError(bi_it)); } CurrAnalysisBin++; } } fMCHist = static_cast(fDataHist->Clone()); fMCHist->SetNameTitle((fSettings.GetName() + "_MC").c_str(), (fSettings.GetFullTitles()).c_str()); fMCHist->Reset(); } void Smear_SVDUnfold_Propagation_Osc::UpdateChi2Hists() { Int_t CurrAnalysisBin = 1; for (size_t fds_it = 0; fds_it < FDSamples.size(); ++fds_it) { FDSample &fds = FDSamples[fds_it]; for (Int_t bi_it = 1; bi_it < fds.FD_Smeared_Spectrum_Hist->GetXaxis()->GetNbins() + 1; ++bi_it) { if ((fds.FitRegion_Min != 0xdeadbeef) && (fds.FD_Smeared_Spectrum_Hist->GetXaxis()->GetBinUpEdge(bi_it) <= fds.FitRegion_Min)) { continue; } if ((fds.FitRegion_Max != 0xdeadbeef) && (fds.FD_Smeared_Spectrum_Hist->GetXaxis()->GetBinLowEdge(bi_it) > fds.FitRegion_Max)) { continue; } fMCHist->SetBinContent( CurrAnalysisBin, fds.FD_Smeared_Spectrum_Hist->GetBinContent(bi_it)); fMCHist->SetBinError(CurrAnalysisBin, fds.FD_Smeared_Spectrum_Hist->GetBinError(bi_it)); CurrAnalysisBin++; } } } //******************************************************************** Smear_SVDUnfold_Propagation_Osc::Smear_SVDUnfold_Propagation_Osc( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "Simple measurement class for doing fake data oscillation studies.\n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("Osc Studies"); fSettings.SetDescription(descrip); fSettings.SetXTitle("XXX"); fSettings.SetYTitle("Number of events"); fSettings.SetEnuRange(0.0, 50); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("*"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") / (fNEvents + 0.); fMCHist = NULL; fDataHist = NULL; ReadExtraConfig(samplekey); AddNDInputs(samplekey); std::vector NDTargets = samplekey.GetListOfChildNodes("NDObs"); for (size_t nd_it = 0; nd_it < NDTargets.size(); ++nd_it) { AddNDInputs(NDTargets[nd_it]); } std::vector FDTargets = samplekey.GetListOfChildNodes("FDObs"); NFDAnalysisBins = 0; if (!FDTargets.size()) { // If no child elements, assume that everything is // contained on the sample element AddFDTarget(samplekey); } else { for (size_t fd_it = 0; fd_it < FDTargets.size(); ++fd_it) { AddFDTarget(FDTargets[fd_it]); NFDAnalysisBins += GetFDSampleNAnalysisBins(fd_it); } } if ((FitRegion_Min != 0xdeadbeef) || (FitRegion_Max != 0xdeadbeef)) { NUIS_LOG(SAM, "When unfolding, interested region limited to:"); if (FitRegion_Min != 0xdeadbeef) { NUIS_LOG(SAM, "\tE_nu > " << FitRegion_Min); } if (FitRegion_Max != 0xdeadbeef) { NUIS_LOG(SAM, "\tE_nu < " << FitRegion_Max); } } SetupNDInputs(); FinaliseFDSamples(); NUIS_LOG(SAM, "Set up " << FDSamples.size() << " samples for oscillation analysis with " << NFDAnalysisBins << " analysis bins."); SetupChi2Hists(); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void Smear_SVDUnfold_Propagation_Osc::FillEventVariables(FitEvent *event){}; bool Smear_SVDUnfold_Propagation_Osc::isSignal(FitEvent *event) { return false; } void DumpUnfoldDebugInfo(Smear_SVDUnfold_Propagation_Osc::NDSample &nds, size_t nd_it, size_t truncations) { TDirectory *ogDir = gDirectory; std::stringstream ss; ss.str(""); ss << "DEBUG_FailedInvert_NDSample_" << nd_it; Config::Get().out->mkdir(ss.str().c_str()); Config::Get().out->cd(ss.str().c_str()); ss.str(""); ss << "ND_Smearing_Matrix_" << nd_it; nds.NDToSpectrumSmearingMatrix->Write(ss.str().c_str(), TObject::kOverwrite); ss.str(""); ss << "ND_Inverse_Smearing_Matrix_" << nd_it; SmearceptanceUtils::SVDGetInverse(nds.NDToSpectrumSmearingMatrix, 0) ->Write(ss.str().c_str(), TObject::kOverwrite); ss.str(""); ss << "ND_Inverse_Smearing_Matrix_" << nd_it << "_Trunc_" << truncations; SmearceptanceUtils::SVDGetInverse(nds.NDToSpectrumSmearingMatrix, truncations) ->Write(ss.str().c_str(), TObject::kOverwrite); ss.str(""); ss << "ND_Obs_" << nd_it; nds.NDDataHist->Write(ss.str().c_str(), TObject::kOverwrite); TMatrixD NDToSpectrumResponseMatrix_notrunc = SmearceptanceUtils::GetMatrix( SmearceptanceUtils::SVDGetInverse(nds.NDToSpectrumSmearingMatrix, 0)); nds.NDToSpectrumResponseMatrix.ResizeTo(NDToSpectrumResponseMatrix_notrunc); nds.NDToSpectrumResponseMatrix = NDToSpectrumResponseMatrix_notrunc; SmearceptanceUtils::PushTH1ThroughMatrixWithErrors( nds.NDDataHist, nds.ND_Unfolded_Spectrum_Hist, nds.NDToSpectrumResponseMatrix, 1000, false); ss.str(""); ss << "ND_Unfolded_" << nd_it; nds.ND_Unfolded_Spectrum_Hist->Write(ss.str().c_str(), TObject::kOverwrite); TMatrixD NDToSpectrumResponseMatrix_trunc = SmearceptanceUtils::GetMatrix(SmearceptanceUtils::SVDGetInverse( nds.NDToSpectrumSmearingMatrix, truncations)); nds.NDToSpectrumResponseMatrix.ResizeTo(NDToSpectrumResponseMatrix_trunc); nds.NDToSpectrumResponseMatrix = NDToSpectrumResponseMatrix_trunc; SmearceptanceUtils::PushTH1ThroughMatrixWithErrors( nds.NDDataHist, nds.ND_Unfolded_Spectrum_Hist, nds.NDToSpectrumResponseMatrix, 1000, false); ss.str(""); ss << "ND_Unfolded_" << nd_it << "_Trunc_" << truncations; nds.ND_Unfolded_Spectrum_Hist->Write(ss.str().c_str(), TObject::kOverwrite); if (ogDir) { ogDir->cd(); } else { Config::Get().out->cd(); } } void Smear_SVDUnfold_Propagation_Osc::UnfoldToNDETrueSpectrum(size_t nd_it) { if (nd_it >= NDSamples.size()) { NUIS_ABORT("Attempting to unfold ND sample index " << nd_it << " but only have " << NDSamples.size() << " ND samples."); } NDSample &nds = NDSamples[nd_it]; nds.ND_Unfolded_Spectrum_Hist = new TH1D(*nds.NDToSpectrumSmearingMatrix->ProjectionY()); nds.ND_Unfolded_Spectrum_Hist->SetDirectory(NULL); nds.ND_Unfolded_Spectrum_Hist->Clear(); std::stringstream ss(""); ss << "ND_Unfolded_Spectrum_Hist_" << nd_it; nds.ND_Unfolded_Spectrum_Hist->SetName(ss.str().c_str()); bool HasNegValue = false; int truncations = nds.TruncateStart; do { if (truncations >= nds.TruncateUpTo) { DumpUnfoldDebugInfo(nds, nd_it, truncations); NUIS_ABORT("Unfolded enu spectrum had negative values even after " << truncations << " SVD singular value truncations."); } // Unfold ND ERec -> Enu spectrum // ------------------------------ SmearceptanceUtils::PushTH1ThroughMatrixWithErrors( nds.NDDataHist, nds.ND_Unfolded_Spectrum_Hist, nds.NDToSpectrumResponseMatrix, 1000, false); HasNegValue = false; for (Int_t bi_it = 1; bi_it < nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetNbins() + 1; ++bi_it) { if ((FitRegion_Min != 0xdeadbeef) && (nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinUpEdge(bi_it) <= FitRegion_Min)) { continue; } if ((FitRegion_Max != 0xdeadbeef) && (nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinLowEdge(bi_it) > FitRegion_Max)) { continue; } if (nds.ND_Unfolded_Spectrum_Hist->GetBinContent(bi_it) < 0) { HasNegValue = true; NUIS_LOG(SAM, "After " << truncations << " truncations, bin " << (bi_it - 1) << " [" << nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinLowEdge( bi_it) << " -- " << nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinUpEdge( bi_it) << " ] has value: " << nds.ND_Unfolded_Spectrum_Hist->GetBinContent(bi_it)); break; } } if (HasNegValue) { TMatrixD NDToSpectrumResponseMatrix_l = SmearceptanceUtils::GetMatrix(SmearceptanceUtils::SVDGetInverse( nds.NDToSpectrumSmearingMatrix, truncations)); nds.NDToSpectrumResponseMatrix.ResizeTo(NDToSpectrumResponseMatrix_l); nds.NDToSpectrumResponseMatrix = NDToSpectrumResponseMatrix_l; } truncations++; } while (HasNegValue); } void Smear_SVDUnfold_Propagation_Osc::PropagateFDSample(size_t fds_it) { if (fds_it >= FDSamples.size()) { NUIS_ABORT("Requested FD sample index " << fds_it << " but only initialised " << FDSamples.size()); } FDSample &fds = FDSamples[fds_it]; // Apply Oscillations // ------------------------------ FitWeight *fw = FitBase::GetRW(); OscWeightEngine *oscWE = dynamic_cast(fw->GetRWEngine(kOSCILLATION)); if (!oscWE) { NUIS_ABORT( "Couldn't load oscillation weight engine for sample: " "Smear_SVDUnfold_Propagation_Osc."); } for (Int_t bi_it = 1; bi_it < fds.NDFD_Corrected_Spectrum_Hist->GetXaxis()->GetNbins() + 1; ++bi_it) { double content_osc = 0; double error_osc = 0; double content_fdnd = 0; double error_fdnd = 0; // Oscillate each ND sample to FD neutrino for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { NDSample &nds = NDSamples[nd_it]; double oscWeight = oscWE->CalcWeight( nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinCenter(bi_it), nds.NuPDG, fds.OscillateToPDG); double sample_content_osc = nds.ND_Unfolded_Spectrum_Hist->GetBinContent(bi_it) * oscWeight; double sample_error_osc = nds.ND_Unfolded_Spectrum_Hist->GetBinError(bi_it) * oscWeight; fds.FD_Propagated_Spectrum_Hist_NDSamples[nd_it]->SetBinContent( bi_it, sample_content_osc); fds.FD_Propagated_Spectrum_Hist_NDSamples[nd_it]->SetBinError( bi_it, sample_error_osc); double sample_content_fdnd = sample_content_osc * fds.FDNDRatios[nds.NuPDG] * fds.FDNDMassRatio; double sample_error_fdnd = sample_error_osc * fds.FDNDRatios[nds.NuPDG] * fds.FDNDMassRatio; fds.NDFD_Corrected_Spectrum_Hist_NDSamples[nd_it]->SetBinContent( bi_it, sample_content_fdnd); fds.NDFD_Corrected_Spectrum_Hist_NDSamples[nd_it]->SetBinError( bi_it, sample_error_fdnd); content_osc += sample_content_osc; error_osc += sample_error_osc * sample_error_osc; content_fdnd += sample_content_fdnd; error_fdnd += sample_error_fdnd * sample_error_fdnd; } fds.FD_Propagated_Spectrum_Hist->SetBinContent(bi_it, content_osc); fds.FD_Propagated_Spectrum_Hist->SetBinError(bi_it, sqrt(error_osc)); fds.NDFD_Corrected_Spectrum_Hist->SetBinContent(bi_it, content_fdnd); fds.NDFD_Corrected_Spectrum_Hist->SetBinError(bi_it, sqrt(error_fdnd)); } // Forward fold Spectrum -> ERec FD // ------------------------------ SmearceptanceUtils::PushTH1ThroughMatrixWithErrors( fds.NDFD_Corrected_Spectrum_Hist, fds.FD_Smeared_Spectrum_Hist, fds.SpectrumToFDSmearingMatrix, 1000, true); } void Smear_SVDUnfold_Propagation_Osc::ConvertEventRates(void) { /// Get topology weights /// for each ND sample /// /// Build NDSample::NDToSpectrumSmearingMatrix from sum of topology smearing histos scaled by topology weights /// /// SetupNDInputs(); /// /// for each FD sample /// /// Build FDSample::SpectrumToFDSmearingMatrix_TH2 as above. /// /// Convert to TMatrixD, FDSample::SpectrumToFDSmearingMatrix for (size_t fds_it = 0; fds_it < FDSamples.size(); ++fds_it) { PropagateFDSample(fds_it); } UpdateChi2Hists(); } void Smear_SVDUnfold_Propagation_Osc::Write(std::string drawOpt) { TDirectory *ogDir = gDirectory; ConvertEventRates(); FitWeight *fw = FitBase::GetRW(); OscWeightEngine *oscWE = dynamic_cast(fw->GetRWEngine(kOSCILLATION)); if (!oscWE) { NUIS_ABORT( "Couldn't load oscillation weight engine for sample: " "Smear_SVDUnfold_Propagation_Osc."); } oscWE->Print(); // Write ND samples //---------------- for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { NDSample &nds = NDSamples[nd_it]; std::stringstream ss(""); ss << "Smear_SVDUnfold_Propagation_Osc_NDSample_" << nd_it; if (ogDir) { ogDir->mkdir(ss.str().c_str()); ogDir->cd(ss.str().c_str()); } else { Config::Get().out->mkdir(ss.str().c_str()); Config::Get().out->cd(ss.str().c_str()); } nds.NDToSpectrumSmearingMatrix->Write("SmearingMatrix_ND", TObject::kOverwrite); nds.NDDataHist->Write("Obs_ND", TObject::kOverwrite); nds.ND_Unfolded_Spectrum_Hist->Write( nds.ND_Unfolded_Spectrum_Hist->GetName(), TObject::kOverwrite); if (ogDir) { ogDir->cd(); } else { Config::Get().out->cd(); } } // Write FD samples //---------------- for (size_t fds_it = 0; fds_it < FDSamples.size(); ++fds_it) { FDSample &fds = FDSamples[fds_it]; std::stringstream ss(""); ss << "Smear_SVDUnfold_Propagation_Osc_FDSample_" << fds_it; if (ogDir) { ogDir->mkdir(ss.str().c_str()); ogDir->cd(ss.str().c_str()); } else { Config::Get().out->mkdir(ss.str().c_str()); Config::Get().out->cd(ss.str().c_str()); } // Calc oscillation probability // ------------------------------ FitWeight *fw = FitBase::GetRW(); OscWeightEngine *oscWE = dynamic_cast(fw->GetRWEngine(kOSCILLATION)); if (!oscWE) { NUIS_ABORT( "Couldn't load oscillation weight engine for sample: " "Smear_SVDUnfold_Propagation_Osc."); } for (size_t nd_it = 0; nd_it < NDSamples.size(); ++nd_it) { NDSample &nds = NDSamples[nd_it]; ss.str(""); ss << "NDSample_" << nd_it << "_contribution"; fds.FD_Propagated_Spectrum_Hist_NDSamples[nd_it]->Write( ss.str().c_str(), TObject::kOverwrite); ss.str(""); ss << "NDSample_" << nd_it << "_FDNDCorrected_contribution"; fds.NDFD_Corrected_Spectrum_Hist_NDSamples[nd_it]->Write( ss.str().c_str(), TObject::kOverwrite); ss.str(""); ss << "NDSample_" << nd_it << "_OscillationProb"; TGraph POsc; POsc.Set(1E4 - 1); double min = nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinLowEdge(1); double step = (nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinUpEdge( nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetNbins()) - nds.ND_Unfolded_Spectrum_Hist->GetXaxis()->GetBinLowEdge(1)) / double(1E4); for (size_t i = 1; i < 1E4; ++i) { double enu = min + i * step; double ow = oscWE->CalcWeight(enu, nds.NuPDG, fds.OscillateToPDG); if (ow != ow) { std::cout << "Bad osc weight for ENu: " << enu << std::endl; } POsc.SetPoint(i - 1, enu, ow); } POsc.Write(ss.str().c_str(), TObject::kOverwrite); } fds.FDDataHist->Write("Obs_FD", TObject::kOverwrite); fds.FD_Propagated_Spectrum_Hist->Write( fds.FD_Propagated_Spectrum_Hist->GetName(), TObject::kOverwrite); fds.NDFD_Corrected_Spectrum_Hist->Write( fds.NDFD_Corrected_Spectrum_Hist->GetName(), TObject::kOverwrite); fds.SpectrumToFDSmearingMatrix_TH2->Write("SmearingMatrix_FD", TObject::kOverwrite); fds.FD_Smeared_Spectrum_Hist->Write(fds.FD_Smeared_Spectrum_Hist->GetName(), TObject::kOverwrite); if (ogDir) { ogDir->cd(); } else { Config::Get().out->cd(); } } fMCHist->Write("Pred_FD", TObject::kOverwrite); fDataHist->Write("Obs_FD", TObject::kOverwrite); Measurement1D::Write(drawOpt); } diff --git a/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.h b/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.h index 752888f..3c98291 100644 --- a/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.h +++ b/src/MCStudies/Smear_SVDUnfold_Propagation_Osc.h @@ -1,119 +1,119 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef Smear_SVDUnfold_Propagation_Osc_H_SEEN #define Smear_SVDUnfold_Propagation_Osc_H_SEEN #include "Measurement1D.h" /// Class for building simple oscillation analyses. /// /// An example tag which runs a FHC beam and performs a numudisp and nue app /// measurement might look like: /// /// /// /// /// /// class Smear_SVDUnfold_Propagation_Osc : public Measurement1D { public: struct FDSample { TH1D *FDDataHist; std::vector FD_Propagated_Spectrum_Hist_NDSamples; std::vector NDFD_Corrected_Spectrum_Hist_NDSamples; TH1D *FD_Propagated_Spectrum_Hist; TH1D *NDFD_Corrected_Spectrum_Hist; TH1D *FD_Smeared_Spectrum_Hist; TH2D *SpectrumToFDSmearingMatrix_TH2; TMatrixD SpectrumToFDSmearingMatrix; Int_t OscillateToPDG; double FitRegion_Min; double FitRegion_Max; std::map FDNDRatios; double FDNDMassRatio; std::pair DetectorInfo; }; struct NDSample { TH1D *NDDataHist; Int_t TruncateStart; Int_t TruncateUpTo; TH1D *ND_Unfolded_Spectrum_Hist; TH2D *NDToSpectrumSmearingMatrix; TMatrixD NDToSpectrumResponseMatrix; Int_t NuPDG; double XSecToEvRateScale; }; public: Smear_SVDUnfold_Propagation_Osc(nuiskey samplekey); virtual ~Smear_SVDUnfold_Propagation_Osc(){}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void UnfoldToNDETrueSpectrum(size_t); void ConvertEventRates(void); void Write(std::string drawOpt); void ReadExtraConfig(nuiskey &samplekey); void SetupChi2Hists(); void UpdateChi2Hists(); // ----- Near detector things void AddNDInputs(nuiskey &samplekey); void SetupNDInputs(); std::vector NDSamples; std::pair NDetectorInfo; double FitRegion_Min; double FitRegion_Max; // ----- Far detector things Int_t NFDAnalysisBins; Int_t GetFDSampleNAnalysisBins(size_t fds_it); void AddFDTarget(nuiskey &nk); void PropagateFDSample(size_t fds_it); void FinaliseFDSamples(); std::vector FDSamples; double ScalePOT; // ----- Other config bool UseRateErrors; }; #endif diff --git a/src/MCStudies/Smearceptance_Tester.cxx b/src/MCStudies/Smearceptance_Tester.cxx index 9ec08cd..174f805 100644 --- a/src/MCStudies/Smearceptance_Tester.cxx +++ b/src/MCStudies/Smearceptance_Tester.cxx @@ -1,881 +1,881 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "Smearceptance_Tester.h" #include "SmearceptanceUtils.h" #include "Smearcepterton.h" //#define DEBUG_SMEARTESTER //******************************************************************** /// @brief Class to perform smearceptance MC Studies on a custom measurement Smearceptance_Tester::Smearceptance_Tester(nuiskey samplekey) { //******************************************************************** samplekey.Print(); // Sample overview --------------------------------------------------- std::string descrip = "Simple measurement class for producing an event summary tree of smeared " "events.\n"; if (Config::HasPar("NPOT")) { samplekey.SetS("NPOT", Config::GetParS("NPOT")); } if (Config::HasPar("FluxIntegralOverride")) { samplekey.SetS("FluxIntegralOverride", Config::GetParS("FluxIntegralOverride")); } if (Config::HasPar("TargetVolume")) { samplekey.SetS("TargetVolume", Config::GetParS("TargetVolume")); } if (Config::HasPar("TargetMaterialDensity")) { samplekey.SetS("TargetMaterialDensity", Config::GetParS("TargetMaterialDensity")); } OutputSummaryTree = true; if (Config::HasPar("smear.OutputSummaryTree")) { OutputSummaryTree = Config::GetParI("smear.OutputSummaryTree"); } // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("Smearceptance Studies"); fSettings.SetDescription(descrip); fSettings.SetXTitle("XXX"); fSettings.SetYTitle("Number of events"); fSettings.SetEnuRange(0.0, 1E5); fSettings.SetAllowedTypes("EVT/SHAPE/DIAG", "EVT/SHAPE/DIAG"); fSettings.DefineAllowedTargets("*"); fSettings.DefineAllowedSpecies("*"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / TotalIntegratedFlux(); // Measurement Details std::vector splitName = GeneralUtils::ParseToStr(fName, "_"); //size_t firstUS = fName.find_first_of("_"); std::string smearceptorName = samplekey.GetS("smearceptor"); NUIS_LOG(SAM, "Using smearceptor: " << smearceptorName << " (parsed from: " << fName << ")."); fDataHist = new TH1D(("empty_data"), ("empty-data"), 1, 0, 1); SetupDefaultHist(); fFullCovar = StatUtils::MakeDiagonalCovarMatrix(fDataHist); covar = StatUtils::GetInvert(fFullCovar); eventVariables = NULL; NUIS_LOG(SAM, "Smearceptance Flux Scaling Factor = " << fScaleFactor); if (fScaleFactor <= 0.0) { NUIS_ERR(WRN, "SCALE FACTOR TOO LOW "); sleep(20); } // Setup our TTrees AddEventVariablesToTree(); smearceptor = &Smearcepterton::Get().GetSmearcepter(smearceptorName); Int_t RecNBins = 20, TrueNBins = 20; double RecBinL = 0xdeadbeef, TrueBinL = 0, RecBinH = 10, TrueBinH = 10; if (Config::HasPar("smear.reconstructed.binning")) { std::vector args = GeneralUtils::ParseToStr( Config::GetParS("smear.reconstructed.binning"), ","); RecNBins = GeneralUtils::StrToInt(args[0]); RecBinL = GeneralUtils::StrToDbl(args[1]); RecBinH = GeneralUtils::StrToDbl(args[2]); TrueNBins = RecNBins; TrueBinL = RecBinL; TrueBinH = RecBinH; } if (Config::HasPar("smear.true.binning")) { std::vector args = GeneralUtils::ParseToStr(Config::GetParS("smear.true.binning"), ","); TrueNBins = GeneralUtils::StrToInt(args[0]); TrueBinL = GeneralUtils::StrToDbl(args[1]); TrueBinH = GeneralUtils::StrToDbl(args[2]); } SVDTruncation = 0; if (Config::HasPar("smear.SVD.truncation")) { SVDTruncation = Config::GetParI("smear.SVD.truncation"); NUIS_LOG(SAM, "Applying SVD truncation of: " << SVDTruncation) } ETrueDistrib = NULL; ETrueDistrib_noweight = NULL; ERecDistrib = NULL; RecoSmear = NULL; if (RecBinL != 0xdeadbeef) { NUIS_LOG(SAM, "Using binning True: " << TrueNBins << ", [" << TrueBinL << " -- " << TrueBinH << "], Rec: " << RecNBins << ", [" << RecBinL << " -- " << RecBinH << "]"); ETrueDistrib = new TH1D("ELep_rate", ";True E_{#nu};Count", TrueNBins, TrueBinL, TrueBinH); ETrueDistrib_noweight = new TH1D("ELep_rate_noweight", ";True E_{#nu};Count", TrueNBins, TrueBinL, TrueBinH); ERecDistrib = new TH1D("ELepRec_rate", ";Rec E_{#nu};Count", RecNBins, RecBinL, RecBinH); ETrueDistrib->Sumw2(); ERecDistrib->Sumw2(); RecoSmear = new TH2D("ELepHadVis_Recon", ";True E_{#nu};Recon. E_{#nu}", RecNBins, RecBinL, RecBinH, TrueNBins, TrueBinL, TrueBinH); RecoSmear->Sumw2(); } // Final setup --------------------------------------------------- FinaliseMeasurement(); } void Smearceptance_Tester::AddEventVariablesToTree() { if (OutputSummaryTree) { // Setup the TTree to save everything if (!eventVariables) { Config::Get().out->cd(); eventVariables = new TTree((fName + "_VARS").c_str(), (fName + "_VARS").c_str()); } NUIS_LOG(SAM, "Adding Event Variables"); eventVariables->Branch("Omega_true", &Omega_true, "Omega_true/F"); eventVariables->Branch("Q2_true", &Q2_true, "Q2_true/F"); eventVariables->Branch("Mode_true", &Mode_true, "Mode_true/I"); eventVariables->Branch("EISLep_true", &EISLep_true, "EISLep_true/F"); eventVariables->Branch("HMFS_clep_true", &HMFS_clep_true); eventVariables->Branch("HMFS_pip_true", &HMFS_pip_true); eventVariables->Branch("HMFS_pim_true", &HMFS_pim_true); eventVariables->Branch("HMFS_cpi_true", &HMFS_cpi_true); eventVariables->Branch("HMFS_pi0_true", &HMFS_pi0_true); eventVariables->Branch("HMFS_cK_true", &HMFS_cK_true); eventVariables->Branch("HMFS_K0_true", &HMFS_K0_true); eventVariables->Branch("HMFS_p_true", &HMFS_p_true); eventVariables->Branch("KEFSHad_cpip_true", &KEFSHad_cpip_true, "KEFSHad_cpip_true/F"); eventVariables->Branch("KEFSHad_cpim_true", &KEFSHad_cpim_true, "KEFSHad_cpim_true/F"); eventVariables->Branch("KEFSHad_cpi_true", &KEFSHad_cpi_true, "KEFSHad_cpi_true/F"); eventVariables->Branch("TEFSHad_pi0_true", &TEFSHad_pi0_true, "TEFSHad_pi0_true/F"); eventVariables->Branch("KEFSHad_cK_true", &KEFSHad_cK_true, "KEFSHad_cK_true/F"); eventVariables->Branch("KEFSHad_K0_true", &KEFSHad_K0_true, "KEFSHad_K0_true/F"); eventVariables->Branch("KEFSHad_p_true", &KEFSHad_p_true, "KEFSHad_p_true/F"); eventVariables->Branch("KEFSHad_n_true", &KEFSHad_n_true, "KEFSHad_n_true/F"); eventVariables->Branch("EFSHad_true", &EFSHad_true, "EFSHad_true/F"); eventVariables->Branch("EFSChargedEMHad_true", &EFSChargedEMHad_true, "EFSChargedEMHad_true/F"); eventVariables->Branch("EFSLep_true", &EFSLep_true, "EFSLep_true/F"); eventVariables->Branch("EFSgamma_true", &EFSgamma_true, "EFSgamma_true/F"); eventVariables->Branch("PDGISLep_true", &PDGISLep_true, "PDGISLep_true/I"); eventVariables->Branch("PDGFSLep_true", &PDGFSLep_true, "PDGFSLep_true/I"); eventVariables->Branch("Nprotons_true", &Nprotons_true, "Nprotons_true/I"); eventVariables->Branch("Nneutrons_true", &Nneutrons_true, "Nneutrons_true/I"); eventVariables->Branch("Ncpiplus_true", &Ncpiplus_true, "Ncpiplus_true/I"); eventVariables->Branch("Ncpiminus_true", &Ncpiminus_true, "Ncpiminus_true/I"); eventVariables->Branch("Ncpi_true", &Ncpi_true, "Ncpi_true/I"); eventVariables->Branch("Npi0_true", &Npi0_true, "Npi0_true/I"); eventVariables->Branch("NcK_true", &NcK_true, "NcK_true/I"); eventVariables->Branch("NK0_true", &NK0_true, "NK0_true/I"); eventVariables->Branch("HMFS_clep_rec", &HMFS_clep_rec); eventVariables->Branch("HMFS_pip_rec", &HMFS_pip_rec); eventVariables->Branch("HMFS_pim_rec", &HMFS_pim_rec); eventVariables->Branch("HMFS_cpi_rec", &HMFS_cpi_rec); eventVariables->Branch("HMFS_pi0_rec", &HMFS_pi0_rec); eventVariables->Branch("HMFS_cK_rec", &HMFS_cK_rec); eventVariables->Branch("HMFS_K0_rec", &HMFS_K0_rec); eventVariables->Branch("HMFS_p_rec", &HMFS_p_rec); eventVariables->Branch("KEFSHad_cpip_rec", &KEFSHad_cpip_rec, "KEFSHad_cpip_rec/F"); eventVariables->Branch("KEFSHad_cpim_rec", &KEFSHad_cpim_rec, "KEFSHad_cpim_rec/F"); eventVariables->Branch("KEFSHad_cpi_rec", &KEFSHad_cpi_rec, "KEFSHad_cpi_rec/F"); eventVariables->Branch("TEFSHad_pi0_rec", &TEFSHad_pi0_rec, "TEFSHad_pi0_rec/F"); eventVariables->Branch("KEFSHad_cK_rec", &KEFSHad_cK_rec, "KEFSHad_cK_rec/F"); eventVariables->Branch("KEFSHad_K0_rec", &KEFSHad_K0_rec, "KEFSHad_K0_rec/F"); eventVariables->Branch("KEFSHad_p_rec", &KEFSHad_p_rec, "KEFSHad_p_rec/F"); eventVariables->Branch("KEFSHad_n_rec", &KEFSHad_n_rec, "KEFSHad_n_rec/F"); eventVariables->Branch("EFSHad_rec", &EFSHad_rec, "EFSHad_rec/F"); eventVariables->Branch("EFSLep_rec", &EFSLep_rec, "EFSLep_rec/F"); eventVariables->Branch("EFSVis_cpip", &EFSVis_cpip, "EFSVis_cpip/F"); eventVariables->Branch("EFSVis_cpim", &EFSVis_cpim, "EFSVis_cpim/F"); eventVariables->Branch("EFSVis_cpi", &EFSVis_cpi, "EFSVis_cpi/F"); eventVariables->Branch("EFSVis_pi0", &EFSVis_pi0, "EFSVis_pi0/F"); eventVariables->Branch("EFSVis_cK", &EFSVis_cK, "EFSVis_cK/F"); eventVariables->Branch("EFSVis_K0", &EFSVis_K0, "EFSVis_K0/F"); eventVariables->Branch("EFSVis_p", &EFSVis_p, "EFSVis_p/F"); eventVariables->Branch("EFSVis_n", &EFSVis_n, "EFSVis_n/F"); eventVariables->Branch("EFSVis_gamma", &EFSVis_gamma, "EFSVis_gamma/F"); eventVariables->Branch("EFSVis_other", &EFSVis_other, "EFSVis_other/F"); eventVariables->Branch("EFSVis", &EFSVis, "EFSVis/F"); eventVariables->Branch("FSCLep_seen", &FSCLep_seen, "FSCLep_seen/I"); eventVariables->Branch("Nprotons_seen", &Nprotons_seen, "Nprotons_seen/I"); eventVariables->Branch("Nneutrons_seen", &Nneutrons_seen, "Nneutrons_seen/I"); eventVariables->Branch("Ncpip_seen", &Ncpip_seen, "Ncpip_seen/I"); eventVariables->Branch("Ncpim_seen", &Ncpim_seen, "Ncpim_seen/I"); eventVariables->Branch("Ncpi_seen", &Ncpi_seen, "Ncpi_seen/I"); eventVariables->Branch("Npi0_seen", &Npi0_seen, "Npi0_seen/I"); eventVariables->Branch("NcK_seen", &NcK_seen, "NcK_seen/I"); eventVariables->Branch("NK0_seen", &NK0_seen, "NK0_seen/I"); eventVariables->Branch("Nothers_seen", &Nothers_seen, "Nothers_seen/I"); eventVariables->Branch("EISLep_QE_rec", &EISLep_QE_rec, "EISLep_QE_rec/F"); eventVariables->Branch("EISLep_LepHad_rec", &EISLep_LepHad_rec, "EISLep_LepHad_rec/F"); eventVariables->Branch("EISLep_LepHadVis_rec", &EISLep_LepHadVis_rec, "EISLep_LepHadVis_rec/F"); eventVariables->Branch("Nprotons_contributed", &Nprotons_contributed, "Nprotons_contributed/I"); eventVariables->Branch("Nneutrons_contributed", &Nneutrons_contributed, "Nneutrons_contributed/I"); eventVariables->Branch("Ncpip_contributed", &Ncpip_contributed, "Ncpip_contributed/I"); eventVariables->Branch("Ncpim_contributed", &Ncpim_contributed, "Ncpim_contributed/I"); eventVariables->Branch("Ncpi_contributed", &Ncpi_contributed, "Ncpi_contributed/I"); eventVariables->Branch("Npi0_contributed", &Npi0_contributed, "Npi0_contributed/I"); eventVariables->Branch("NcK_contributed", &NcK_contributed, "NcK_contributed/I"); eventVariables->Branch("NK0_contributed", &NK0_contributed, "NK0_contributed/I"); eventVariables->Branch("Ngamma_contributed", &Ngamma_contributed, "Ngamma_contributed/I"); eventVariables->Branch("Nothers_contibuted", &Nothers_contibuted, "Nothers_contibuted/I"); eventVariables->Branch("Weight", &Weight, "Weight/F"); eventVariables->Branch("RWWeight", &RWWeight, "RWWeight/F"); eventVariables->Branch("InputWeight", &InputWeight, "InputWeight/F"); eventVariables->Branch("FluxWeight", &FluxWeight, "FluxWeight/F"); eventVariables->Branch("EffWeight", &EffWeight, "EffWeight/F"); xsecScaling = fScaleFactor; eventVariables->Branch("xsecScaling", &xsecScaling, "xsecScaling/F"); eventVariables->Branch("flagCCINC_true", &flagCCINC_true, "flagCCINC_true/O"); eventVariables->Branch("flagCC0K_true", &flagCC0K_true, "flagCC0K_true/O"); eventVariables->Branch("flagCC0Pi_true", &flagCC0Pi_true, "flagCC0Pi_true/O"); eventVariables->Branch("flagCC1Pi_true", &flagCC1Pi_true, "flagCC1Pi_true/O"); eventVariables->Branch("flagCCINC_rec", &flagCCINC_rec, "flagCCINC_rec/O"); eventVariables->Branch("flagCC0K_rec", &flagCC0K_rec, "flagCC0K_rec/O"); eventVariables->Branch("flagCC0Pi_rec", &flagCC0Pi_rec, "flagCC0Pi_rec/O"); eventVariables->Branch("flagCC1Pi_rec", &flagCC1Pi_rec, "flagCC1Pi_rec/O"); } PredEvtRateWeight = 1; if (fEvtRateScaleFactor != 0xdeadbeef) { if (OutputSummaryTree) { eventVariables->Branch("PredEvtRateWeight", &PredEvtRateWeight, "PredEvtRateWeight/F"); } PredEvtRateWeight = fScaleFactor * fEvtRateScaleFactor; } } template int CountNPdgsSeen(RecoInfo ri, int const (&pdgs)[N]) { int sum = 0; for (size_t pdg_it = 0; pdg_it < N; ++pdg_it) { sum += std::count(ri.RecObjClass.begin(), ri.RecObjClass.end(), pdgs[pdg_it]); } return sum; } template int CountNNotPdgsSeen(RecoInfo ri, int const (&pdgs)[N]) { int sum = 0; for (size_t p_it = 0; p_it < ri.RecObjClass.size(); ++p_it) { if (!std::count(pdgs, pdgs + N, ri.RecObjClass[p_it])) { sum++; } } return sum; } template int CountNPdgsContributed(RecoInfo ri, int const (&pdgs)[N]) { int sum = 0; for (size_t pdg_it = 0; pdg_it < N; ++pdg_it) { sum += std::count(ri.TrueContribPDGs.begin(), ri.TrueContribPDGs.end(), pdgs[pdg_it]); } return sum; } template int CountNNotPdgsContributed(RecoInfo ri, int const (&pdgs)[N]) { int sum = 0; for (size_t p_it = 0; p_it < ri.TrueContribPDGs.size(); ++p_it) { if (!std::count(pdgs, pdgs + N, ri.TrueContribPDGs[p_it])) { sum++; } } return sum; } TLorentzVector GetHMFSRecParticles(RecoInfo ri, int pdg) { TLorentzVector mom(0, 0, 0, 0); for (size_t p_it = 0; p_it < ri.RecObjMom.size(); ++p_it) { if ((ri.RecObjClass[p_it] == pdg) && (mom.Mag() < ri.RecObjMom[p_it].Mag())) { mom.SetXYZM(ri.RecObjMom[p_it].X(), ri.RecObjMom[p_it].Y(), ri.RecObjMom[p_it].Z(), PhysConst::GetMass(ri.RecObjClass[p_it]) * 1.0E3); } } return mom; } template double SumKE_RecoInfo(RecoInfo ri, int const (&pdgs)[N], double mass) { double sum = 0; for (size_t p_it = 0; p_it < ri.RecObjMom.size(); ++p_it) { if (!std::count(pdgs, pdgs + N, ri.RecObjClass[p_it])) { // If we don't care about this // particle type. continue; } sum += sqrt(ri.RecObjMom[p_it].Mag2() + mass * mass) - mass; } return sum; } template double SumTE_RecoInfo(RecoInfo ri, int const (&pdgs)[N], double mass) { double sum = 0; for (size_t p_it = 0; p_it < ri.RecObjMom.size(); ++p_it) { if (!std::count(pdgs, pdgs + N, ri.RecObjClass[p_it])) { // If we don't care about this // particle type. continue; } sum += sqrt(ri.RecObjMom[p_it].Mag2() + mass * mass); } return sum; } template double SumVisE_RecoInfo(RecoInfo ri, int const (&pdgs)[N]) { double sum = 0; for (size_t p_it = 0; p_it < ri.RecVisibleEnergy.size(); ++p_it) { if (!std::count(pdgs, pdgs + N, ri.TrueContribPDGs[p_it])) { // If we don't care about this // particle type. continue; } sum += ri.RecVisibleEnergy[p_it]; } return sum; } template double SumVisE_RecoInfo_NotPdgs(RecoInfo ri, int const (&pdgs)[N]) { double sum = 0; for (size_t p_it = 0; p_it < ri.RecVisibleEnergy.size(); ++p_it) { if (std::count(pdgs, pdgs + N, ri.TrueContribPDGs[p_it])) { // If we know about this // particle type. continue; } sum += ri.RecVisibleEnergy[p_it]; } return sum; } //******************************************************************** void Smearceptance_Tester::FillEventVariables(FitEvent *event) { //******************************************************************** static int const cpipPDG[] = {211}; static int const cpimPDG[] = {-211}; static int const pi0PDG[] = {111}; static int const cKPDG[] = {321, -321}; static int const K0PDG[] = {311, 310, 130}; static int const ProtonPDG[] = {2212}; static int const NeutronPDG[] = {2112}; static int const GammaPDG[] = {22}; static int const CLeptonPDGs[] = {11, 13, 15, -11, -13, -15}; static int const ExplicitPDGs[] = {211, -211, 111, 321, -321, 311, 310, 130, 2212, 2112, 22, 11, 13, 15, 12, 14, 16, -11, -13, -15, -12, -14, -16}; RecoInfo *ri = smearceptor->Smearcept(event); //** START Pions HMFS_clep_true = TLorentzVector(0, 0, 0, 0); HMFS_clep_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fsCLep = event->GetHMFSParticle(CLeptonPDGs); if (fsCLep) { HMFS_clep_true = fsCLep->P4(); HMFS_clep_rec = GetHMFSRecParticles(*ri, fsCLep->PDG()); } //** END Charged leptons //** START Pions HMFS_pip_true = TLorentzVector(0, 0, 0, 0); HMFS_pip_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fsPip = event->GetHMFSPiPlus(); if (fsPip) { HMFS_pip_true = fsPip->P4(); HMFS_pip_rec = GetHMFSRecParticles(*ri, fsPip->PDG()); } HMFS_pim_true = TLorentzVector(0, 0, 0, 0); HMFS_pim_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fsPim = event->GetHMFSPiMinus(); if (fsPim) { HMFS_pim_true = fsPim->P4(); HMFS_pim_rec = GetHMFSRecParticles(*ri, fsPim->PDG()); } HMFS_cpi_true = TLorentzVector(0, 0, 0, 0); HMFS_cpi_rec = TLorentzVector(0, 0, 0, 0); if (fsPip || fsPim) { if (!fsPip) { HMFS_cpi_true = HMFS_pim_true; HMFS_cpi_rec = HMFS_pim_rec; } else if (!fsPim) { HMFS_cpi_true = HMFS_pip_true; HMFS_cpi_rec = HMFS_pip_rec; } else { HMFS_cpi_true = (fsPip->p2() > fsPim->p2()) ? HMFS_pip_true : HMFS_pim_true; HMFS_cpi_rec = (fsPip->p2() > fsPim->p2()) ? HMFS_pip_rec : HMFS_pim_rec; } } HMFS_pi0_true = TLorentzVector(0, 0, 0, 0); HMFS_pi0_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fsPi0 = event->GetHMFSPiZero(); if (fsPi0) { HMFS_pi0_true = fsPi0->P4(); HMFS_pi0_rec = GetHMFSRecParticles(*ri, fsPi0->PDG()); } //** END Pions //** START Kaons HMFS_cK_true = TLorentzVector(0, 0, 0, 0); HMFS_cK_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fscK = event->GetHMFSParticle(cKPDG); if (fscK) { HMFS_cK_true = fscK->P4(); HMFS_cK_rec = GetHMFSRecParticles(*ri, fscK->PDG()); } HMFS_K0_true = TLorentzVector(0, 0, 0, 0); HMFS_K0_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fsK0 = event->GetHMFSParticle(K0PDG); if (fsK0) { HMFS_K0_true = fsK0->P4(); HMFS_K0_rec = GetHMFSRecParticles(*ri, fsK0->PDG()); } //** END Kaons //** START Nucleons HMFS_p_true = TLorentzVector(0, 0, 0, 0); HMFS_p_rec = TLorentzVector(0, 0, 0, 0); FitParticle *fsP = event->GetHMFSProton(); if (fsP) { HMFS_p_true = fsP->P4(); HMFS_p_rec = GetHMFSRecParticles(*ri, fsP->PDG()); } TLorentzVector FourMomentumTransfer = (event->GetHMISAnyLeptons()->P4() - event->GetHMFSAnyLeptons()->P4()); Omega_true = FourMomentumTransfer.E(); Q2_true = -1 * FourMomentumTransfer.Mag2(); Mode_true = event->Mode; EISLep_true = event->GetHMISAnyLeptons()->E(); KEFSHad_cpip_true = FitUtils::SumTE_PartVect(event->GetAllFSPiPlus()); KEFSHad_cpim_true = FitUtils::SumTE_PartVect(event->GetAllFSPiMinus()); KEFSHad_cpi_true = KEFSHad_cpip_true + KEFSHad_cpim_true; TEFSHad_pi0_true = FitUtils::SumTE_PartVect(event->GetAllFSPiZero()); KEFSHad_cK_true = FitUtils::SumTE_PartVect(event->GetAllFSParticle(cKPDG)); KEFSHad_K0_true = FitUtils::SumTE_PartVect(event->GetAllFSParticle(K0PDG)); KEFSHad_p_true = FitUtils::SumKE_PartVect(event->GetAllFSProton()); KEFSHad_n_true = FitUtils::SumKE_PartVect(event->GetAllFSNeutron()); EFSHad_true = KEFSHad_cpi_true + TEFSHad_pi0_true + KEFSHad_p_true + KEFSHad_n_true; EFSChargedEMHad_true = KEFSHad_cpi_true + TEFSHad_pi0_true + KEFSHad_p_true + KEFSHad_cK_true + KEFSHad_K0_true; EFSLep_true = event->GetHMFSAnyLeptons()->E(); EFSgamma_true = FitUtils::SumTE_PartVect(event->GetAllFSPhoton()); PDGISLep_true = event->GetHMISAnyLeptons()->PDG(); PDGFSLep_true = event->GetHMFSAnyLeptons()->PDG(); Nprotons_true = event->GetAllFSProton().size(); Nneutrons_true = event->GetAllFSNeutron().size(); Ncpiplus_true = event->GetAllFSPiPlus().size(); Ncpiminus_true = event->GetAllFSPiMinus().size(); Ncpi_true = Ncpiplus_true + Ncpiminus_true; Npi0_true = event->GetAllFSPiZero().size(); NcK_true = event->GetAllFSParticle(cKPDG).size(); NK0_true = event->GetAllFSParticle(K0PDG).size(); KEFSHad_cpip_rec = SumKE_RecoInfo(*ri, cpipPDG, PhysConst::mass_cpi * PhysConst::mass_MeV); KEFSHad_cpim_rec = SumKE_RecoInfo(*ri, cpimPDG, PhysConst::mass_cpi * PhysConst::mass_MeV); KEFSHad_cpi_rec = KEFSHad_cpip_rec + KEFSHad_cpim_rec; TEFSHad_pi0_rec = SumTE_RecoInfo(*ri, pi0PDG, PhysConst::mass_pi0 * PhysConst::mass_MeV); KEFSHad_cK_rec = SumKE_RecoInfo(*ri, cKPDG, PhysConst::mass_cK * PhysConst::mass_MeV); KEFSHad_K0_rec = SumKE_RecoInfo(*ri, K0PDG, PhysConst::mass_K0 * PhysConst::mass_MeV); KEFSHad_p_rec = SumKE_RecoInfo(*ri, ProtonPDG, PhysConst::mass_proton * PhysConst::mass_MeV); KEFSHad_n_rec = SumKE_RecoInfo(*ri, NeutronPDG, PhysConst::mass_neutron * PhysConst::mass_MeV); EFSHad_rec = KEFSHad_cpi_rec + TEFSHad_pi0_rec + KEFSHad_p_rec + KEFSHad_n_rec; TLorentzVector FSLepMom_rec(0, 0, 0, 0); if (event->GetHMFSAnyLeptons()) { FSLepMom_rec = GetHMFSRecParticles(*ri, event->GetHMFSAnyLeptons()->PDG()); EFSLep_rec = FSLepMom_rec.E(); } else { EFSLep_rec = 0; } EFSVis_cpip = SumVisE_RecoInfo(*ri, cpipPDG); EFSVis_cpim = SumVisE_RecoInfo(*ri, cpimPDG); EFSVis_cpi = EFSVis_cpip + EFSVis_cpim; EFSVis_pi0 = SumVisE_RecoInfo(*ri, pi0PDG); EFSVis_cK = SumVisE_RecoInfo(*ri, cKPDG); EFSVis_K0 = SumVisE_RecoInfo(*ri, K0PDG); EFSVis_p = SumVisE_RecoInfo(*ri, ProtonPDG); EFSVis_n = SumVisE_RecoInfo(*ri, NeutronPDG); EFSVis_gamma = SumVisE_RecoInfo(*ri, GammaPDG); EFSVis_other = SumVisE_RecoInfo_NotPdgs(*ri, ExplicitPDGs); EFSVis = EFSVis_cpi + EFSVis_pi0 + EFSVis_p + EFSVis_n + EFSVis_gamma + EFSVis_cK + EFSVis_K0; FSCLep_seen = CountNPdgsSeen(*ri, CLeptonPDGs); Nprotons_seen = CountNPdgsSeen(*ri, ProtonPDG); Nneutrons_seen = CountNPdgsSeen(*ri, NeutronPDG); Ncpip_seen = CountNPdgsSeen(*ri, cpipPDG); Ncpim_seen = CountNPdgsSeen(*ri, cpimPDG); Ncpi_seen = Ncpip_seen + Ncpim_seen; Npi0_seen = CountNPdgsSeen(*ri, pi0PDG); NcK_seen = CountNPdgsSeen(*ri, cKPDG); NK0_seen = CountNPdgsSeen(*ri, K0PDG); Nothers_seen = CountNNotPdgsSeen(*ri, ExplicitPDGs); if (FSCLep_seen && (FSLepMom_rec.Mag() > 1E-8)) { EISLep_QE_rec = FitUtils::EnuQErec(FSLepMom_rec.Mag() / 1000.0, FSLepMom_rec.CosTheta(), 34, PDGFSLep_true > 0) * 1000.0; } else { EISLep_QE_rec = 0; } EISLep_LepHad_rec = EFSLep_rec + EFSHad_rec; EISLep_LepHadVis_rec = EFSLep_rec + EFSHad_rec + EFSVis; Nprotons_contributed = CountNPdgsContributed(*ri, ProtonPDG); Nneutrons_contributed = CountNPdgsContributed(*ri, NeutronPDG); Ncpip_contributed = CountNPdgsContributed(*ri, cpipPDG); Ncpim_contributed = CountNPdgsContributed(*ri, cpimPDG); Ncpi_contributed = Ncpip_contributed + Ncpim_contributed; Npi0_contributed = CountNPdgsContributed(*ri, pi0PDG); NcK_contributed = CountNPdgsContributed(*ri, cKPDG); NK0_contributed = CountNPdgsContributed(*ri, K0PDG); Ngamma_contributed = CountNPdgsContributed(*ri, GammaPDG); Nothers_contibuted = CountNNotPdgsContributed(*ri, ExplicitPDGs); Weight = event->RWWeight * event->InputWeight; RWWeight = event->RWWeight; InputWeight = event->InputWeight; FluxWeight = GetFluxHistogram()->GetBinContent( GetFluxHistogram()->FindBin(EISLep_true)) / GetFluxHistogram()->Integral(); EffWeight = ri->Weight; flagCCINC_true = PDGFSLep_true & 1; flagCC0K_true = (NcK_true + NK0_true) == 0; flagCC0Pi_true = flagCCINC_true && flagCC0K_true && ((Ncpi_true + Npi0_true) == 0); flagCC1Pi_true = flagCCINC_true && flagCC0K_true && ((Ncpi_true + Npi0_true) == 1); flagCCINC_rec = FSCLep_seen && flagCCINC_true; flagCC0K_rec = (NcK_seen + NK0_seen) == 0; flagCC0Pi_rec = flagCCINC_rec && flagCC0K_rec && ((Ncpi_seen + Npi0_seen) == 0); flagCC1Pi_rec = flagCCINC_rec && flagCC0K_rec && ((Ncpi_seen + Npi0_seen) == 1); if (OutputSummaryTree) { // Fill the eventVariables Tree eventVariables->Fill(); } if (RecoSmear) { RecoSmear->Fill(EISLep_true / 1000.0, flagCCINC_rec ? EISLep_LepHadVis_rec / 1000.0 : -1, Weight); ETrueDistrib_noweight->Fill(EISLep_true / 1000.0, flagCCINC_true ? Weight : 0); ETrueDistrib->Fill(EISLep_true / 1000.0, flagCCINC_true ? Weight * PredEvtRateWeight : 0); ERecDistrib->Fill(EISLep_LepHadVis_rec / 1000.0, flagCCINC_rec ? Weight * PredEvtRateWeight : 0); } }; //******************************************************************** void Smearceptance_Tester::Write(std::string drawOpt) { //******************************************************************** if (OutputSummaryTree) { // First save the TTree eventVariables->Write(); } // Save Flux and Event Histograms too GetInput()->GetFluxHistogram()->Write(); GetInput()->GetEventHistogram()->Write(); if (!RecoSmear) { return; } TH2D *SmearMatrix_ev = static_cast(RecoSmear->Clone("ELepHadVis_Smear_ev")); for (Int_t trueAxis_it = 1; trueAxis_it < RecoSmear->GetXaxis()->GetNbins() + 1; ++trueAxis_it) { double NEISLep = ETrueDistrib_noweight->GetBinContent(trueAxis_it); for (Int_t recoAxis_it = 1; recoAxis_it < RecoSmear->GetYaxis()->GetNbins() + 1; ++recoAxis_it) { if (NEISLep > std::numeric_limits::epsilon()) { SmearMatrix_ev->SetBinContent( trueAxis_it, recoAxis_it, SmearMatrix_ev->GetBinContent(trueAxis_it, recoAxis_it) / NEISLep); } } } ETrueDistrib_noweight->Write(); ETrueDistrib->Write(); ERecDistrib->Write(); RecoSmear->Write(); SmearMatrix_ev->Write(); TH2D *ResponseMatrix_ev = SmearceptanceUtils::SVDGetInverse(SmearMatrix_ev, SVDTruncation); ResponseMatrix_ev->SetName("ResponseMatrix_ev"); ResponseMatrix_ev->Write(); #ifdef DEBUG_SMEARTESTER TMatrixD SmearMatrix_ev_md = SmearceptanceUtils::GetMatrix(SmearMatrix_ev); TH1D *SmearedEvt = static_cast(ERecDistrib->Clone()); SmearedEvt->SetNameTitle("SmearedEvt", ";Rec E_{#nu}; count"); SmearceptanceUtils::PushTH1ThroughMatrixWithErrors( ETrueDistrib, SmearedEvt, SmearMatrix_ev_md, 5000, false); SmearedEvt->Write(); SmearedEvt->Scale(1, "width"); SmearedEvt->SetName("SmearedEvt_bw"); SmearedEvt->Write(); #endif #ifdef __PROB3PP_ENABLED__ FitWeight *fw = FitBase::GetRW(); if (fw->HasRWEngine(kOSCILLATION)) { OscWeightEngine *oscWE = dynamic_cast(fw->GetRWEngine(kOSCILLATION)); TGraph POsc; POsc.Set(1E4 - 1); double min = ETrueDistrib->GetXaxis()->GetBinLowEdge(1); double step = (ETrueDistrib->GetXaxis()->GetBinUpEdge( ETrueDistrib->GetXaxis()->GetNbins()) - ETrueDistrib->GetXaxis()->GetBinLowEdge(1)) / double(1E4); for (size_t i = 1; i < 1E4; ++i) { double enu = min + i * step; double ow = oscWE->CalcWeight(enu, 14); if (ow != ow) { std::cout << "Bad osc weight for ENu: " << enu << std::endl; } POsc.SetPoint(i - 1, enu, ow); } POsc.Write("POsc", TObject::kOverwrite); } #endif TMatrixD ResponseMatrix_evt_md = SmearceptanceUtils::GetMatrix(ResponseMatrix_ev); TH1D *Unfolded_enu_obs = static_cast(ETrueDistrib->Clone()); Unfolded_enu_obs->SetNameTitle("UnfoldedENu_evt", ";True E_{#nu};count"); SmearceptanceUtils::PushTH1ThroughMatrixWithErrors( ERecDistrib, Unfolded_enu_obs, ResponseMatrix_evt_md, 5000, false); Unfolded_enu_obs->Write(); Unfolded_enu_obs->Scale(1, "width"); Unfolded_enu_obs->SetName("UnfoldedENu_evt_bw"); Unfolded_enu_obs->Write(); ETrueDistrib->Scale(1, "width"); ETrueDistrib->SetName("ELep_rate_bw"); ETrueDistrib->Write(); ERecDistrib->Scale(1, "width"); ERecDistrib->SetName("ELepRec_rate_bw"); ERecDistrib->Write(); } // ------------------------------------------------------------------- // Purely MC Plot // Following functions are just overrides to handle this // ------------------------------------------------------------------- //******************************************************************** /// Everything is classed as signal... bool Smearceptance_Tester::isSignal(FitEvent *event) { //******************************************************************** (void)event; return true; }; //******************************************************************** void Smearceptance_Tester::ScaleEvents() { //******************************************************************** // Saving everything to a TTree so no scaling required return; } //******************************************************************** void Smearceptance_Tester::ApplyNormScale(float norm) { //******************************************************************** // Saving everything to a TTree so no scaling required fCurrentNorm = norm; return; } //******************************************************************** void Smearceptance_Tester::FillHistograms() { //******************************************************************** // No Histograms need filling........ return; } //******************************************************************** void Smearceptance_Tester::ResetAll() { //******************************************************************** if (OutputSummaryTree) { eventVariables->Reset(); } return; } //******************************************************************** float Smearceptance_Tester::GetChi2() { //******************************************************************** // No Likelihood to test, purely MC return 0.0; } diff --git a/src/MCStudies/Smearceptance_Tester.h b/src/MCStudies/Smearceptance_Tester.h index aa97221..673ac4a 100644 --- a/src/MCStudies/Smearceptance_Tester.h +++ b/src/MCStudies/Smearceptance_Tester.h @@ -1,201 +1,201 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef Smearceptance_Tester_H_SEEN #define Smearceptance_Tester_H_SEEN #include "Measurement1D.h" #include "ISmearcepter.h" #ifdef __PROB3PP_ENABLED__ #include "OscWeightEngine.h" #endif //******************************************************************** class Smearceptance_Tester : public Measurement1D { //******************************************************************** public: Smearceptance_Tester(nuiskey samplekey); virtual ~Smearceptance_Tester(){}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Fill Custom Histograms void FillHistograms(); //! ResetAll void ResetAll(); //! Scale void ScaleEvents(); //! Norm void ApplyNormScale(float norm); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); //! Get Chi2 float GetChi2(); void AddEventVariablesToTree(); private: ISmearcepter *smearceptor; TTree *eventVariables; float Omega_true; float Q2_true; int Mode_true; float EISLep_true; TLorentzVector HMFS_clep_true; TLorentzVector HMFS_pip_true; TLorentzVector HMFS_pim_true; TLorentzVector HMFS_cpi_true; TLorentzVector HMFS_pi0_true; TLorentzVector HMFS_cK_true; TLorentzVector HMFS_K0_true; TLorentzVector HMFS_p_true; float KEFSHad_cpip_true; float KEFSHad_cpim_true; float KEFSHad_cpi_true; float TEFSHad_pi0_true; float KEFSHad_cK_true; float KEFSHad_K0_true; float KEFSHad_p_true; float KEFSHad_n_true; float EFSHad_true; float EFSChargedEMHad_true; float EFSLep_true; float EFSgamma_true; int PDGISLep_true; int PDGFSLep_true; int Nprotons_true; int Nneutrons_true; int Ncpiplus_true; int Ncpiminus_true; int Ncpi_true; int Npi0_true; int NcK_true; int NK0_true; TLorentzVector HMFS_clep_rec; TLorentzVector HMFS_pip_rec; TLorentzVector HMFS_pim_rec; TLorentzVector HMFS_cpi_rec; TLorentzVector HMFS_pi0_rec; TLorentzVector HMFS_cK_rec; TLorentzVector HMFS_K0_rec; TLorentzVector HMFS_p_rec; float KEFSHad_cpip_rec; float KEFSHad_cpim_rec; float KEFSHad_cpi_rec; float TEFSHad_pi0_rec; float KEFSHad_cK_rec; float KEFSHad_K0_rec; float KEFSHad_p_rec; float KEFSHad_n_rec; float EFSHad_rec; float EFSLep_rec; float EFSVis_cpip; float EFSVis_cpim; float EFSVis_cpi; float EFSVis_pi0; float EFSVis_cK; float EFSVis_K0; float EFSVis_p; float EFSVis_n; float EFSVis_gamma; float EFSVis_other; float EFSVis; int FSCLep_seen; int Nprotons_seen; int Nneutrons_seen; int Ncpip_seen; int Ncpim_seen; int Ncpi_seen; int Npi0_seen; int NcK_seen; int NK0_seen; int Nothers_seen; float EISLep_QE_rec; float EISLep_LepHad_rec; float EISLep_LepHadVis_rec; int Nprotons_contributed; int Nneutrons_contributed; int Ncpip_contributed; int Ncpim_contributed; int Ncpi_contributed; int Npi0_contributed; int NcK_contributed; int NK0_contributed; int Ngamma_contributed; int Nothers_contibuted; float Weight; float RWWeight; float InputWeight; float FluxWeight; float EffWeight; float PredEvtRateWeight; float xsecScaling; bool flagCCINC_true; bool flagCC0K_true; bool flagCC0Pi_true; bool flagCC1Pi_true; bool flagCCINC_rec; bool flagCC0K_rec; bool flagCC0Pi_rec; bool flagCC1Pi_rec; bool OutputSummaryTree; int SVDTruncation; TH2D *RecoSmear; TH1D *ETrueDistrib; TH1D *ETrueDistrib_noweight; TH1D *ERecDistrib; }; #endif diff --git a/src/MCStudies/T2K2017_FakeData.cxx b/src/MCStudies/T2K2017_FakeData.cxx index 6ef7186..e79aa06 100644 --- a/src/MCStudies/T2K2017_FakeData.cxx +++ b/src/MCStudies/T2K2017_FakeData.cxx @@ -1,243 +1,243 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K2017_FakeData.h" //******************************************************************** /// @brief Class to perform MC Studies on a custom measurement T2K2017_FakeData::T2K2017_FakeData(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K2017 Event Kinematics MC Study \n" \ "Target: CH/H2O \n" \ "Flux: T2K numu flux \n" \ "Signal: numuCC \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K MC #nu_{#mu} CC"); fSettings.SetDescription(descrip); fSettings.SetEnuRange(0.0, 6.0); fSettings.DefineAllowedTargets("H,C,O"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- fScaleFactor = GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.) / TotalIntegratedFlux(); // Setup some MC Histograms const int nbin_x = 14; const double binedge_x[15] = {0., 300., 400., 500., 600., 700., 800., 900., 1000., 1250., 1500., 2000., 3000., 5000., 30000.}; const int nbin_y = 10; const double binedge_y[11] = { -1, 0.6, 0.7, 0.8, 0.85, 0.9, 0.92, 0.94, 0.96, 0.98, 1.}; fMCHist_FGD1NuMuCC0Pi = new TH2D((fName + "_FGD1NuMuCC0Pi_MC").c_str(), (fName + "_FGD1NuMuCC0Pi_MC").c_str(), nbin_x, binedge_x, nbin_y, binedge_y); fMCHistPDG_FGD1NuMuCC0Pi = new TrueModeStack((fName + "_FGD1NuMuCC0Pi_MC_PDG").c_str(), (fName + "_FGD1NuMuCC0Pi_MC_PDG").c_str(), fMCHist_FGD1NuMuCC0Pi); fMCFine_FGD1NuMuCC0Pi = new TH2D((fName + "_FGD1NuMuCC0Pi_MC_FINE").c_str(), (fName + "_FGD1NuMuCC0Pi_MC_FINE").c_str(), 40, 0., 1000., 40, -1., 1.); fMCFinePDG_FGD1NuMuCC0Pi = new TrueModeStack((fName + "_FGD1NuMuCC0Pi_MC_FINE_PDG").c_str(), (fName + "_FGD1NuMuCC0Pi_MC_FINE_PDG").c_str(), fMCFine_FGD1NuMuCC0Pi); SetAutoProcessTH1(fMCHist_FGD1NuMuCC0Pi); SetAutoProcessTH1(fMCHistPDG_FGD1NuMuCC0Pi); SetAutoProcessTH1(fMCFine_FGD1NuMuCC0Pi); SetAutoProcessTH1(fMCFinePDG_FGD1NuMuCC0Pi); // Setup TTree to Save ------------------------------------------- SetEmptyData(); if (samplekey.Has("saveflattree")) { fSaveEventTree = samplekey.GetI("saveflattree") > 0; } else { fSaveEventTree = false; } if (fSaveEventTree) { fEventTree = new TTree("EventTree", "EventTree"); fEventTree->Branch("Enu", &fEnu, "Enu/D"); fEventTree->Branch("Tmu", &fTMu, "Tmu/D"); fEventTree->Branch("Cosmu", &fCosMu, "Cosmu/D"); fEventTree->Branch("Ppip", &fPPip, "Ppip/D"); fEventTree->Branch("Cospip", &fCosPip, "Cospip/D"); fEventTree->Branch("Ppim", &fPPim, "Ppim/D"); fEventTree->Branch("Cospim", &fCosPim, "Cospim/D"); fEventTree->Branch("Ppi0", &fPPi0, "Ppi0/D"); fEventTree->Branch("Cospi0", &fCosPi0, "Cospi0/D"); fEventTree->Branch("Mode", &fMode, "Mode/I"); fEventTree->Branch("NuPDG", &fNuPDG, "NuPDG/I"); fEventTree->Branch("ScaleFactor", &fScaleFactor, "ScaleFactor/D"); } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void T2K2017_FakeData::FillEventVariables(FitEvent *event) { //******************************************************************** // Reset Variables fEnu = -999.9; fTMu = -999.9; fCosMu = -999.9; fPPip = -999.9; fCosPip = -999.9; fPPim = -999.9; fCosPim = -999.9; fPPi0 = -999.9; fCosPi0 = -999.9; fMode = 0; fNuPDG = 0; // Get neutrino information if (abs(event->PDGnu()) != 14) return; FitParticle* nu = event->GetNeutrinoIn(); fEnu = nu->fP.E(); // Get Muon Information if ((event->NumFSParticle(13) + event->NumFSParticle(-13)) < 1) { return; } FitParticle* muon = NULL; if (nu->fPID == 14) { muon = event->GetHMFSParticle(13); } else if (nu->fPID == -14) { muon = event->GetHMFSParticle(-13); } fTMu = FitUtils::T(muon->fP) * 1.E3; fCosMu = cos(muon->fP.Vect().Angle(nu->fP.Vect())); // Get Pion+ Information if (event->NumFSParticle(211) >= 1) { FitParticle* pionp = event->GetHMFSParticle(211); fPPip = pionp->fP.Vect().Mag(); fCosPip = cos(pionp->fP.Vect().Angle(nu->fP.Vect())); } // Get Pion- Information if (event->NumFSParticle(-211) >= 1) { FitParticle* pionm = event->GetHMFSParticle(-211); fPPim = pionm->fP.Vect().Mag(); fCosPim = cos(pionm->fP.Vect().Angle(nu->fP.Vect())); } // Get Pion0 Information if (event->NumFSParticle(111) >= 1) { FitParticle* pion0 = event->GetHMFSParticle(111); fPPi0 = pion0->fP.Vect().Mag(); fCosPi0 = cos(pion0->fP.Vect().Angle(nu->fP.Vect())); } return; }; //******************************************************************** void T2K2017_FakeData::Write(std::string drawOpt) { //******************************************************************** if (fSaveEventTree) { fEventTree->Write(); } fMCHist_FGD1NuMuCC0Pi->Write(); fMCHistPDG_FGD1NuMuCC0Pi->Write(); fMCFine_FGD1NuMuCC0Pi->Write(); fMCFinePDG_FGD1NuMuCC0Pi->Write(); return; } // ------------------------------------------------------------------- // Purely MC Plot // Following functions are just overrides to handle this // ------------------------------------------------------------------- //******************************************************************** /// Everything is classed as signal... bool T2K2017_FakeData::isSignal(FitEvent *event) { //******************************************************************** if (abs(event->PDGnu()) != 14) return false; if ((event->NumFSParticle(13) + event->NumFSParticle(-13)) < 1) { return false; } return true; }; //******************************************************************** void T2K2017_FakeData::FillHistograms() { //******************************************************************** fMCHist_FGD1NuMuCC0Pi->Fill(fTMu, fCosMu, Weight); fMCHistPDG_FGD1NuMuCC0Pi->Fill(Mode, fTMu, fCosMu, Weight); fMCFine_FGD1NuMuCC0Pi->Fill(fTMu, fCosMu, Weight); fMCFinePDG_FGD1NuMuCC0Pi->Fill(Mode, fTMu, fCosMu, Weight); return; } //******************************************************************** void T2K2017_FakeData::ResetAll() { //******************************************************************** Measurement1D::ResetAll(); if (fSaveEventTree) { fEventTree->Reset(); } return; } //******************************************************************** float T2K2017_FakeData::GetChi2() { //******************************************************************** // No Likelihood to test, purely MC return 0.0; } diff --git a/src/MCStudies/T2K2017_FakeData.h b/src/MCStudies/T2K2017_FakeData.h index e2a2bb9..26e3771 100644 --- a/src/MCStudies/T2K2017_FakeData.h +++ b/src/MCStudies/T2K2017_FakeData.h @@ -1,92 +1,92 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K2017_FakeData_H_SEEN #define T2K2017_FakeData_H_SEEN #include "Measurement1D.h" #include "StandardStacks.h" //******************************************************************** class T2K2017_FakeData : public Measurement1D { //******************************************************************** public: T2K2017_FakeData(nuiskey samplekey); virtual ~T2K2017_FakeData() {}; //! Grab info from event void FillEventVariables(FitEvent *event); //! Fill Custom Histograms void FillHistograms(); //! ResetAll void ResetAll(); //! Scale // void ScaleEvents(); //! Norm void ApplyNormScale(float norm); //! Define this samples signal bool isSignal(FitEvent *nvect); //! Write Files void Write(std::string drawOpt); //! Get Chi2 float GetChi2(); //! Fill all signal flags we currently have void FillSignalFlags(FitEvent *event); void AddEventVariablesToTree(); void AddSignalFlagsToTree(); private: TTree* fEventTree; double fTMu; double fCosMu; double fPPip; double fCosPip; double fPPim; double fCosPim; double fPPi0; double fCosPi0; double fEnu; int fMode; int fNuPDG; bool fSaveEventTree; TH2D* fMCHist_FGD1NuMuCC0Pi; TH2D* fMCFine_FGD1NuMuCC0Pi; TrueModeStack* fMCFinePDG_FGD1NuMuCC0Pi; TrueModeStack* fMCHistPDG_FGD1NuMuCC0Pi; }; #endif diff --git a/src/MINERvA/CMakeLists.txt b/src/MINERvA/CMakeLists.txt index fb420a0..dd28a41 100644 --- a/src/MINERvA/CMakeLists.txt +++ b/src/MINERvA/CMakeLists.txt @@ -1,180 +1,180 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES MINERvA_CCQE_XSec_1DQ2_antinu.cxx MINERvA_CCQE_XSec_1DQ2_joint.cxx MINERvA_CCQE_XSec_1DQ2_nu.cxx MINERvA_CC0pi_XSec_1DEe_nue.cxx MINERvA_CC0pi_XSec_1DQ2_nue.cxx MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx MINERvA_CC0pi_XSec_1DThetae_nue.cxx MINERvA_CC0pinp_STV_XSec_1D_nu.cxx MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx MINERvA_CC1pi0_XSec_1Dth_antinu.cxx MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx MINERvA_CC1pi0_XSec_1D_nu.cxx MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx MINERvA_CC1pip_XSec_1DTpi_nu.cxx MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx MINERvA_CC1pip_XSec_1Dth_nu.cxx MINERvA_CC1pip_XSec_1D_2017Update.cxx MINERvA_CCNpip_XSec_1DEnu_nu.cxx MINERvA_CCNpip_XSec_1DQ2_nu.cxx MINERvA_CCNpip_XSec_1DTpi_nu.cxx MINERvA_CCNpip_XSec_1Dpmu_nu.cxx MINERvA_CCNpip_XSec_1Dth_nu.cxx MINERvA_CCNpip_XSec_1Dthmu_nu.cxx MINERvA_CCinc_XSec_2DEavq3_nu.cxx MINERvA_CCinc_XSec_1Dx_ratio.cxx MINERvA_CCinc_XSec_1DEnu_ratio.cxx MINERvA_CCinc_XSec_1Dx_nu.cxx MINERvA_CCinc_XSec_1DEnu_nu.cxx MINERvA_CCDIS_XSec_1Dx_ratio.cxx MINERvA_CCDIS_XSec_1DEnu_ratio.cxx MINERvA_CCDIS_XSec_1Dx_nu.cxx MINERvA_CCDIS_XSec_1DEnu_nu.cxx MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.cxx MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.cxx MINERvA_CC0pi_XSec_2D_antinu.cxx MINERvA_CC0pi_XSec_2D_nu.cxx # MINERvA_CC0pi_XSec_3DptpzTp_nu.cxx MINERvA_CC0pi_XSec_1D_2018_nu.cxx MINERvA_CCCOHPI_XSec_1DEnu_nu.cxx MINERvA_CCCOHPI_XSec_1DEpi_nu.cxx MINERvA_CCCOHPI_XSec_1Dth_nu.cxx MINERvA_CCCOHPI_XSec_1DQ2_nu.cxx MINERvA_CCCOHPI_XSec_1DEnu_antinu.cxx MINERvA_CCCOHPI_XSec_1DEpi_antinu.cxx MINERvA_CCCOHPI_XSec_1Dth_antinu.cxx MINERvA_CCCOHPI_XSec_1DQ2_antinu.cxx MINERvA_CCCOHPI_XSec_joint.cxx MINERvAUtils.cxx MINERvA_SignalDef.cxx ) set(HEADERFILES MINERvA_CCQE_XSec_1DQ2_antinu.h MINERvA_CCQE_XSec_1DQ2_joint.h MINERvA_CCQE_XSec_1DQ2_nu.h MINERvA_CC0pi_XSec_1DEe_nue.h MINERvA_CC0pi_XSec_1DQ2_nue.h MINERvA_CC0pi_XSec_1DQ2_nu_proton.h MINERvA_CC0pi_XSec_1DThetae_nue.h MINERvA_CC0pinp_STV_XSec_1D_nu.h MINERvA_CC1pi0_XSec_1DEnu_antinu.h MINERvA_CC1pi0_XSec_1DQ2_antinu.h MINERvA_CC1pi0_XSec_1Dpmu_antinu.h MINERvA_CC1pi0_XSec_1Dppi0_antinu.h MINERvA_CC1pi0_XSec_1DTpi0_antinu.h MINERvA_CC1pi0_XSec_1Dth_antinu.h MINERvA_CC1pi0_XSec_1Dthmu_antinu.h MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h MINERvA_CC1pip_XSec_1DTpi_nu.h MINERvA_CC1pip_XSec_1Dth_20deg_nu.h MINERvA_CC1pip_XSec_1Dth_nu.h MINERvA_CCNpip_XSec_1DEnu_nu.h MINERvA_CCNpip_XSec_1DQ2_nu.h MINERvA_CCNpip_XSec_1DTpi_nu.h MINERvA_CCNpip_XSec_1Dpmu_nu.h MINERvA_CCNpip_XSec_1Dth_nu.h MINERvA_CCNpip_XSec_1Dthmu_nu.h MINERvA_CCinc_XSec_2DEavq3_nu.h MINERvA_CCinc_XSec_1Dx_ratio.h MINERvA_CCinc_XSec_1DEnu_ratio.h MINERvA_CCinc_XSec_1Dx_nu.h MINERvA_CCinc_XSec_1DEnu_nu.h MINERvA_CCDIS_XSec_1Dx_ratio.h MINERvA_CCDIS_XSec_1DEnu_ratio.h MINERvA_CCDIS_XSec_1Dx_nu.h MINERvA_CCDIS_XSec_1DEnu_nu.h MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h MINERvA_CC0pi_XSec_2D_antinu.h MINERvA_CC0pi_XSec_2D_nu.h # MINERvA_CC0pi_XSec_3DptpzTp_nu.h MINERvA_CC0pi_XSec_1D_2018_nu.h MINERvA_CC1pip_XSec_1D_2017Update.h MINERvA_CCCOHPI_XSec_1DEnu_nu.h MINERvA_CCCOHPI_XSec_1DEpi_nu.h MINERvA_CCCOHPI_XSec_1Dth_nu.h MINERvA_CCCOHPI_XSec_1DQ2_nu.h MINERvA_CCCOHPI_XSec_1DEnu_antinu.h MINERvA_CCCOHPI_XSec_1DEpi_antinu.h MINERvA_CCCOHPI_XSec_1Dth_antinu.h MINERvA_CCCOHPI_XSec_1DQ2_antinu.h MINERvA_CCCOHPI_XSec_joint.h MINERvAUtils.h MINERvA_SignalDef.h MINERvAVariableBoxes.h ) set(LIBNAME expMINERvA) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/MINERvA) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MINERvA/MINERvAUtils.cxx b/src/MINERvA/MINERvAUtils.cxx index 63cf721..845d3d8 100644 --- a/src/MINERvA/MINERvAUtils.cxx +++ b/src/MINERvA/MINERvAUtils.cxx @@ -1,571 +1,571 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvAUtils.h" #include "FitUtils.h" namespace MINERvAPar { double MINERvADensity = FitPar::Config().GetParD("MINERvADensity"); double MINERvARecoDist = FitPar::Config().GetParD("MINERvARecoDist"); double PenetratingMuonE = FitPar::Config().GetParD("PenetratingMuonEnergy"); double NumRangeSteps = FitPar::Config().GetParI("NumRangeSteps"); } // namespace MINERvAPar double MINERvAUtils::StoppedEfficiency(TH2D *effHist, FitParticle *nu, FitParticle *muon) { double eff = 0.; if (!effHist) return eff; eff = effHist->GetBinContent(effHist->FindBin( FitUtils::p(muon), FitUtils::th(nu, muon) / TMath::Pi() * 180.)); return eff; } double MINERvAUtils::PenetratedEfficiency(FitParticle *nu, FitParticle *muon) { double eff = 0.; if (FitUtils::th(nu, muon) / TMath::Pi() * 180. > 50) eff = 0.; if (FitUtils::p(muon) < 1.4) eff = 0.; return eff; } double MINERvAUtils::BetheBlochCH(double E, double mass) { double beta2 = 1 - mass * mass / E / E; double gamma = 1. / sqrt(1 - beta2); double mass_ratio = PhysConst::mass_electron * 1000. / mass; // Argh, have to remember to convert to MeV or you'll hate yourself! double I2 = 68.7e-6 * 68.7e-6; // mean excitation potential I double w_max = 2 * PhysConst::mass_electron * 1000. * beta2 * gamma * gamma; w_max /= 1 + 2 * gamma * mass_ratio + mass_ratio * mass_ratio; // Values taken from the PDG for K = 0.307075 MeV mol-1 cm2, mean ionization // energy I = 68.7 eV (Polystyrene) = 0.53768 // (pdg.lbl.gov/AtomicNuclearProperties) double log_term = log(2 * PhysConst::mass_electron * 1000. * beta2 * gamma * gamma * w_max / I2); double dedx = 0.307075 * 0.53768 / beta2 * (0.5 * log_term - beta2); return dedx; } // This function returns an estimate of the range of the particle in // scintillator. It uses crude integration and Bethe-Bloch to approximate the // range. double MINERvAUtils::RangeInScintillator(FitParticle *particle, int nsteps) { // The particle energy double E = particle->fP.E(); double M = particle->fP.M(); double Ek = E - M; double step_size = Ek / float(nsteps + 1); double range = 0; // Add an offset to make the integral a touch more accurate Ek -= step_size / 2.; for (int i = 0; i < nsteps; ++i) { double dEdx = MINERvAUtils::BetheBlochCH(Ek + M, M); Ek -= step_size; // dEdx is -ve range -= step_size / dEdx; } // Account for density of polystyrene range /= MINERvAPar::MINERvADensity; // Range estimate is in cm return fabs(range); } double MINERvAUtils::GetEDepositOutsideRangeInScintillator(FitParticle *particle, double rangelimit) { // The particle energy double E = particle->fP.E(); double M = particle->fP.M(); double Ek = E - M; int nsteps = MINERvAPar::NumRangeSteps; double step_size = Ek / float(nsteps + 1); double range = 0; double Ekinside = 0.0; double Ekstart = Ek; // Add an offset to make the integral a touch more accurate Ek -= step_size / 2.; for (int i = 0; i < nsteps; ++i) { double dEdx = MINERvAUtils::BetheBlochCH(Ek + M, M); Ek -= step_size; // dEdx is -ve range -= step_size / dEdx; if (fabs(range) / MINERvAPar::MINERvADensity < rangelimit) { Ekinside = Ek; } } // Range estimate is in cm return Ekstart - Ekinside; } double MINERvAUtils::GetEDepositInsideRangeInScintillator(FitParticle *particle, double rangelimit) { // The particle energy double E = particle->fP.E(); double M = particle->fP.M(); double Ek = E - M; return Ek - GetEDepositOutsideRangeInScintillator(particle, rangelimit); } // Function to calculate the distance the particle travels in scintillator bool MINERvAUtils::PassesDistanceCut(FitParticle *beam, FitParticle *particle) { double dist = MINERvAUtils::RangeInScintillator(particle, MINERvAPar::NumRangeSteps); double zdist = dist * cos(FitUtils::th(beam, particle)); if (abs(zdist) < MINERvAPar::MINERvARecoDist) return false; return true; } // Function to return the MainTrk int MINERvAUtils::GetMainTrack(FitEvent *event, TH2D *effHist, FitParticle *&mainTrk, double &weight, bool penetrated) { FitParticle *nu = event->GetNeutrinoIn(); double highestMom = 0; int index = 0; mainTrk = NULL; // Loop over particles for (uint j = 2; j < event->Npart(); ++j) { // Final state only! if (!(event->PartInfo(j))->fIsAlive) continue; if (event->PartInfo(j)->fNEUTStatusCode != 0) continue; int PID = event->PartInfo(j)->fPID; // Only consider pions, muons for now if (abs(PID) != 211 && abs(PID) != 13) continue; // Ignore if higher momentum tracks available if (FitUtils::p(event->PartInfo(j)) < highestMom) continue; // Okay, now this is highest momentum highestMom = FitUtils::p(event->PartInfo(j)); weight *= MINERvAUtils::StoppedEfficiency(effHist, nu, event->PartInfo(j)); index = j; mainTrk = event->PartInfo(j); } // end loop over particle stack return index; } void MINERvAUtils::GetOtherTrackInfo(FitEvent *event, int mainIndex, int &nProtons, int &nPiMus, int &nVertex, FitParticle *&secondTrk) { // Reset everything nPiMus = 0; nProtons = 0; nVertex = 0; secondTrk = NULL; double highestMom = 0.; // Loop over particles for (uint j = 2; j < event->Npart(); ++j) { // Don't re-count the main track if (j == (uint)mainIndex) continue; // Final state only! if (!(event->PartInfo(j))->fIsAlive) continue; if (event->PartInfo(j)->fNEUTStatusCode != 0) continue; int PID = event->PartInfo(j)->fPID; // Only consider pions, muons, protons if (abs(PID) != 211 && PID != 2212 && abs(PID) != 13) continue; // Must be reconstructed as a track in SciBooNE if (MINERvAUtils::PassesDistanceCut(event->PartInfo(0), event->PartInfo(j))) { // Keep track of the second highest momentum track if (FitUtils::p(event->PartInfo(j)) > highestMom) { highestMom = FitUtils::p(event->PartInfo(j)); secondTrk = event->PartInfo(j); } if (PID == 2212) nProtons += 1; else nPiMus += 1; } else nVertex += 1; } // end loop over particle stack return; } // NOTE: need to adapt this to allow for penetrating events... // Simpler, but gives the same results as in Hirade-san's thesis double MINERvAUtils::CalcThetaPr(FitEvent *event, FitParticle *main, FitParticle *second, bool penetrated) { FitParticle *nu = event->GetNeutrinoIn(); if (!main || !nu || !second) return -999; // Construct the vector p_pr = (-p_mux, -p_muy, Enurec - pmucosthetamu) // where p_mux, p_muy are the projections of the candidate muon momentum onto // the x and y dimension respectively double pmu = main->fP.Vect().Mag(); double pmu_x = main->fP.Vect().X(); double pmu_y = main->fP.Vect().Y(); if (penetrated) { pmu = 1400.; double ratio = 1.4 / main->fP.Vect().Mag(); TVector3 mod_mu = main->fP.Vect() * ratio; pmu_x = mod_mu.X(); pmu_y = mod_mu.Y(); } double Enuqe = FitUtils::EnuQErec(pmu / 1000., cos(FitUtils::th(nu, main)), 27., true) * 1000.; double p_pr_z = Enuqe - pmu * cos(FitUtils::th(nu, main)); TVector3 p_pr = TVector3(-pmu_x, -pmu_y, p_pr_z); double thetapr = p_pr.Angle(second->fP.Vect()) / TMath::Pi() * 180.; return thetapr; } double MINERvAUtils::CalcThetaPi(FitEvent *event, FitParticle *second) { FitParticle *nu = event->GetNeutrinoIn(); if (!second || !nu) return -999; double thetapi = FitUtils::th(nu, second) / TMath::Pi() * 180.; return thetapi; } /// Functions to deal with the SB mode stacks MINERvAUtils::ModeStack::ModeStack(std::string name, std::string title, TH1 *hist) { fName = name; fTitle = title; AddMode(0, "Other", "Other", kGreen + 2, 2, 3244); AddMode(1, "CCDIS", "#nu_{#mu} CC DIS", kRed, 2, 3304); AddMode(2, "CCRES", "#nu_{#mu} CC Resonant", kGray + 2, 2, 1001); AddMode(3, "CCQE", "#nu_{#mu} CC QE", kMagenta, 2, 1001); AddMode(4, "CC2P2H", "#nu_{#mu} CC 2p2h", kAzure + 1, 2, 1001); StackBase::SetupStack(hist); }; int MINERvAUtils::ModeStack::ConvertModeToIndex(int mode) { switch (abs(mode)) { case 1: return 3; case 2: return 4; case 11: case 12: case 13: return 2; case 26: return 1; default: return 0; } }; void MINERvAUtils::ModeStack::Fill(int mode, double x, double y, double z, double weight) { StackBase::FillStack(MINERvAUtils::ModeStack::ConvertModeToIndex(mode), x, y, z, weight); }; void MINERvAUtils::ModeStack::Fill(FitEvent *evt, double x, double y, double z, double weight) { StackBase::FillStack(MINERvAUtils::ModeStack::ConvertModeToIndex(evt->Mode), x, y, z, weight); }; void MINERvAUtils::ModeStack::Fill(BaseFitEvt *evt, double x, double y, double z, double weight) { StackBase::FillStack(MINERvAUtils::ModeStack::ConvertModeToIndex(evt->Mode), x, y, z, weight); }; double MINERvAUtils::Get_STV_dpt_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG, bool Is0pi) { // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector Pprot = MINERvAUtils::GetProtonInRange( event, ProtonMinCut_MeV, ProtonMaxCut_MeV, ProtonCosThetaCut); // Get highest momentum proton in allowed proton range TVector3 HadronP = Pprot.Vect(); // If we don't have a CC0pi signal definition we also add in pion momentum if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } // Count up pion momentum TLorentzVector pp = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += pp.Vect(); } return FitUtils::GetDeltaPT(LeptonP, HadronP, NuP).Mag(); } double MINERvAUtils::Get_STV_dphit_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG, bool Is0pi) { // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector Pprot = MINERvAUtils::GetProtonInRange( event, ProtonMinCut_MeV, ProtonMaxCut_MeV, ProtonCosThetaCut); TVector3 HadronP = Pprot.Vect(); if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector pp = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += pp.Vect(); } return FitUtils::GetDeltaPhiT(LeptonP, HadronP, NuP); } double MINERvAUtils::Get_STV_dalphat_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG, bool Is0pi) { // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector Pprot = MINERvAUtils::GetProtonInRange( event, ProtonMinCut_MeV, ProtonMaxCut_MeV, ProtonCosThetaCut); TVector3 HadronP = Pprot.Vect(); if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector pp = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += pp.Vect(); } return FitUtils::GetDeltaAlphaT(LeptonP, HadronP, NuP); } // As defined in PhysRevC.95.065501 // Using prescription from arXiv 1805.05486 // Returns in GeV double MINERvAUtils::Get_pn_reco_C_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG, bool Is0pi) { const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) < ProtonCosThetaCut TLorentzVector Pprot = MINERvAUtils::GetProtonInRange( event, ProtonMinCut_MeV, ProtonMaxCut_MeV, ProtonCosThetaCut); TVector3 HadronP = Pprot.Vect(); double const el = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->E() / 1000.; double const eh = Pprot.E() / 1000.; if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector pp = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += pp.Vect(); } TVector3 dpt = FitUtils::GetDeltaPT(LeptonP, HadronP, NuP); double dptMag = dpt.Mag() / 1000.; double ma = 6 * mn + 6 * mp - 0.09216; // target mass (E is from PhysRevC.95.065501) double map = ma - mn + 0.02713; // remnant mass double pmul = LeptonP.Dot(NuP.Unit()) / 1000.; double phl = HadronP.Dot(NuP.Unit()) / 1000.; // double pmul = GetVectorInTPlane(LeptonP, dpt).Mag()/1000.; // double phl = GetVectorInTPlane(HadronP, dpt).Mag()/1000.; double R = ma + pmul + phl - el - eh; double dpl = 0.5 * R - (map * map + dptMag * dptMag) / (2 * R); // double dpl = ((R*R)-(dptMag*dptMag)-(map*map))/(2*R); // as in in // PhysRevC.95.065501 - gives same result double pn_reco = sqrt((dptMag * dptMag) + (dpl * dpl)); // std::cout << "Diagnostics: " << std::endl; // std::cout << "mn: " << mn << std::endl; // std::cout << "ma: " << ma << std::endl; // std::cout << "map: " << map << std::endl; // std::cout << "pmu: " << LeptonP.Mag()/1000. << std::endl; // std::cout << "ph: " << HadronP.Mag()/1000. << std::endl; // std::cout << "pmul: " << pmul << std::endl; // std::cout << "phl: " << phl << std::endl; // std::cout << "el: " << el << std::endl; // std::cout << "eh: " << eh << std::endl; // std::cout << "R: " << R << std::endl; // std::cout << "dptMag: " << dptMag << std::endl; // std::cout << "dpl: " << dpl << std::endl; // std::cout << "pn_reco: " << pn_reco << std::endl; return pn_reco; } // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector MINERvAUtils::GetProtonInRange(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut) { // Get the neutrino TLorentzVector Pnu = event->GetNeutrinoIn()->fP; int HMFSProton = -1; double HighestMomentum = 0.0; // Get the stack of protons std::vector Protons = event->GetAllFSProton(); for (size_t i = 0; i < Protons.size(); ++i) { if (Protons[i]->p() > ProtonMinCut_MeV && Protons[i]->p() < ProtonMaxCut_MeV && cos(Protons[i]->P3().Angle(Pnu.Vect())) > ProtonCosThetaCut && Protons[i]->p() > HighestMomentum) { HighestMomentum = Protons[i]->p(); HMFSProton = i; } } if (HMFSProton == -1) { return TLorentzVector(0, 0, 0, 0); } // Now get the proton TLorentzVector Pprot = Protons[HMFSProton]->fP; return Pprot; } diff --git a/src/MINERvA/MINERvAUtils.h b/src/MINERvA/MINERvAUtils.h index 5aa3b25..9fc1aa2 100644 --- a/src/MINERvA/MINERvAUtils.h +++ b/src/MINERvA/MINERvAUtils.h @@ -1,139 +1,139 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERvAUtils_H_SEEN #define MINERvAUtils_H_SEEN #include #include #include #include #include #include #include #include #include #include #include #include #include #include "FitEvent.h" #include "FitLogger.h" #include "FitParticle.h" #include "StandardStacks.h" /*! * \addtogroup Utils * @{ */ namespace MINERvAPar { extern double MINERvADensity; extern double MINERvARecoDist; extern double PenetratingMuonE; extern double NumRangeSteps; } // namespace MINERvAPar namespace MINERvAUtils { double StoppedEfficiency(TH2D *effHist, FitParticle *nu, FitParticle *muon); double PenetratedEfficiency(FitParticle *nu, FitParticle *muon); double BetheBlochCH(double beta, double mass); double RangeInScintillator(FitParticle *particle, int nsteps = 50); double GetEDepositOutsideRangeInScintillator(FitParticle *particle, double rangelimit); double GetEDepositInsideRangeInScintillator(FitParticle *particle, double rangelimit); bool PassesDistanceCut(FitParticle *beam, FitParticle *particle); int GetMainTrack(FitEvent *event, TH2D *effHist, FitParticle *&mainTrk, double &weight, bool penetrated = false); void GetOtherTrackInfo(FitEvent *event, int mainIndex, int &nProtons, int &nPiMus, int &nVertex, FitParticle *&secondTrk); double CalcThetaPr(FitEvent *event, FitParticle *main, FitParticle *second, bool penetrated = false); double CalcThetaPi(FitEvent *event, FitParticle *second); /// Gets delta p T as defined in Phys.Rev. C94 (2016) no.1, 015503 double Get_STV_dpt_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG = 14, bool Is0pi = true); /// Gets delta phi T as defined in Phys.Rev. C94 (2016) no.1, 015503 double Get_STV_dphit_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG = 14, bool Is0pi = true); /// Gets delta alpha T as defined in Phys.Rev. C94 (2016) no.1, 015503 double Get_STV_dalphat_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG = 14, bool Is0pi = true); // As defined in PhysRevC.95.065501 // Using prescription from arXiv 1805.05486 double Get_pn_reco_C_MINERvAPS(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut, int ISPDG = 14, bool Is0pi = true); // Helper for STV; get a proton from an event within some cut range (different // for T2K and MINERvA) TLorentzVector GetProtonInRange(FitEvent *event, double ProtonMinCut_MeV, double ProtonMaxCut_MeV, double ProtonCosThetaCut); /// Break down the plots as in the MINERvA CCQE Papers class ModeStack : public StackBase { public: /// Main constructor listing true mode categories. ModeStack(std::string name, std::string title, TH1 *hist); /// List to convert Modes to Index. /// Should be kept in sync with constructor. int ConvertModeToIndex(int mode); /// Fill from given mode integer void Fill(int mode, double x, double y = 1.0, double z = 1.0, double weight = 1.0); /// Extracts Mode from FitEvent and fills void Fill(FitEvent *evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); /// Extracts Mode from BaseFitEvt void Fill(BaseFitEvt *evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; /// Break down the plots in terms of 1-N pion contributions class PionStack : public StackBase { public: /// Main constructor listing true mode categories. PionStack(std::string name, std::string title, TH1 *hist); /// List to convert Pions to Index. /// Should be kept in sync with constructor. int ConvertNPionsToIndex(int npions); /// Fill from given mode integer void Fill(int npions, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; } // namespace MINERvAUtils #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx index 944672c..8e63ce7 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.cxx @@ -1,102 +1,102 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DEe_nue.h" //******************************************************************** MINERvA_CC0pi_XSec_1DEe_nue::MINERvA_CC0pi_XSec_1DEe_nue(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA CC0pi nue Ee sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{e} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{e} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA #nu_e CC0#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root;Data_1DEe" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root;Covar_1DEe" ); fSettings.DefineAllowedSpecies("nue,nueb"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromRootFile(fSettings.GetCovarInput() ); ScaleCovar(1.0 / 1000.0); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DEe_nue::FillEventVariables(FitEvent *event) { //******************************************************************** int PDGnu = event->GetNeutrinoIn()->fPID; int PDGe = 0; if (PDGnu == 12) PDGe = 11; else if (PDGnu == -12) PDGe = -11; if (event->NumFSParticle(PDGe) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pe = event->GetHMFSParticle(PDGe)->fP; Thetae = Pnu.Vect().Angle(Pe.Vect()); 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)) and !(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_1DEe_nue.h b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.h index 31ffc1f..dbe5372 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DEe_nue.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERvA_CC0pi_XSec_1DEe_nue_H_SEEN #define MINERvA_CC0pi_XSec_1DEe_nue_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CC0pi_XSec_1DEe_nue : public Measurement1D { //******************************************************************** public: MINERvA_CC0pi_XSec_1DEe_nue(nuiskey samplekey); virtual ~MINERvA_CC0pi_XSec_1DEe_nue() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double Enu_rec; double Ee, Q2QEe, Thetae; bool anty_flag; bool nue_flag; bool bad_particle; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.cxx index d37fce6..223d162 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.cxx @@ -1,149 +1,140 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu::MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu sample. \n" "Target: Target;CH (2 INPUTS)\n" "Flux: MINERvA Forward Horn Current Numu \n" "Signal: Any event with 1 muon, 1 proton p>450, no pions"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle(" d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG,FULL/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); // CCQELike plot information fSettings.SetTitle("MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu"); fIsRatio = true; nBins = 5; target = ""; if (fSettings.Found("name", "TgtRatioFe")) target = "Fe"; else if (fSettings.Found("name", "TgtRatioPb")) target = "Pb"; else if (fSettings.Found("name", "TgtRatioC")) target = "C"; else { NUIS_ABORT("target " << target << " was not found!"); } std::string basedir = FitPar::GetDataBase() + "/MINERvA/CC0pi/"; fSettings.SetDataInput(basedir + "Q2_TgtRatio_" + target + "_data.txt"); fSettings.SetCovarInput(basedir + "Q2_TgtRatio_" + target + "_covar.txt"); FinaliseSampleSettings(); // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA CC0pi ratio requires input files in format: " "NUMERATOR;DENOMINATOR"); } std::string inFileNUM = fSubInFiles.at(0); std::string inFileDEN = fSubInFiles.at(1); // Scaling Setup --------------------------------------------------- // Ratio of sub classes so non needed // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCorrelationFromTextFile(fSettings.GetCovarInput()); // Setup Experiments ------------------------------------------------------- std::string type = samplekey.GetS("type"); nuiskey samplekey_num = nuiskey("sample"); samplekey_num.Set("name", "MINERvA_CC0pi_XSec_1DQ2_Tgt" + target + "_nu"); samplekey_num.Set("input", inFileNUM); samplekey_num.Set("type", type); nuiskey samplekey_den = nuiskey("sample"); samplekey_den.Set("name", "MINERvA_CC0pi_XSec_1DQ2_TgtCH_nu"); samplekey_den.Set("input", inFileDEN); samplekey_den.Set("type", type); NUM = new MINERvA_CC0pi_XSec_1DQ2_Tgt_nu(samplekey_num); DEN = new MINERvA_CC0pi_XSec_1DQ2_Tgt_nu(samplekey_den); NUM->SetNoData(); DEN->SetNoData(); // Add to chain for processing this->fSubChain.clear(); this->fSubChain.push_back(NUM); this->fSubChain.push_back(DEN); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu::MakePlots() { //******************************************************************** UInt_t sample = 0; for (std::vector::const_iterator expIter = this->fSubChain.begin(); expIter != this->fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); if (sample == 0) this->NUM = static_cast(exp); else if (sample == 1) this->DEN = static_cast(exp); else break; sample++; } // Now make the ratio histogram - TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); - TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); - - for (int i = 0; i < nBins; ++i) { - double binVal = 0; - double binErr = 0; - - if (DEN_MC->GetBinContent(i + 1) && NUM_MC->GetBinContent(i + 1)) { - binVal = NUM_MC->GetBinContent(i + 1) / DEN_MC->GetBinContent(i + 1); - double fractErrNUM = - NUM_MC->GetBinError(i + 1) / NUM_MC->GetBinContent(i + 1); - double fractErrDEN = - DEN_MC->GetBinError(i + 1) / DEN_MC->GetBinContent(i + 1); - binErr = - binVal * sqrt(fractErrNUM * fractErrNUM + fractErrDEN * fractErrDEN); - } - - this->fMCHist->SetBinContent(i + 1, binVal); - this->fMCHist->SetBinError(i + 1, binErr); - } + TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); + TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); + this->fMCHist = PlotUtils::GetRatioPlot(NUM_MC, DEN_MC, this->fMCHist); + + // Also make fine histograms for good measure + TH1D *NUM_FINE = (TH1D*)this->NUM->GetFineList().at(0)->Clone(); + TH1D *DEN_FINE = (TH1D*)this->DEN->GetFineList().at(0)->Clone(); + this->fMCFine = PlotUtils::GetRatioPlot(NUM_FINE, DEN_FINE); + this->fMCFine ->SetNameTitle(Form("%s_MC_FINE", fSettings.GetName().c_str()), + Form("%s_MC_FINE%s", fSettings.GetName().c_str(), + fSettings.GetFullTitles().c_str())); return; } diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h index c38c5c0..55cc72c 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu.h @@ -1,58 +1,58 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu_H_SEEN #define MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h" ///\brief MINERvA CC0pi1p Target Ratio Analysis : Q2 Distribution /// ///\n [arXiv:1705.03791] ///\n Input: Target events generated with all interaction modes with flux given in Ref. /// handles multiple targets : C, CH, Fe, Pb class MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu : public JointMeas1D { public: MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu(nuiskey samplekey); virtual ~MINERvA_CC0pi_XSec_1DQ2_TgtRatio_nu() {}; void MakePlots(); // This is a dummy function as it is not required for the ratio (and does bad bad things) void ScaleEvents(){return;};; private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; // Need to have the distributions for the numerator and denominator stored separately MINERvA_CC0pi_XSec_1DQ2_Tgt_nu * NUM; MINERvA_CC0pi_XSec_1DQ2_Tgt_nu * DEN; Int_t nBins; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.cxx index af840fb..91f6a09 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.cxx @@ -1,138 +1,138 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include #include #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h" //******************************************************************** MINERvA_CC0pi_XSec_1DQ2_Tgt_nu::MINERvA_CC0pi_XSec_1DQ2_Tgt_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC0pi_XSec_1DQ2_Tgt_nu sample. \n" \ "Target: Either C, CH, Fe, Pb \n" \ "Flux: MINERvA Forward Horn numu \n" "Signal: Any event with 1 muon, 1 proton p>450, no pions"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); - fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2})"); + fSettings.SetYTitle("d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC0pi_XSec_1DQ2_Tgt_nu"); fSettings.DefineAllowedSpecies("numu"); // Set Target From name if (fSettings.Found("name","_CH")){ fTarget = 1; // kTargetCH; fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_CH_data.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_CH_covar.txt"); } else if (fSettings.Found("name","TgtC")){ fTarget = 2; //kTargetC; fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_C_data.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_C_covar.txt"); } else if (fSettings.Found("name","TgtFe")){ fTarget = 3; //kTargetFe; fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_Fe_data.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_Fe_covar.txt"); } else if (fSettings.Found("name","TgtPb")){ fTarget = 4; //kTargetPb; fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_Pb_data.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/Q2_Tgt_Pb_covar.txt"); } else { NUIS_ABORT("Target not found in name!"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); if (fTarget == 1){ SetCovarFromDiagonal(fDataHist); } else { SetCorrelationFromTextFile(fSettings.GetCovarInput() ); } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CC0pi_XSec_1DQ2_Tgt_nu::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_Tgt_nu::isSignal(FitEvent *event){ // IS NuMu + FS Muon if (!event->HasISNuMuon()) return false; if (!event->HasFSMuon()) return false; // No Pions if (!SignalDef::isCC0pi(event, 14, EnuMin, EnuMax)) return false; // Proton Threshold if (!SignalDef::HasProtonMomAboveThreshold(event, 450.0)){ return false; } return true; }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h index 4931574..21f2179 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_Tgt_nu.h @@ -1,62 +1,62 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC0pi_XSec_1DQ2_Tgt_nu_H_SEEN #define MINERVA_CC0pi_XSec_1DQ2_Tgt_nu_H_SEEN #include "Measurement1D.h" ///\brief MINERvA CC0pi1p Target Ratio Analysis : Q2 Distribution /// ///\n [arXiv:1705.03791] ///\n Input: Target events generated with all interaction modes with flux given in Ref. /// handles multiple targets : C, CH, Fe, Pb class MINERvA_CC0pi_XSec_1DQ2_Tgt_nu : public Measurement1D { public: ///\brief Setup data histograms, full covariance matrix and coplanar histogram. ///\n Available fit options: FIX/FULL,DIAG ///\n Sample is given as /nucleon. /// ///\n Valid Sample Names: ///\n 1. MINERvA_CC0pi_XSec_1DQ2_Tgt_nu - Main analysis MINERvA_CC0pi_XSec_1DQ2_Tgt_nu(nuiskey samplekey); virtual ~MINERvA_CC0pi_XSec_1DQ2_Tgt_nu() {}; ///\brief Signal is CC0pi1p /// ///\n 1. CC0pi Selection ///\n 2. Proton above 450 MeV bool isSignal(FitEvent* event); ///\brief Determine Q2 from the leading proton void FillEventVariables(FitEvent *event); ///\brief Calculate Extra Weight (Not necessary) inline double CalcSampleWeight(FitEvent* event){ return 1.0; } private: TH1D* fCoplanarMCHist; /// MC Coplanar Distribution TH1D* fCoplanarDataHist; /// Data Coplanar Distribution int fTarget; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx index 87fc775..8fc66e0 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.cxx @@ -1,106 +1,106 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include #include #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DQ2_nu_proton.h" // https://arxiv.org/abs/1409.4497 // DOI: 10.1103/PhysRevD.91.071301 //******************************************************************** MINERvA_CC0pi_XSec_1DQ2_nu_proton::MINERvA_CC0pi_XSec_1DQ2_nu_proton(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC0pi_XSec_1DQ2_nu_proton sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu \n" \ "Signal: Any event with 1 muon, at least one proton in range, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); - fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2})"); + fSettings.SetYTitle("d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC0pi_XSec_1DQ2_nu_proton"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/proton_2014/proton_Q2QE_nu_data.txt" ); // Have a shape covariance fIsShape = fSettings.Found("type","SHAPE"); std::string covid = FitPar::GetDataBase() + "/MINERvA/CC0pi/proton_2014/proton_Q2QE_nu_covar"; if (fIsShape) covid += "_shape"; covid += ".txt"; fSettings.SetCovarInput(covid); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width")*1E-38/(fNEvents+0.))/TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile(fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.h b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.h index b8e4ed7..e21d035 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nu_proton.h @@ -1,61 +1,61 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_1DQ2_nu_proton_H_SEEN #define MINERVA_1DQ2_nu_proton_H_SEEN #include "Measurement1D.h" ///\brief MINERvA CC0pi1p Analysis : Q2 Distribution /// ///\n Ref: Phys. Rev. D 91, 071301 (2015) [arXiv:1409.4497] ///\n Input: CH events generated with all interaction modes with flux given in Ref. class MINERvA_CC0pi_XSec_1DQ2_nu_proton : public Measurement1D { public: ///\brief Setup data histograms, full covariance matrix and coplanar histogram. ///\n Available fit options: FIX/FULL,DIAG ///\n Sample is given as /nucleon. /// ///\n Valid Sample Names: ///\n 1. MINERvA_CC0pi_XSec_1DQ2_nu_proton - Main analysis MINERvA_CC0pi_XSec_1DQ2_nu_proton(nuiskey samplekey); virtual ~MINERvA_CC0pi_XSec_1DQ2_nu_proton() {}; ///\brief Signal is CC0pi1p /// ///\n 1. CC0pi Selection ///\n 2. Proton above 110 MeV ///\n 3. Muon Angle < 20deg ///\n 4. 1.5 < Enu < 100.0 bool isSignal(FitEvent* event); ///\brief Determine Q2 from the leading proton void FillEventVariables(FitEvent *event); ///\brief Calculate Extra Weight (Not necessary) inline double CalcSampleWeight(FitEvent* event){ return 1.0; } private: TH1D* fCoplanarMCHist; /// MC Coplanar Distribution TH1D* fCoplanarDataHist; /// Data Coplanar Distribution }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx index 0264ddc..6ef85b7 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.cxx @@ -1,103 +1,103 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DQ2_nue.h" //******************************************************************** MINERvA_CC0pi_XSec_1DQ2_nue::MINERvA_CC0pi_XSec_1DQ2_nue(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC0pi_XSec_1DQ2_nue sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{e} (GeV)"); fSettings.SetYTitle("d#sigma/dQ^{2}_{e} (cm^{2}/GeV)^{2}"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC0pi_XSec_1DQ2_nue"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root;Data_1DQ2" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root;Covar_1DQ2" ); fSettings.DefineAllowedSpecies("nue,nueb"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromRootFile(fSettings.GetCovarInput() ); ScaleCovar(1.0 / 1000.0); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DQ2_nue::FillEventVariables(FitEvent *event){ //******************************************************************** int PDGnu = event->GetNeutrinoIn()->fPID; int PDGe = 0; if (PDGnu == 12) PDGe= 11; else if (PDGnu == -12) PDGe = -11; if (event->NumFSParticle(PDGe) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pe = event->GetHMFSParticle(PDGe)->fP; Thetae = Pnu.Vect().Angle(Pe.Vect()); Q2QEe = FitUtils::Q2QErec(Pe, cos(Thetae), 34., true); Ee = Pe.E() / 1000.0; fXVar = Q2QEe; 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)) and !(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_1DQ2_nue.h b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.h index 8e61336..a4ce2d8 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DQ2_nue.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERvA_CC0pi_XSec_1DQ2_nue_H_SEEN #define MINERvA_CC0pi_XSec_1DQ2_nue_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CC0pi_XSec_1DQ2_nue : public Measurement1D { //******************************************************************** public: MINERvA_CC0pi_XSec_1DQ2_nue(nuiskey samplekey); virtual ~MINERvA_CC0pi_XSec_1DQ2_nue() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double Enu_rec; double Ee, Q2QEe, Thetae; bool anty_flag; bool nue_flag; bool bad_particle; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx index 416273e..ec41913 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.cxx @@ -1,104 +1,104 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_1DThetae_nue.h" //******************************************************************** MINERvA_CC0pi_XSec_1DThetae_nue::MINERvA_CC0pi_XSec_1DThetae_nue(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC0pi_XSec_1DThetae_nue sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{e}"); fSettings.SetYTitle("d#sigma/d#theta_{e} (cm^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA #nu_e CC0#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root;Data_1DThetae" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CC0pi/MINERvA_CC0pi_nue_Data_ARX1509_05729.root;Covar_1DThetae" ); fSettings.DefineAllowedSpecies("nue,nueb"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromRootFile(fSettings.GetCovarInput() ); ScaleCovar(1.0 / 1000.0); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1DThetae_nue::FillEventVariables(FitEvent *event){ //******************************************************************** int PDGnu = event->GetNeutrinoIn()->fPID; int PDGe = 0; if (PDGnu == 12) PDGe= 11; else if (PDGnu == -12) PDGe = -11; if (event->NumFSParticle(PDGe) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pe = event->GetHMFSParticle(PDGe)->fP; Thetae = Pnu.Vect().Angle(Pe.Vect()); Q2QEe = FitUtils::Q2QErec(Pe, cos(Thetae), 34., true); Ee = Pe.E() / 1000.0; fXVar = Thetae * 180. / TMath::Pi(); return; } //******************************************************************** bool MINERvA_CC0pi_XSec_1DThetae_nue::isSignal(FitEvent *event){ //******************************************************************* // Check this is a nue CC0pi event if (!(SignalDef::isCC0pi(event, 12, EnuMin, EnuMax)) and !(SignalDef::isCC0pi(event, -12, EnuMin, EnuMax))) return false; // Restrict EE if (Ee < 0.5) return false; return true; }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.h b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.h index ce7cb33..eb7460a 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1DThetae_nue.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERvA_CC0pi_XSec_1DThetae_nue_H_SEEN #define MINERvA_CC0pi_XSec_1DThetae_nue_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CC0pi_XSec_1DThetae_nue : public Measurement1D { //******************************************************************** public: MINERvA_CC0pi_XSec_1DThetae_nue(nuiskey samplekey); virtual ~MINERvA_CC0pi_XSec_1DThetae_nue() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double Enu_rec; double Ee, Q2QEe, Thetae; bool anty_flag; bool nue_flag; bool bad_particle; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.cxx index 1a5ce78..92787d6 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.cxx @@ -1,235 +1,235 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /* Authors: Adrian Orea (v1 2017) Clarence Wret (v2 2018) */ #include "MINERvA_CC0pi_XSec_1D_2018_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** void MINERvA_CC0pi_XSec_1D_2018_nu::SetupDataSettings() { //******************************************************************** // Set Distribution // See header file for enum and some descriptions std::string name = fSettings.GetS("name"); // Have two distributions as of summer 2018 if (!name.compare("MINERvA_CC0pi_XSec_1Dpt_nu")) fDist = kPt; else if (!name.compare("MINERvA_CC0pi_XSec_1Dpz_nu")) fDist = kPz; else if (!name.compare("MINERvA_CC0pi_XSec_1DQ2QE_nu")) fDist = kQ2QE; else if (!name.compare("MINERvA_CC0pi_XSec_1DEnuQE_nu")) fDist = kEnuQE; // Define what files to use from the dist std::string datafile = ""; std::string corrfile = ""; std::string titles = ""; std::string distdescript = ""; std::string histname = ""; switch (fDist) { case (kPt): datafile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_ptmu_qelike.root"; corrfile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_ptmu_qelike.root"; - titles = "MINERvA CC0#pi #nu_{#mu} p_{t};p_{t} (GeV);d#sigma/dP_{t} " + titles = "MINERvA CC0#pi #nu_{#mu} p_{t};p_{t} (GeV);d#sigma/dp_{t} " "(cm^{2}/GeV/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_1Dpt_nu sample"; histname = "ptmu_cross_section"; break; case (kPz): datafile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_pzmu_qelike.root"; corrfile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_pzmu_qelike.root"; - titles = "MINERvA CC0#pi #nu_{#mu} p_{z};p_{z} (GeV);d#sigma/dP_{z} " + titles = "MINERvA CC0#pi #nu_{#mu} p_{z};p_{z} (GeV);d#sigma/dp_{z} " "(cm^{2}/GeV/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_1Dpz_nu sample"; histname = "pzmu_cross_section"; break; case (kQ2QE): datafile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_q2qe_qelike.root"; corrfile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_q2qe_qelike.root"; titles = "MINERvA CC0#pi #nu_{#mu} Q^{2}_{QE};Q^{2}_{QE} " "(GeV^{2});d#sigma/dQ^{2}_{QE} cm^{2}/GeV^{2}/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_1DQ2QE_nu sample"; histname = "q2qe_cross_section"; break; case (kEnuQE): datafile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_enuqe_qelike.root"; corrfile = "MINERvA/CC0pi_1D/FixedBinWidthPub/cov_enuqe_qelike.root"; titles = "MINERvA CC0#pi #nu_{#mu} E_{#nu}^{QE}; E_{#nu}^{QE} " "(GeV);d#sigma/dE_{#nu}^{QE} (cm^{2}/GeV/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_1DEnuQE_nu sample"; histname = "enuqe_cross_section"; break; default: NUIS_ABORT("Unknown Analysis Distribution : " << fDist); } fSettings.SetTitle(GeneralUtils::ParseToStr(titles, ";")[0]); fSettings.SetXTitle(GeneralUtils::ParseToStr(titles, ";")[1]); fSettings.SetYTitle(GeneralUtils::ParseToStr(titles, ";")[2]); // Sample overview --------------------------------------------------- std::string descrip = distdescript + "\n" "Target: CH \n" "Flux: MINERvA Low Energy FHC numu \n" "Signal: CC-0pi \n"; fSettings.SetDescription(descrip); // The input ROOT file fSettings.SetDataInput(FitPar::GetDataBase() + datafile); fSettings.SetCovarInput(FitPar::GetDataBase() + corrfile); // Set the data file SetDataFromRootFile(fSettings.GetDataInput(), histname); }; //******************************************************************** MINERvA_CC0pi_XSec_1D_2018_nu::MINERvA_CC0pi_XSec_1D_2018_nu( nuiskey samplekey) { //******************************************************************** // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); SetupDataSettings(); FinaliseSampleSettings(); // If EnuQE distribution we apply the bin by bin flux integrated scaling (so // don't divide scalefactor by integrated flux yet) if (fDist == kEnuQE) { fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)); } else { fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); } TMatrixDSym *tempmat = StatUtils::GetCovarFromRootFile( fSettings.GetCovarInput(), "TotalCovariance"); // Scale up up up! (*tempmat) *= 1E38 * 1E38; fFullCovar = tempmat; // Decomposition is stable for entries that aren't E-xxx double ScalingFactor = 1E38; (*fFullCovar) *= ScalingFactor; // Just check that the data error and covariance are the same for (int i = 0; i < fFullCovar->GetNrows(); ++i) { for (int j = 0; j < fFullCovar->GetNcols(); ++j) { // Get the global bin int xbin1, ybin1, zbin1; fDataHist->GetBinXYZ(i, xbin1, ybin1, zbin1); double xlo1 = fDataHist->GetXaxis()->GetBinLowEdge(xbin1); double xhi1 = fDataHist->GetXaxis()->GetBinLowEdge(xbin1 + 1); double ylo1 = fDataHist->GetYaxis()->GetBinLowEdge(ybin1); double yhi1 = fDataHist->GetYaxis()->GetBinLowEdge(ybin1 + 1); if (xlo1 < fDataHist->GetXaxis()->GetBinLowEdge(1) || ylo1 < fDataHist->GetYaxis()->GetBinLowEdge(1) || xhi1 > fDataHist->GetXaxis()->GetBinLowEdge( fDataHist->GetXaxis()->GetNbins() + 1) || yhi1 > fDataHist->GetYaxis()->GetBinLowEdge( fDataHist->GetYaxis()->GetNbins() + 1)) continue; double data_error = fDataHist->GetBinError(xbin1, ybin1); double cov_error = sqrt((*fFullCovar)(i, i) / ScalingFactor); if (fabs(data_error - cov_error) > 1E-5) { std::cerr << "Error on data is different to that of covariance" << std::endl; NUIS_ERR(FTL, "Data error: " << data_error); NUIS_ERR(FTL, "Cov error: " << cov_error); NUIS_ERR(FTL, "Data/Cov: " << data_error / cov_error); NUIS_ERR(FTL, "Data-Cov: " << data_error - cov_error); NUIS_ERR(FTL, "For x: " << xlo1 << "-" << xhi1); NUIS_ABORT("For y: " << ylo1 << "-" << yhi1); } } } // Now can make the inverted covariance covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); // Now scale back (*fFullCovar) *= 1.0 / ScalingFactor; (*covar) *= ScalingFactor; (*fDecomp) *= ScalingFactor; // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_1D_2018_nu::FillEventVariables(FitEvent *event) { //******************************************************************** // Checking to see if there is a Muon if (event->NumFSParticle(13) == 0) return; // Get the muon kinematics TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; // Now we set the x-axis switch (fDist) { case (kPt): { Double_t px = Pmu.X() / 1000.; Double_t py = Pmu.Y() / 1000.; Double_t pt = sqrt(px * px + py * py); fXVar = pt; break; } case (kPz): { Double_t pz = Pmu.Vect().Dot(Pnu.Vect() * (1.0 / Pnu.Vect().Mag())) / 1000.; fXVar = pz; break; } case (kQ2QE): { Double_t q2qe = FitUtils::Q2QErec(Pmu, Pnu, 34.); fXVar = q2qe; break; } case (kEnuQE): { Double_t enuqe = FitUtils::EnuQErec(Pmu, cos(Pnu.Vect().Angle(Pmu.Vect())), 34.); fXVar = enuqe; break; } default: NUIS_ABORT("DIST NOT FOUND : " << fDist); break; } return; }; //******************************************************************** bool MINERvA_CC0pi_XSec_1D_2018_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC0pi_MINERvAPTPZ(event, 14, EnuMin, EnuMax); }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.h b/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.h index 96bfbbc..cb94073 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_1D_2018_nu.h @@ -1,55 +1,55 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC0PI_XSEC_1D_NU_H_SEEN #define MINERVA_CC0PI_XSEC_1D_NU_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CC0pi_XSec_1D_2018_nu : public Measurement1D { //******************************************************************** public: // Constructor MINERvA_CC0pi_XSec_1D_2018_nu(nuiskey samplekey); // Required functions bool isSignal(FitEvent *nvect); void FillEventVariables(FitEvent *event); protected: // Set up settings based on distribution void SetupDataSettings(); private: // The distribution privates int fDist; enum Distribution { // Pt Pz kQ2QE, kEnuQE, kPt, kPz }; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.cxx index 2589ec8..4074216 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.cxx @@ -1,199 +1,199 @@ // Adrian Orea // I used the file MINERvA_CCinc_XSec_2DEavq3_nu.cxx as a template // Also, I am fully aware of the naming typo (should be ptpz), but Everything is already named the same way so... -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /* Author : Adrian Orea Clarence Wret Cleanup 2019: Data was missing Signal definition wrong (missing 120 MeV KE cut, missing pz and pt cut) Not fully implemented Assumed generator send neutrinos along z-axis */ #include "MINERvA_SignalDef.h" #include "MINERvA_CC0pi_XSec_2D_antinu.h" //******************************************************************** void MINERvA_CC0pi_XSec_2D_antinu::SetupDataSettings() { //******************************************************************** // Set Distribution // See header file for enum and some descriptions std::string name = fSettings.GetS("name"); // We're lucky to have three different MINERvA CC0pi anti-numu 2D distributions if (!name.compare("MINERvA_CC0pi_XSec_2Dptpz_antinu")) fDist = kPtPz; else if (!name.compare("MINERvA_CC0pi_XSec_2DQ2QEEnuQE_antinu")) fDist = kQ2QEEnuQE; else if (!name.compare("MINERvA_CC0pi_XSec_2DQ2QEEnuTrue_antinu")) fDist = kQ2QEEnuTrue; // Define what files to use from the dist std::string basedir = "MINERvA/CC0pi_2D_antinu/"; std::string datafile = basedir; std::string covfile = basedir; std::string titles = ""; std::string distdescript = ""; std::string histname = ""; std::string xbinning = basedir; std::string ybinning = basedir; // N.B. fScaleFactor also needs to be set dependent on the distribution. The EnuQE and EnuTrue distributions flux integrate in the Enu dimension and flux average in the Q2 dimension switch (fDist) { case (kPtPz): datafile += "cross_sections_muonpz_muonpt_lowangleqelike_minerva_2d.csv"; covfile += "cross_sections_muonpz_muonpt_lowangleqelike_minerva_covariance.csv"; xbinning += "cross_sections_muonpt_lowangleqelike_minerva_intmuonpz_bins_1d.csv"; ybinning += "cross_sections_muonpz_lowangleqelike_minerva_intmuonpt_bins_1d.csv"; titles = "MINERvA CC0#pi #bar{#nu}_{#mu} p_{t} p_{z};p_{t} (GeV);p_{z} (GeV);d^{2}#sigma/dp_{t}dp_{z} (cm^{2}/GeV^{2}/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_2Dptpz_antinu sample"; fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); break; case (kQ2QEEnuQE): datafile += "cross_sections_enuqe_qsq_lowangleqelike_minerva_2d.csv"; covfile += "cross_sections_enuqe_qsq_lowangleqelike_minerva_covariance.csv"; xbinning += "cross_sections_qsq_lowangleqelike_minerva_intenuqe_bins_1d.csv"; ybinning += "cross_sections_enuqe_lowangleqelike_minerva_intqsq_bins_1d.csv"; titles = "MINERvA CC0#pi #bar{#nu}_{#mu} Q^{2}_{QE} E^{#nu}_{QE};Q^{2}_{QE} (GeV);E^{#nu}_{QE} (GeV);d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2}/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_2DQ2QEEnuQE_antinu sample"; fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); break; case (kQ2QEEnuTrue): datafile += "cross_sections_enu_qsq_lowangleqelike_minerva_2d.csv"; covfile += "cross_sections_enu_qsq_lowangleqelike_minerva_covariance.csv"; xbinning += "cross_sections_qsq_lowangleqelike_minerva_intenuqe_bins_1d.csv"; ybinning += "cross_sections_enuqe_lowangleqelike_minerva_intqsq_bins_1d.csv"; titles = "MINERvA CC0#pi #bar{#nu}_{#mu} Q^{2}_{QE} E^{#nu}_{True};Q^{2}_{QE} (GeV);E^{#nu}_{True} (GeV);d#sigma/dQ^{2}_{QE} (cm^{2}/GeV^{2}/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_2DQ2QEEnuTrue_antinu sample"; fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); break; default: NUIS_ABORT("Unknown Analysis Distribution : " << name); } fSettings.SetTitle( GeneralUtils::ParseToStr(titles,";")[0] ); fSettings.SetXTitle( GeneralUtils::ParseToStr(titles,";")[1] ); fSettings.SetYTitle( GeneralUtils::ParseToStr(titles,";")[2] ); fSettings.SetZTitle( GeneralUtils::ParseToStr(titles,";")[3] ); // Sample overview --------------------------------------------------- std::string descrip = distdescript + "\n"\ "Target: CH \n" \ "Flux: MINERvA Low Energy RHC anti-numu \n" \ "Signal: CC-0pi \n"; fSettings.SetDescription(descrip); // The input ROOT file in the fSettings fSettings.SetDataInput(FitPar::GetDataBase() + datafile); fSettings.SetCovarInput(FitPar::GetDataBase() + covfile); // Save the binning used in the sample settings fSettings.SetS("xbins", FitPar::GetDataBase() + xbinning); fSettings.SetS("ybins", FitPar::GetDataBase() + ybinning); // Sets up the data from the data file, x binning and y binning SetDataFromTextFile(fSettings.GetDataInput(), fSettings.GetS("xbins"), fSettings.GetS("ybins")); // The data comes in units of 1E-41 fDataHist->Scale(1E-41); // Setup the covariance matrix SetCovarFromTextFile(fSettings.GetCovarInput(), fDataHist->GetNbinsX()*fDataHist->GetNbinsY()); // Set the error on the data from the covariance matrix StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, (TH2I*)NULL, 1.E-41, true); // In NUISANCE we assume the covar scale is 1E76 (or cross-section in 1E-38) // For this measurement it's actually 1E41*1E41=1E82 so need to multiply 1E82/1E76=1E6 double ScalingFactor = 1E-3*1E-3; (*fFullCovar) *= ScalingFactor; (*covar) *= 1./ScalingFactor; (*fDecomp) *= 1./ScalingFactor; }; //******************************************************************** MINERvA_CC0pi_XSec_2D_antinu::MINERvA_CC0pi_XSec_2D_antinu(nuiskey samplekey) { //******************************************************************** fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("antinumu"); // Set up the data and covariance matrix SetupDataSettings(); FinaliseSampleSettings(); FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_2D_antinu::FillEventVariables(FitEvent *event) { //******************************************************************** // Checking to see if there is a Muon if (event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; switch (fDist) { case (kPtPz): { Double_t px = Pmu.X()/1.E3; Double_t py = Pmu.Y()/1.E3; Double_t pt = sqrt(px*px+py*py); // Don't want to assume the event generators all have neutrino coming along z // pz is muon momentum projected onto the neutrino direction Double_t pz = Pmu.Vect().Dot(Pnu.Vect()*(1.0/Pnu.Vect().Mag()))/1.E3; // Set Hist Variables fYVar = pz; fXVar = pt; break; } case (kQ2QEEnuQE): { double Q2qeRec = FitUtils::Q2QErec(Pmu, Pnu, 30, false); double EnuQErec = FitUtils::EnuQErec(Pmu, Pnu, 30, false); fXVar = Q2qeRec; fYVar = EnuQErec; break; } case (kQ2QEEnuTrue): { double Q2qeRec = FitUtils::Q2QErec(Pmu, Pnu, 30, false); double EnuTrue = Pnu.E()/1.E3; fXVar = Q2qeRec; fYVar = EnuTrue; break; } } }; //******************************************************************** bool MINERvA_CC0pi_XSec_2D_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC0pi_anti_MINERvAPTPZ(event, -14, EnuMin, EnuMax); }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.h b/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.h index 6b1675f..f884ba5 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_2D_antinu.h @@ -1,55 +1,55 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC0PI_XSEC_2D_ANTINU_H_SEEN #define MINERVA_CC0PI_XSEC_2D_ANTINU_H_SEEN #include "Measurement2D.h" //******************************************************************** class MINERvA_CC0pi_XSec_2D_antinu : public Measurement2D { //******************************************************************** public: // Constructor MINERvA_CC0pi_XSec_2D_antinu(nuiskey samplekey); // Destructor virtual ~MINERvA_CC0pi_XSec_2D_antinu() {}; // Required functions bool isSignal(FitEvent *nvect); void FillEventVariables(FitEvent *event); protected: // Set up settings based on distribution void SetupDataSettings(); // The 2D distributions we have enum Distribution { kPtPz, kQ2QEEnuQE, kQ2QEEnuTrue }; Distribution fDist; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.cxx index 519685d..5b8d40c 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.cxx @@ -1,288 +1,183 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /* Authors: Adrian Orea (v1 2017) Clarence Wret (v2 2018) */ #include "MINERvA_CC0pi_XSec_2D_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** void MINERvA_CC0pi_XSec_2D_nu::SetupDataSettings() { //******************************************************************** // Define what files to use from the dist std::string datafile = ""; std::string corrfile = ""; std::string titles = ""; std::string distdescript = ""; std::string histname = ""; datafile = "MINERvA/CC0pi_2D/cov_ptpl_2D_qelike.root"; corrfile = "MINERvA/CC0pi_2D/cov_ptpl_2D_qelike.root"; titles = "MINERvA CC0#pi #nu_{#mu} p_{t} p_{z};p_{z} (GeV);p_{t} " "(GeV);d^{2}#sigma/dP_{t}dP_{z} (cm^{2}/GeV^{2}/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_2Dptpz_nu sample"; histname = "pt_pl_cross_section"; fSettings.SetTitle(GeneralUtils::ParseToStr(titles, ";")[0]); fSettings.SetXTitle(GeneralUtils::ParseToStr(titles, ";")[1]); fSettings.SetYTitle(GeneralUtils::ParseToStr(titles, ";")[2]); fSettings.SetZTitle(GeneralUtils::ParseToStr(titles, ";")[3]); // Sample overview --------------------------------------------------- std::string descrip = distdescript + "\n" "Target: CH \n" "Flux: MINERvA Low Energy FHC numu \n" "Signal: CC-0pi \n"; fSettings.SetDescription(descrip); // The input ROOT file fSettings.SetDataInput(FitPar::GetDataBase() + datafile); fSettings.SetCovarInput(FitPar::GetDataBase() + corrfile); // Set the data file SetDataValues(fSettings.GetDataInput(), histname); } //******************************************************************** MINERvA_CC0pi_XSec_2D_nu::MINERvA_CC0pi_XSec_2D_nu(nuiskey samplekey) { //******************************************************************** // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); SetupDataSettings(); FinaliseSampleSettings(); fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); TMatrixDSym *tempmat = StatUtils::GetCovarFromRootFile( fSettings.GetCovarInput(), "TotalCovariance"); fFullCovar = tempmat; // Decomposition is stable for entries that aren't E-xxx double ScalingFactor = 1E38 * 1E38; (*fFullCovar) *= ScalingFactor; // Just check that the data error and covariance are the same for (int i = 0; i < fFullCovar->GetNrows(); ++i) { for (int j = 0; j < fFullCovar->GetNcols(); ++j) { // Get the global bin int xbin1, ybin1, zbin1; fDataHist->GetBinXYZ(i, xbin1, ybin1, zbin1); double xlo1 = fDataHist->GetXaxis()->GetBinLowEdge(xbin1); double xhi1 = fDataHist->GetXaxis()->GetBinLowEdge(xbin1 + 1); double ylo1 = fDataHist->GetYaxis()->GetBinLowEdge(ybin1); double yhi1 = fDataHist->GetYaxis()->GetBinLowEdge(ybin1 + 1); if (xlo1 < fDataHist->GetXaxis()->GetBinLowEdge(1) || ylo1 < fDataHist->GetYaxis()->GetBinLowEdge(1) || xhi1 > fDataHist->GetXaxis()->GetBinLowEdge( fDataHist->GetXaxis()->GetNbins() + 1) || yhi1 > fDataHist->GetYaxis()->GetBinLowEdge( fDataHist->GetYaxis()->GetNbins() + 1)) continue; double data_error = fDataHist->GetBinError(xbin1, ybin1); double cov_error = sqrt((*fFullCovar)(i, i) / ScalingFactor); if (fabs(data_error - cov_error) > 1E-5) { std::cerr << "Error on data is different to that of covariance" << std::endl; NUIS_ERR(FTL, "Data error: " << data_error); NUIS_ERR(FTL, "Cov error: " << cov_error); NUIS_ERR(FTL, "Data/Cov: " << data_error / cov_error); NUIS_ERR(FTL, "Data-Cov: " << data_error - cov_error); NUIS_ERR(FTL, "For x: " << xlo1 << "-" << xhi1); NUIS_ABORT("For y: " << ylo1 << "-" << yhi1); } } } // Now can make the inverted covariance covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); // Now scale back (*fFullCovar) *= 1.0 / ScalingFactor; (*fDecomp) *= ScalingFactor; //Don't scale this back as GetLikelihood expects it to look like this // (*covar) *= ScalingFactor; fMapHist = new TH2I("MINERvA_CC0pi_XSec_2D_nu_maphist", "", fDataHist->GetNbinsX(), 0, fDataHist->GetNbinsX(), fDataHist->GetNbinsY(), 0, fDataHist->GetNbinsY()); int nbinsx = fDataHist->GetNbinsX(); int nbinsy = fDataHist->GetNbinsY(); Int_t Nbins = nbinsx * nbinsy; // Loop over the covariance matrix bins for (int i = 0; i < Nbins; ++i) { int xbin = (i % nbinsx) + 1; int ybin = (i / nbinsx) + 1; fMapHist->SetBinContent(xbin, ybin, i+1); } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_2D_nu::FillEventVariables(FitEvent *event) { //******************************************************************** // Checking to see if there is a Muon if (event->NumFSParticle(13) == 0) return; // Get the muon kinematics TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; Double_t px = Pmu.X() / 1000; Double_t py = Pmu.Y() / 1000; Double_t pt = sqrt(px * px + py * py); // y-axis is transverse momentum for both measurements fYVar = pt; // Don't want to assume the event generators all have neutrino coming along // z pz is muon momentum projected onto the neutrino direction Double_t pz = Pmu.Vect().Dot(Pnu.Vect() * (1.0 / Pnu.Vect().Mag())) / 1000.; // Set Hist Variables fXVar = pz; }; //******************************************************************** bool MINERvA_CC0pi_XSec_2D_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC0pi_MINERvAPTPZ(event, 14, EnuMin, EnuMax); }; -// //******************************************************************** -// // Custom likelihood calculator because binning of covariance matrix -// double MINERvA_CC0pi_XSec_2D_nu::GetLikelihood() { -// //******************************************************************** - -// return Measurement2D::GetLikelihood(); - -// // The calculated chi2 -// double chi2 = 0.0; - -// // Support shape comparisons -// double scaleF = fDataHist->Integral() / fMCHist->Integral(); -// if (fIsShape) { -// fMCHist->Scale(scaleF); -// fMCFine->Scale(scaleF); -// } - -// int nbinsx = fMCHist->GetNbinsX(); -// int nbinsy = fMCHist->GetNbinsY(); -// Int_t Nbins = nbinsx * nbinsy; - -// // Even though this chi2 calculation looks ugly it is _EXACTLY_ what MINERvA -// // used for their measurement Can be prettified in due time but for now keep - -// // Loop over the covariance matrix bins -// for (int i = 0; i < Nbins; ++i) { -// int xbin = (i % nbinsx) + 1; -// int ybin = (i / nbinsx) + 1; -// double datax = fDataHist->GetBinContent(xbin, ybin); -// double mcx = fMCHist->GetBinContent(xbin, ybin); - -// // std::cout << "CMap( " << xbin << ", " << ybin << ") = " << i -// // << ", mc = " << mcx << ", mapped(" -// // << fMapHist->GetBinContent(xbin, ybin) -// // << ") = " << Mapped_MC->GetBinContent(i) << std::endl; - -// double chi2_bin = 0; -// for (int j = 0; j < Nbins; ++j) { -// int xbin2 = (j % nbinsx) + 1; -// int ybin2 = (j / nbinsx) + 1; - -// double datay = fDataHist->GetBinContent(xbin2, ybin2); -// double mcy = fMCHist->GetBinContent(xbin2, ybin2); - -// double chi2_xy = (datax - mcx) * (*covar)(i, j) * (datay - mcy); -// chi2_bin += chi2_xy; -// } -// if (fResidualHist) { -// fResidualHist->SetBinContent(xbin, ybin, chi2_bin); -// } -// chi2 += chi2_bin; -// } - -// if (fChi2LessBinHist) { -// for (int igbin = 0; igbin < Nbins; ++igbin) { -// int igxbin = (igbin % nbinsx) + 1; -// int igybin = (igbin / nbinsx) + 1; -// double tchi2 = 0; -// for (int i = 0; i < Nbins; ++i) { -// int xbin = (i % nbinsx) + 1; -// int ybin = (i / nbinsx) + 1; -// if ((xbin == igxbin) && (ybin == igybin)) { -// continue; -// } -// double datax = fDataHist->GetBinContent(xbin, ybin); -// double mcx = fMCHist->GetBinContent(xbin, ybin); -// double chi2_bin = 0; -// for (int j = 0; j < Nbins; ++j) { -// int xbin2 = (j % nbinsx) + 1; -// int ybin2 = (j / nbinsx) + 1; -// if ((xbin2 == igxbin) && (ybin2 == igybin)) { -// continue; -// } -// double datay = fDataHist->GetBinContent(xbin2, ybin2); -// double mcy = fMCHist->GetBinContent(xbin2, ybin2); - -// double chi2_xy = (datax - mcx) * (*covar)(i, j) * (datay - mcy); -// chi2_bin += chi2_xy; -// } -// tchi2 += chi2_bin; -// } - -// fChi2LessBinHist->SetBinContent(igxbin, igybin, tchi2); -// } -// } - -// // Normalisation penalty term if included -// if (fAddNormPen) { -// chi2 += -// (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / (fNormError * fNormError); -// NUIS_LOG(REC, "Norm penalty = " << (1 - (fCurrentNorm)) * -// (1 - (fCurrentNorm)) / -// (fNormError * fNormError)); -// } - -// // Adjust the shape back to where it was. -// if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")) { -// fMCHist->Scale(1. / scaleF); -// fMCFine->Scale(1. / scaleF); -// } - -// fLikelihood = chi2; - -// return chi2; -// } diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.h b/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.h index 2219083..120fb9b 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_2D_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC0PI_XSEC_2D_NU_H_SEEN #define MINERVA_CC0PI_XSEC_2D_NU_H_SEEN #include "Measurement2D.h" //******************************************************************** class MINERvA_CC0pi_XSec_2D_nu : public Measurement2D { //******************************************************************** public: // Constructor MINERvA_CC0pi_XSec_2D_nu(nuiskey samplekey); // Destructor virtual ~MINERvA_CC0pi_XSec_2D_nu() {}; // Required functions bool isSignal(FitEvent *nvect); void FillEventVariables(FitEvent *event); protected: // Converted covariance matrix to provide global binning method in GetLikelihood // double GetLikelihood(); // Set up settings based on distribution void SetupDataSettings(); }; #endif diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.cxx b/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.cxx index 042a490..475c9bb 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.cxx +++ b/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.cxx @@ -1,255 +1,255 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ /* Authors: Clarence Wret (v2 2018) */ #include "MINERvA_CC0pi_XSec_3DptpzTp_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** void MINERvA_CC0pi_XSec_3DptpzTp_nu::SetupDataSettings() { //******************************************************************** // Define what files to use from the dist std::string datafile = ""; std::string corrfile = ""; std::string titles = ""; std::string distdescript = ""; std::string histname = ""; datafile = "MINERvA/CC0pi_3D/cov_ptpl_3DptpzTp_qelike.root"; corrfile = "MINERvA/CC0pi_3D/cov_ptpl_3DptpzTp_qelike.root"; titles = "MINERvA CC0#pi #nu_{#mu} p_{t} p_{z};p_{z} (GeV);p_{t} " "(GeV);d^{2}#sigma/dP_{t}dP_{z} (cm^{2}/GeV^{2}/nucleon)"; distdescript = "MINERvA_CC0pi_XSec_3DptpzTp_nu sample"; histname = "pt_pl_cross_section"; fSettings.SetTitle(GeneralUtils::ParseToStr(titles, ";")[0]); fSettings.SetXTitle(GeneralUtils::ParseToStr(titles, ";")[1]); fSettings.SetYTitle(GeneralUtils::ParseToStr(titles, ";")[2]); fSettings.SetZTitle(GeneralUtils::ParseToStr(titles, ";")[3]); // Sample overview --------------------------------------------------- std::string descrip = distdescript + "\n" "Target: CH \n" "Flux: MINERvA Low Energy FHC numu \n" "Signal: CC-0pi \n"; fSettings.SetDescription(descrip); // The input ROOT file //fSettings.SetDataInput(FitPar::GetDataBase() + datafile); //fSettings.SetCovarInput(FitPar::GetDataBase() + corrfile); nptbins = 7; ptbins = {0, 0.15, 0.25, 0.4, 0.7, 1, 2.5}; // GeV npzbins = 4; pzbins = {1.5, 3.5, 8, 20}; // GeV ntpbins = 15; sumTpbins = {0, 40, 80, 120, 160, 200, 240, 280, 320, 360, 400, 600, 800, 1000, 10000}; // MeV // Data is actually an array of 2D measurements // Have the 2D in pt pz and then Tp to be the left over axis //fDataHist = new TH2D("minerva_test", "minerva_test", nptbins, ptbins, npzbins, pzbins); for (int i = 0; i < ntpbins; ++i) { fDataHist_Slices.push_back(new TH2D(Form("minerva_data_test_%i", i), Form("minerva_data_test_%i", i), nptbins, ptbins, npzbins, pzbins); fMCHist_Slices.push_back(new TH2D(Form("minerva_mc_test_%i", i), Form("minerva_mc_test_%i", i), nptbins, ptbins, npzbins, pzbins); } //fDataHist->SetName((fSettings.GetName() + "_data").c_str()); //fDataHist->SetTitle(fSettings.GetFullTitles().c_str()); } //******************************************************************** MINERvA_CC0pi_XSec_3DptpzTp_nu::MINERvA_CC0pi_XSec_3DptpzTp_nu(nuiskey samplekey) { //******************************************************************** // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); SetupDataSettings(); FinaliseSampleSettings(); fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC0pi_XSec_3DptpzTp_nu::FillEventVariables(FitEvent *event) { //******************************************************************** // Checking to see if there is a Muon if (event->NumFSParticle(13) == 0) return; // Get the muon kinematics TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; Double_t px = Pmu.X() / 1000; Double_t py = Pmu.Y() / 1000; Double_t pt = sqrt(px * px + py * py); // y-axis is transverse momentum for both measurements fYVar = pt; // Don't want to assume the event generators all have neutrino coming along // z pz is muon momentum projected onto the neutrino direction Double_t pz = Pmu.Vect().Dot(Pnu.Vect() * (1.0 / Pnu.Vect().Mag())) / 1000.; // Set Hist Variables fXVar = pz; // Sum up kinetic energy of protons double sum = 0.0; for (std::vector::iterator it = event->GetAllFSProton().begin(); it != event->GetAllFSProton().end(); ++it) { sum += (*it)->KE(); } fZVar = sum; }; void MINERvA_CC0pi_XSec_3DptpzTp_nu::FillHistograms() { Measurement2D::FillHistograms(); if (Signal) { FillMCSlice(fXVar, fYVar, fZVar, Weight); } } void MINERvA_CC0pi_XSec_3DptpzTp_nu::FillMCSlice(double x, double y, double z, double w) { // Find the bin for (int i = 0; i < ntpbins; ++i) { if (z > sumTpbins[i] && z < sumTpbins[i+1]) fMCHist_Slices[i]->Fill(y, x, w); } } //******************************************************************** bool MINERvA_CC0pi_XSec_3DptpzTp_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC0pi_MINERvAPTPZ(event, 14, EnuMin, EnuMax); // From Dan // if not (2212 or 2112 or 22 and E<10) BAD BAD BAD }; //******************************************************************** // Custom likelihood calculator because binning of covariance matrix double MINERvA_CC0pi_XSec_3DptpzTp_nu::GetLikelihood() { //******************************************************************** // The calculated chi2 double chi2 = 0.0; // Support shape comparisons double scaleF = fDataHist->Integral() / fMCHist->Integral(); if (fIsShape) { fMCHist->Scale(scaleF); fMCFine->Scale(scaleF); } // Even though this chi2 calculation looks ugly it is _EXACTLY_ what MINERvA // used for their measurement Can be prettified in due time but for now keep int nbinsx = fMCHist->GetNbinsX(); int nbinsy = fMCHist->GetNbinsY(); Int_t Nbins = nbinsx * nbinsy; // Loop over the covariance matrix bins for (int i = 0; i < Nbins; ++i) { int xbin = (i % nbinsx) + 1; int ybin = (i / nbinsx) + 1; double datax = fDataHist->GetBinContent(xbin, ybin); double mcx = fMCHist->GetBinContent(xbin, ybin); double chi2_bin = 0; for (int j = 0; j < Nbins; ++j) { int xbin2 = (j % nbinsx) + 1; int ybin2 = (j / nbinsx) + 1; double datay = fDataHist->GetBinContent(xbin2, ybin2); double mcy = fMCHist->GetBinContent(xbin2, ybin2); double chi2_xy = (datax - mcx) * (*covar)(i, j) * (datay - mcy); chi2_bin += chi2_xy; } if (fResidualHist) { fResidualHist->SetBinContent(xbin, ybin, chi2_bin); } chi2 += chi2_bin; } if (fChi2LessBinHist) { for (int igbin = 0; igbin < Nbins; ++igbin) { int igxbin = (igbin % nbinsx) + 1; int igybin = (igbin / nbinsx) + 1; double tchi2 = 0; for (int i = 0; i < Nbins; ++i) { int xbin = (i % nbinsx) + 1; int ybin = (i / nbinsx) + 1; if ((xbin == igxbin) && (ybin == igybin)) { continue; } double datax = fDataHist->GetBinContent(xbin, ybin); double mcx = fMCHist->GetBinContent(xbin, ybin); double chi2_bin = 0; for (int j = 0; j < Nbins; ++j) { int xbin2 = (j % nbinsx) + 1; int ybin2 = (j / nbinsx) + 1; if ((xbin2 == igxbin) && (ybin2 == igybin)) { continue; } double datay = fDataHist->GetBinContent(xbin2, ybin2); double mcy = fMCHist->GetBinContent(xbin2, ybin2); double chi2_xy = (datax - mcx) * (*covar)(i, j) * (datay - mcy); chi2_bin += chi2_xy; } tchi2 += chi2_bin; } fChi2LessBinHist->SetBinContent(igxbin, igybin, tchi2); } } // Normalisation penalty term if included if (fAddNormPen) { chi2 += (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / (fNormError * fNormError); NUIS_LOG(REC, "Norm penalty = " << (1 - (fCurrentNorm)) * (1 - (fCurrentNorm)) / (fNormError * fNormError)); } // Adjust the shape back to where it was. if (fIsShape and !FitPar::Config().GetParB("saveshapescaling")) { fMCHist->Scale(1. / scaleF); fMCFine->Scale(1. / scaleF); } fLikelihood = chi2; return chi2; }; diff --git a/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.h b/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.h index c99a861..56020e2 100644 --- a/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.h +++ b/src/MINERvA/MINERvA_CC0pi_XSec_3DptpzTp_nu.h @@ -1,59 +1,59 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC0PI_XSEC_3DPTPZTP_NU_H_SEEN #define MINERVA_CC0PI_XSEC_3DPTPZTP_NU_H_SEEN #include "Measurement2D.h" //******************************************************************** class MINERvA_CC0pi_XSec_3DptpzTp_nu : public Measurement2D { //******************************************************************** public: // Constructor MINERvA_CC0pi_XSec_3DptpzTp_nu(nuiskey samplekey); // Destructor virtual ~MINERvA_CC0pi_XSec_3DptpzTp_nu() {}; // Required functions bool isSignal(FitEvent *nvect); void FillEventVariables(FitEvent *event); protected: // Converted covariance matrix to provide global binning method in GetLikelihood double GetLikelihood(); // Set up settings based on distribution void SetupDataSettings(); std::vector fDataHist_Slices; std::vector fMCHist_Slices; int nptbins; double *ptbins; int npzbins; double *pzbins; int ntpbins; double *sumTpbins; }; #endif diff --git a/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.cxx b/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.cxx index 25117fe..7588249 100644 --- a/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.cxx +++ b/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.cxx @@ -1,354 +1,354 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // Implementation of 2018 MINERvA numu CC0pi STV analysis // arxiv 1805.05486.pdf // Clarence Wret // cwret@fnal.gov // Stephen Dolan // Stephen.Dolan@llr.in2p3.fr #include "MINERvA_CC0pinp_STV_XSec_1D_nu.h" #include "MINERvA_SignalDef.h" #include "MINERvAUtils.h" //******************************************************************** void MINERvA_CC0pinp_STV_XSec_1D_nu::SetupDataSettings() { //******************************************************************** // Set Distribution // See header file for enum and some descriptions std::string name = fSettings.GetS("name"); if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpmu_nu")) fDist = kMuonMom; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dthmu_nu")) fDist = kMuonTh; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpprot_nu")) fDist = kPrMom; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dthprot_nu")) fDist = kPrTh; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Dpnreco_nu")) fDist = kNeMom; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Ddalphat_nu")) fDist = kDalphaT; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Ddpt_nu")) fDist = kDpT; else if (!name.compare("MINERvA_CC0pinp_STV_XSec_1Ddphit_nu")) fDist = kDphiT; // Location of data, correlation matrices and the titles std::string titles = "MINERvA_CC0pinp_STV_XSec_1D"; std::string foldername; std::string distdescript; // Data release is a single file std::string rootfile = "MINERvA_1805.05486.root"; fMin = -999; fMax = 999; switch (fDist) { case (kMuonMom): titles += "pmu"; foldername = "muonmomentum"; distdescript = "Muon momentum in lab frame"; /* fMin = 2.0; fMax = 6.0; */ fMin = 1.5; fMax = 10.0; break; case (kMuonTh): titles += "thmu"; foldername = "muontheta"; distdescript = "Muon angle relative neutrino in lab frame"; fMin = 0.0; fMax = 20.0; break; case (kPrMom): titles += "pprot"; foldername = "protonmomentum"; distdescript = "Proton momentum in lab frame"; // fMin = 0.5; fMin = 0.45; fMax = 1.2; break; case (kPrTh): titles += "thprot"; foldername = "protontheta"; distdescript = "Proton angle relative neutrino in lab frame"; fMin = 0.0; fMax = 70.0; break; case (kNeMom): titles += "pnreco"; foldername = "neutronmomentum"; distdescript = "Neutron momentum in lab frame"; fMin = 0.0; // fMax = 0.9; fMax = 2.0; break; case (kDalphaT): foldername = "dalphat"; titles += foldername; distdescript = "Delta Alpha_T"; fMin = 0.0; // fMax = 170; fMax = 180; break; case (kDpT): foldername = "dpt"; titles += foldername; distdescript = "Delta p_T"; fMin = 0.0; fMax = 2.0; break; case (kDphiT): foldername = "dphit"; titles += foldername; distdescript = "Delta phi_T"; fMin = 0.0; // fMax = 60.0; fMax = 180.0; break; default: NUIS_ERR(FTL, "Did not find your specified distribution implemented, exiting"); NUIS_ABORT("You gave " << fName); } titles += "_nu"; // All have the same name std::string dataname = foldername; // Sample overview --------------------------------------------------- std::string descrip = distdescript + "Target: CH \n" "Flux: MINERvA Forward Horn Current numu ONLY \n" "Signal: Any event with 1 muon, and 0pi0 in FS, no " "mesons, at least one proton with: \n" "1.5GeV < p_mu < 10 GeV\n" "theta_mu < 20 degrees\n" "0.45GeV < p_prot < 1.2 GeV\n" "theta_prot < 70 degrees\n" "arXiv 1805.05486"; fSettings.SetDescription(descrip); std::string filename = GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC0pi/CC0pi_STV/MINERvA_1805.05486.root"; // Specify the data fSettings.SetDataInput(filename + ";" + dataname); // And the correlations fSettings.SetCovarInput(filename + ";" + dataname); // Set titles fSettings.SetTitle(titles); }; //******************************************************************** MINERvA_CC0pinp_STV_XSec_1D_nu::MINERvA_CC0pinp_STV_XSec_1D_nu( nuiskey samplekey) { //******************************************************************** // A few different distributinos // Muon momentum, muon angle, proton momentum, proton angle, neutron momentum, // dalphat, dpt, dphit // Hard-code the cuts ProtonMinCut = 450; // MeV ProtonMaxCut = 1200; // MeV ProtonThetaCut = 70; // degrees // Setup common settings fSettings = LoadSampleSettings(samplekey); // Load up the data paths and sample descriptions SetupDataSettings(); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); // No Enu cut fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); // Finalise the settings FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / (double(fNEvents) * TotalIntegratedFlux("width")); // Set the data and covariance matrix SetDataFromRootFile(fSettings.GetDataInput()); SetCovarianceFromRootFile(fSettings.GetCovarInput()); fSettings.SetXTitle(fDataHist->GetXaxis()->GetTitle()); fSettings.SetYTitle(fDataHist->GetYaxis()->GetTitle()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** // Data comes in a TList // Some bins need stripping out because of zero bin content. Why oh why void MINERvA_CC0pinp_STV_XSec_1D_nu::SetDataFromRootFile(std::string filename) { //******************************************************************** std::vector tempfile = GeneralUtils::ParseToStr(filename, ";"); TFile *File = new TFile(tempfile[0].c_str(), "READ"); // First object is the data TH1D *temp = (TH1D *)(((TList *)(File->Get(tempfile[1].c_str())))->At(0)); // Garh, some of the data points are zero in the TH1D (WHY?!) so messes with // the covariance entries to data bins check Skim through the data and check // for zero bins std::vector CrossSection; std::vector Error; std::vector BinEdges; int lastbin = 0; startbin = 0; for (int i = 0; i < temp->GetXaxis()->GetNbins() + 2; ++i) { if (temp->GetBinContent(i + 1) > 0 && temp->GetBinLowEdge(i + 1) >= fMin && temp->GetBinLowEdge(i + 1) <= fMax) { if (startbin == 0) startbin = i; lastbin = i; CrossSection.push_back(temp->GetBinContent(i + 1)); BinEdges.push_back(temp->GetXaxis()->GetBinLowEdge(i + 1)); Error.push_back(temp->GetBinError(i + 1)); } } BinEdges.push_back(temp->GetXaxis()->GetBinLowEdge(lastbin + 2)); fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), BinEdges.size() - 1, &BinEdges[0]); fDataHist->SetDirectory(0); for (unsigned int i = 0; i < BinEdges.size() - 1; ++i) { fDataHist->SetBinContent(i + 1, CrossSection[i]); fDataHist->SetBinError(i + 1, Error[i]); } fDataHist->GetXaxis()->SetTitle(temp->GetXaxis()->GetTitle()); fDataHist->GetYaxis()->SetTitle(temp->GetYaxis()->GetTitle()); fDataHist->SetTitle(temp->GetTitle()); File->Close(); } //******************************************************************** // Covariance also needs stripping out // There's padding (two bins...) and overflow (last bin before the two empty // bins) void MINERvA_CC0pinp_STV_XSec_1D_nu::SetCovarianceFromRootFile( std::string filename) { //******************************************************************** std::vector tempfile = GeneralUtils::ParseToStr(filename, ";"); TFile *File = new TFile(tempfile[0].c_str(), "READ"); // First object is the data, second is data with statistical error only, third // is the covariance matrix TMatrixDSym *tempcov = (TMatrixDSym *)((TList *)File->Get(tempfile[1].c_str()))->At(2); // Count the number of zero entries int ngood = 0; int nstart = -1; int nend = -1; // Scan through the middle bin and look for entries int middle = tempcov->GetNrows() / 2; int nbinsdata = fDataHist->GetXaxis()->GetNbins(); for (int j = 0; j < tempcov->GetNrows(); ++j) { if ((*tempcov)(middle, j) > 0 && ngood < nbinsdata) { ngood++; if (nstart == -1) nstart = j; if (j > nend) nend = j; } } fFullCovar = new TMatrixDSym(ngood); for (int i = 0; i < fFullCovar->GetNrows(); ++i) { for (int j = 0; j < fFullCovar->GetNrows(); ++j) { (*fFullCovar)(i, j) = (*tempcov)(i + nstart + startbin - 1, j + nstart + startbin - 1); } } (*fFullCovar) *= 1E38 * 1E38; File->Close(); // Fill other covars. covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); } void MINERvA_CC0pinp_STV_XSec_1D_nu::FillEventVariables(FitEvent *event) { fXVar = -999.99; // Need a proton and a muon if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(13) == 0) { return; } TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Find the highest momentum proton in the event between 450 and 1200 MeV with // theta_p < 70 TLorentzVector Pprot = MINERvAUtils::GetProtonInRange(event, ProtonMinCut, ProtonMaxCut, cos(ProtonThetaCut/180.0*M_PI)); switch (fDist) { case (kMuonMom): fXVar = Pmu.Vect().Mag() / 1000.0; break; case (kMuonTh): fXVar = Pmu.Vect().Angle(Pnu.Vect()) * (180.0 / M_PI); break; case (kPrMom): fXVar = Pprot.Vect().Mag() / 1000.0; break; case (kPrTh): fXVar = Pprot.Vect().Angle(Pnu.Vect()) * (180.0 / M_PI); break; // Use Stephen's validated functions case (kNeMom): fXVar = MINERvAUtils::Get_pn_reco_C_MINERvAPS(event, ProtonMinCut, ProtonMaxCut, cos(ProtonThetaCut/180.0*M_PI), 14, true); break; case (kDalphaT): fXVar = MINERvAUtils::Get_STV_dalphat_MINERvAPS(event, ProtonMinCut, ProtonMaxCut, cos(ProtonThetaCut/180.0*M_PI), 14, true) * (180.0 / M_PI); break; case (kDpT): fXVar = MINERvAUtils::Get_STV_dpt_MINERvAPS(event, ProtonMinCut, ProtonMaxCut, cos(ProtonThetaCut/180.0*M_PI), 14, true) / 1000.0; break; case (kDphiT): fXVar = MINERvAUtils::Get_STV_dphit_MINERvAPS(event, ProtonMinCut, ProtonMaxCut, cos(ProtonThetaCut/180.0*M_PI), 14, true) * (180.0 / M_PI); break; } return; }; //******************************************************************** bool MINERvA_CC0pinp_STV_XSec_1D_nu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isCC0piNp_MINERvA_STV(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.h b/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.h index e769b0b..61a2143 100644 --- a/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.h +++ b/src/MINERvA/MINERvA_CC0pinp_STV_XSec_1D_nu.h @@ -1,63 +1,63 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERvA_CC0PINP_STV_XSEC_1D_NU_H_SEEN #define MINERvA_CC0PINP_STV_XSEC_1D_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC0pinp_STV_XSec_1D_nu : public Measurement1D { public: MINERvA_CC0pinp_STV_XSec_1D_nu(nuiskey samplekey); virtual ~MINERvA_CC0pinp_STV_XSec_1D_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double ProtonMinCut; double ProtonMaxCut; double ProtonThetaCut; void SetupDataSettings(); void SetDataFromRootFile(std::string); void SetCovarianceFromRootFile(std::string); enum DataDistribution { kMuonMom, kMuonTh, kPrMom, kPrTh, kNeMom, kDalphaT, kDpT, kDphiT } MINERvA_CC0pi_STV_DataDistributions; DataDistribution fDist; // For truncating double fMin; double fMax; int startbin; }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx index f5a2fa7..f481145 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.cxx @@ -1,109 +1,109 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1DEnu_antinu.h" //******************************************************************** MINERvA_CC1pi0_XSec_1DEnu_antinu::MINERvA_CC1pi0_XSec_1DEnu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1DEnu_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubar \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); - fSettings.SetYTitle("#sigma(E_{#nu} (cm^{2}/nucleon)"); + fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1DEnu_antinu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-enu.csv"); for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } SetCorrelationFromTextFile(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-enu.csv"); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CC1pi0_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double Enu = -999; if (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 other charged tracks (means no protons) // //******************************************************************** bool MINERvA_CC1pi0_XSec_1DEnu_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi0_MINERvA_2016(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.h index 9bcbb58..3495bff 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DEnu_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1DENU_NU_H_SEEN #define MINERVA_CC1PI0_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pi0_XSec_1DEnu_antinu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1DEnu_antinu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1DEnu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx index f5fc03a..6edfa52 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DQ2_antinu.cxx @@ -1,92 +1,92 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1DQ2_antinu.h" //******************************************************************** MINERvA_CC1pi0_XSec_1DQ2_antinu::MINERvA_CC1pi0_XSec_1DQ2_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1DQ2_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubar \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/(GeV^{2})/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1DQ2_antinu"); fSettings.DefineAllowedSpecies("numu"); // fFluxCorrected = fSettings.Found("name", "fluxcorr"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-q2.csv"); for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } SetCorrelationFromTextFile(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-q2.csv"); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CC1pi0_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double Q2 = -999; if (hadMass < 1800) { Q2 = -1*(Pnu-Pmu).Mag2()/1.E6; } fXVar = Q2; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1DQ2_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi0_MINERvA_2016(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx index cfab2c3..3d5b573 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.cxx @@ -1,98 +1,98 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1DTpi0_antinu.h" // The 2016 MINERvA measurement is in Tpi // The 2016 MINERvA measurement is in ppi //******************************************************************** MINERvA_CC1pi0_XSec_1DTpi0_antinu::MINERvA_CC1pi0_XSec_1DTpi0_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1DTpi0_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubar \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/dT_{#pi} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1DTpi0_antinu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-pion-kinetic-energy.csv"); for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinError(i + 1, fDataHist->GetBinContent(i + 1)*fDataHist->GetBinError(i + 1) / 100.); } SetCorrelationFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-pion-kinetic-energy.csv"); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 < 1800) Tpi0 = FitUtils::T(Ppi0); fXVar = Tpi0; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1DTpi0_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi0_MINERvA_2016(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.h index 97b1d52..7320ec3 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1DTpi0_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1DTpi0_ANTINU_H_SEEN #define MINERVA_CC1PI0_XSEC_1DTpi0_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pi0_XSec_1DTpi0_antinu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1DTpi0_antinu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1DTpi0_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.cxx index f186b4b..efee412 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.cxx @@ -1,320 +1,320 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1D_nu.h" // Implementation of 2017 MINERvA numu CC1pi0 // arxiv:1708.03723v1 hep-ex // c.wret14@imperial.ac.uk //******************************************************************** void MINERvA_CC1pi0_XSec_1D_nu::SetupDataSettings(){ //******************************************************************** // Set Distribution // See header file for enum and some descriptions std::string name = fSettings.GetS("name"); if (!name.compare("MINERvA_CC1pi0_XSec_1DTpi_nu")) fDist = kTpi; else if (!name.compare("MINERvA_CC1pi0_XSec_1Dth_nu")) fDist= kth; else if (!name.compare("MINERvA_CC1pi0_XSec_1Dpmu_nu")) fDist= kpmu; else if (!name.compare("MINERvA_CC1pi0_XSec_1Dthmu_nu")) fDist= kthmu; else if (!name.compare("MINERvA_CC1pi0_XSec_1DQ2_nu")) fDist= kQ2; else if (!name.compare("MINERvA_CC1pi0_XSec_1DEnu_nu")) fDist= kEnu; else if (!name.compare("MINERvA_CC1pi0_XSec_1DWexp_nu")) fDist= kWexp; else if (!name.compare("MINERvA_CC1pi0_XSec_1DPPi0Mass_nu")) fDist= kPPi0Mass; else if (!name.compare("MINERvA_CC1pi0_XSec_1DPPi0MassDelta_nu")) fDist= kPPi0MassDelta; else if (!name.compare("MINERvA_CC1pi0_XSec_1DCosAdler_nu")) fDist= kCosAdler; else if (!name.compare("MINERvA_CC1pi0_XSec_1DPhiAdler_nu")) fDist= kPhiAdler; // Define what files to use from the dist std::string datafile = ""; std::string corrfile = ""; std::string titles = ""; std::string distdescript = ""; // Set the default to essentially not be a cut on proton kinetic energy // The Adler angles and reconstructed p,pi0 invariant mass have cuts on these ProtonCut = 100; // W exp is 1.8 GeV or lower (dealt with below) WexpCut = 1.8; // Load up the data switch (fDist) { case (kTpi): datafile = "data/XSec_Table_pi0_KE_xsec.csv"; corrfile = "corr/Correlation_Table_pi0_KE_xsec.csv"; titles = "CC1#pi^{0};T_{#pi} (GeV);d#sigma/dT_{#pi} (cm^{2}/nucleon/GeV)"; break; case (kth): datafile = "data/XSec_Table_pi0_theta_xsec.csv"; corrfile = "corr/Correlation_Table_pi0_theta_xsec.csv"; titles = "CC1#pi^{0};#theta_{#pi} (degrees); d#sigma/d#theta_{#pi} (cm^{2}/nucleon/degree)"; break; case (kpmu): datafile = "data/XSec_Table_muon_P_xsec.csv"; corrfile = "corr/Correlation_Table_muon_P_xsec.csv"; titles = "CC1#pi^{0};p_{#mu} (GeV);d#sigma/dp_{#mu} (cm^{2}/nucleon/GeV)"; break; case (kthmu): datafile = "data/XSec_Table_muon_theta_xsec.csv"; corrfile = "corr/Correlation_Table_muon_theta_xsec.csv"; titles = "CC1#pi^{0};#theta_{#mu} (degrees);d#sigma/d#theta_{#mu} (cm^{2}/nucleon/degree)"; break; case (kQ2): datafile = "data/XSec_Table_QSq_xsec.csv"; corrfile = "corr/Correlation_Table_QSq_xsec.csv"; titles = "CC1#pi^{0};Q^{2} (GeV^{2});d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})"; break; case (kEnu): datafile = "data/XSec_Table_Enu_xsec.csv"; corrfile = "corr/Correlation_Table_Enu_xsec.csv"; - titles = "CC1#pi^{0};E_{#nu} (GeV);#sigma(E_#nu) (cm^{2}/nucleon)"; + titles = "CC1#pi^{0};E_{#nu} (GeV);#sigma(E_{#nu}) (cm^{2}/nucleon)"; break; case (kWexp): datafile = "data/XSec_Table_W_xsec.csv"; corrfile = "corr/Correlation_Table_W_xsec.csv"; titles = "CC1#pi^{0};W_{exp} (GeV);d#sigma/dW_{exp} (cm^{2}/nucleon/GeV)"; break; case (kPPi0Mass): datafile = "data/XSec_Table_deltaInvMass_xsec.csv"; corrfile = "corr/Correlation_Table_deltaInvMass_xsec.csv"; titles = "CC1#pi^{0}; M_{p#pi^{0}} (GeV); d#sigma/dM_{p#pi^{0}} (cm^{2}/nucleon/GeV)"; break; case (kPPi0MassDelta): datafile = "data/XSec_Table_deltaInvMass_xsec_DeltaRich.csv"; corrfile = "corr/Correlation_Table_deltaInvMass_xsec_DeltaRich.csv"; titles = "CC1#pi^{0}; M_{p#pi^{0}} W_{exp} < 1.4 (GeV); d#sigma/dM_{p#pi^{0}} (cm^{2}/nucleon/GeV)"; break; case (kCosAdler): datafile = "data/XSec_Table_Delta_pi_theta_xsec.csv"; corrfile = "corr/Correlation_Table_Delta_pi_theta_xsec.csv"; titles = "CC1#pi^{0}; cos#theta_{Adler}; d#sigma/dcos#theta_{Adler} (cm^{2}/nucleon/0.1)"; break; case (kPhiAdler): datafile = "data/XSec_Table_Delta_pi_phi_xsec.csv"; corrfile = "corr/Correlation_Table_Delta_pi_phi_xsec.csv"; titles = "CC1#pi^{0}; #phi_{Adler} (degrees); d#sigma/d#phi_{Adler} (cm^{2}/nucleon/degree)"; break; default: NUIS_ABORT("Unknown Analysis Distribution : " << fDist); } // Set the Wexp and proton kinetic energy cuts depending on sample // for Ppi0Mass distributions and Adler angles we require a proton of at least 100 MeV kinetic energy if (fDist >= kPPi0Mass) { ProtonCut = 0.1; // 0.1 GeV proton kinetic energy cut // Some distributions have a Wexp cut at 1.4 GeV which attempts to isolate delta production if (fDist >= kPPi0MassDelta) { WexpCut = 1.4; } } // Only have xsec covariance (not shape only) // Now setup each data distribution and description. std::string descrip = distdescript + \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu ONLY \n" \ "Signal: Any event with 1 muon with #theta_{#mu,#nu}<25#degree, and 1pi0 in FS, no mesons, any nucleon(s). W < 1.8" \ "Alt Signal: Add in requirement of 1 proton with 100 MeV and sometimes W < 1.4"; fSettings.SetDescription(descrip); // Specify the data fSettings.SetDataInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2017_nu/" + datafile); // And the correlations fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2017_nu/" + corrfile); fSettings.SetTitle( GeneralUtils::ParseToStr(titles,";")[0] ); fSettings.SetXTitle( GeneralUtils::ParseToStr(titles,";")[1] ); fSettings.SetYTitle( GeneralUtils::ParseToStr(titles,";")[2] ); return; } //******************************************************************** MINERvA_CC1pi0_XSec_1D_nu::MINERvA_CC1pi0_XSec_1D_nu(nuiskey samplekey) { //******************************************************************** // Define Sample Settings common to all data distributions fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); // From 1.5 to 20 GeV Enu fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); SetupDataSettings(); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // If Enu setup scale factor for Enu Unfolded, otherwise use differential if (fDist == kEnu) fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); else fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); // The errors come as a percent of the cross-section for this measurement so need rescaling // Have set the fDataHist above so just loop over and set new errors for (int i = 0; i < fDataHist->GetNbinsX(); ++i) { fDataHist->SetBinError(i+1, (fDataHist->GetBinError(i+1)/100.0)*fDataHist->GetBinContent(i+1)); } // And finally all the numbers are in units of 1E-40 so scale the histograms as such fDataHist->Scale(1.0E-40); // This measurement gives us a correlation matrix, so should set it up as such SetCorrelationFromTextFile( fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC1pi0_XSec_1D_nu::FillEventVariables(FitEvent *event) { //******************************************************************** fXVar = -999.9; // Need a neutral pion and a muon if (event->NumFSParticle(111) == 0 || event->NumFSParticle(13) == 0) { return; } // Get the TLorentzVectors from the event TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Pion kinetic energy double Tpi = (Ppi0.E() - Ppi0.Mag())/1.E3; // Pion-neutrino angle double th = (180./M_PI)*FitUtils::th(Pnu, Ppi0); // Muon momentum double pmu = Pmu.Vect().Mag()/1.E3; // Muon-neutrino angle double thmu = (180.0/M_PI)*FitUtils::th(Pnu, Pmu); // True Q2 double Q2 = fabs((Pmu - Pnu).Mag2()) / 1.E6; // True Enu double Enu = Pnu.E() / 1.E3; // Wexp (derived from "kinematic quantities" but uses EnuTrue) double Wexp = FitUtils::Wrec(Pnu, Pmu)/1.E3; // Wexp cut of 1.8 GeV in signal definition // N.B. the Adler angles and PPi0 mass requires this to be 1400 if (Wexp > WexpCut) return; // There's a theta mu cut of 25 degrees if (thmu > 25) return; // Some distributions require the final state proton: check that it exists if (fDist >= kPPi0Mass && event->NumFSParticle(2212) == 0) return; // Fill the variables depending on the enums switch (fDist) { case kTpi: fXVar = Tpi; break; case kth: fXVar = th; break; case kpmu: // Pmu has a theta_mu < 25degree cut fXVar = pmu; break; case kthmu: // thmu has a theta_mu < 25degree cut fXVar = thmu; break; case kQ2: fXVar = Q2; break; case kEnu: fXVar = Enu; break; case kWexp: fXVar = Wexp; break; // p, pi0 invariant mass with Wexp < 1.8 or Wexp < 1.4: already checked these above case kPPi0Mass: case kPPi0MassDelta: { // Get the proton TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; double Ppi0Mass = (Ppi0+Pprot).Mag()/1.E3; fXVar = Ppi0Mass; break; } // Cos theta Adler angle case kCosAdler: { TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; double CosThAdler = FitUtils::CosThAdler(Pnu, Pmu, Ppi0, Pprot); fXVar = CosThAdler; break; } // Phi Adler angle case kPhiAdler: { TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; double PhiAdler = FitUtils::PhiAdler(Pnu, Pmu, Ppi0, Pprot); fXVar = PhiAdler; break; } default: NUIS_ABORT("DIST NOT FOUND : " << fDist); break; } }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1D_nu::isSignal(FitEvent *event) { //******************************************************************** // Some of the distributions require a proton with at least 100 MeV KE if (fDist >= kPPi0Mass) { // First of needs a proton in the final state if (event->NumFSParticle(2212) == 0) return false; // Needs to pass CC1pi0 signal definition bool pass_cc1pi0 = SignalDef::isCC1pi0_MINERvA_nu(event, EnuMin, EnuMax); if (!pass_cc1pi0) return false; // And the proton needs at least 100 MeV kinetic energy TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; double ke = (Pprot.E() - Pprot.Mag())/1.E3; if (pass_cc1pi0 && ke > ProtonCut) { return true; } else { return false; } // The other distributions ahve a more generic "1mu, 1pi0, no mesons, any nucleon(s)" // The W cut is instead made in FillEventVariables } else { return SignalDef::isCC1pi0_MINERvA_nu(event, EnuMin, EnuMax); } } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.h index 5247d84..3ca9ea9 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1D_nu.h @@ -1,74 +1,74 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1D_NU_H_SEEN #define MINERVA_CC1PI0_XSEC_1D_NU_H_SEEN #include "Measurement1D.h" // Implementation of 2017 MINERvA numu CC1pi0 // arxiv:1708.03723v1 hep-ex // c.wret14@imperial.ac.uk class MINERvA_CC1pi0_XSec_1D_nu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1D_nu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1D_nu() {}; void SetupDataSettings(); void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: int fDist; double WexpCut; double ProtonCut; // The enums for the different distributions // P.S. the order __IS__ important: after Wexp we require a proton and impose other cuts enum DataDistribution { // Pion kinetic energy kTpi, // Pion-neutrino angle kth, // Muon momentum kpmu, // Muon-neutrino angle kthmu, // True Q2 kQ2, // True Enu kEnu, // And the interesting distributions ^_^ // Wexperimental kWexp, // p, pi0 invariant mass with Wexp < 1.8 kPPi0Mass, // p, pi0 invariant mass with Wexp < 1.4 kPPi0MassDelta, // Cos theta Adler angle kCosAdler, // Phi Adler angle kPhiAdler } CC1pi0_DataDistributions; }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx index 19dfe99..74b6e2b 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dpmu_antinu.h" //******************************************************************** MINERvA_CC1pi0_XSec_1Dpmu_antinu::MINERvA_CC1pi0_XSec_1Dpmu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1Dpmu_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubarr \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/dp_{#mu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1Dpmu_antinu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-muon-momentum.csv"); for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } SetCorrelationFromTextFile(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-muon-momentum.csv"); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CC1pi0_XSec_1Dpmu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double pmu = -999; if (hadMass < 1800) pmu = FitUtils::p(Pmu); fXVar = pmu; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dpmu_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi0_MINERvA_2016(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.h index 64c1fd4..91b9f18 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dpmu_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1DPMU_ANTINU_H_SEEN #define MINERVA_CC1PI0_XSEC_1DPMU_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pi0_XSec_1Dpmu_antinu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1Dpmu_antinu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1Dpmu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx index 90ae266..a0513f6 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.cxx @@ -1,94 +1,94 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dppi0_antinu.h" //******************************************************************** MINERvA_CC1pi0_XSec_1Dppi0_antinu::MINERvA_CC1pi0_XSec_1Dppi0_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1Dppi0_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubar \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi^{0}} (GeV/c)"); fSettings.SetYTitle("d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1Dppi0_antinu"); fSettings.DefineAllowedSpecies("numu"); fFluxCorrected = fSettings.Found("name", "fluxcorr"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2015/ccpi0_ppi0.csv"); SetCovarFromDiagonal(); if (fFluxCorrected) { // 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); } } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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; // 2015 does pion momentum in GeV double ppi0 = FitUtils::p(Ppi0); fXVar = ppi0; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dppi0_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi0_MINERvA_2015(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.h index 7091e47..2d0ee61 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dppi0_antinu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1DPPI0_ANTINU_H_SEEN #define MINERVA_CC1PI0_XSEC_1DPPI0_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pi0_XSec_1Dppi0_antinu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1Dppi0_antinu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1Dppi0_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool fUpdatedData; bool fFluxCorrected; }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx index 5d56b9d..ccd64cb 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.cxx @@ -1,132 +1,132 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dth_antinu.h" //******************************************************************** MINERvA_CC1pi0_XSec_1Dth_antinu::MINERvA_CC1pi0_XSec_1Dth_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1Dth_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubar \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (degrees)"); - fSettings.SetYTitle("d#sigma/d#theta_{#pi}) (cm^{2}/nucleon/degree)"); + fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2}/nucleon/degree)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); fUpdatedData = !fSettings.Found("name", "2015"); fFluxCorrection = fSettings.Found("name","fluxcorr"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1Dth_antinu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- if (fUpdatedData) { hadMassCut = 1800; fIsDiag = false; SetDataFromTextFile(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.); } SetCorrelationFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-pion-angle.csv"); SetShapeCovar(); } 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; SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2015/ccpi0_th.csv"); SetCovarFromDiagonal(); } // end special treatment depending on release year if (fFluxCorrection) { for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 < hadMassCut) th = (180. / M_PI) * FitUtils::th(Pnu, Ppi0); fXVar = th; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dth_antinu::isSignal(FitEvent *event) { //******************************************************************** if (fUpdatedData) { return SignalDef::isCC1pi0_MINERvA_2016(event, EnuMin, EnuMax); } else { return SignalDef::isCC1pi0_MINERvA_2015(event, EnuMin, EnuMax); } } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.h index 10b781b..5f30113 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dth_antinu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1DTH_ANTINU_H_SEEN #define MINERVA_CC1PI0_XSEC_1DTH_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pi0_XSec_1Dth_antinu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1Dth_antinu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1Dth_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double hadMassCut; bool fUpdatedData; bool fFluxCorrection; }; #endif diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx index e5d212d..0986e7c 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.cxx @@ -1,91 +1,91 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pi0_XSec_1Dthmu_antinu.h" //******************************************************************** MINERvA_CC1pi0_XSec_1Dthmu_antinu::MINERvA_CC1pi0_XSec_1Dthmu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pi0_XSec_1Dthmu_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numubar \n" \ "Signal: Any event with 1 muon, 1 pion, no other tracks \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#mu}"); fSettings.SetYTitle("d#sigma/d#theta_{#mu} (cm^{2}/degrees/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CC1pi0_XSec_1Dthmu_antinu"); fSettings.DefineAllowedSpecies("numu"); fFluxCorrected = fSettings.Found("name", "fluxcorr"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pi0/2016/anu-cc1pi0-xsec-muon-angle.csv"); for (int i = 0; i < fDataHist->GetNbinsX()+1; i++) { fDataHist->SetBinError(i+1, fDataHist->GetBinContent(i+1)*fDataHist->GetBinError(i+1)/100.); } SetCorrelationFromTextFile(GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pi0/2016/anu-cc1pi0-correlation-muon-angle.csv"); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CC1pi0_XSec_1Dthmu_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double hadMass = FitUtils::Wrec(Pnu, Pmu); double thmu = -999; if (hadMass < 1800) thmu = (180./M_PI)*FitUtils::th(Pnu, Pmu); fXVar = thmu; return; }; //******************************************************************** bool MINERvA_CC1pi0_XSec_1Dthmu_antinu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi0_MINERvA_2016(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.h b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.h index e1bc2f4..41755da 100644 --- a/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.h +++ b/src/MINERvA/MINERvA_CC1pi0_XSec_1Dthmu_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PI0_XSEC_1DTHMU_ANTINU_H_SEEN #define MINERVA_CC1PI0_XSEC_1DTHMU_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pi0_XSec_1Dthmu_antinu : public Measurement1D { public: MINERvA_CC1pi0_XSec_1Dthmu_antinu(nuiskey samplekey); virtual ~MINERvA_CC1pi0_XSec_1Dthmu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); bool fFluxCorrected; private: }; #endif diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.cxx index 05cceaf..3808062 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 +// Copyright 2016-2021 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 . *******************************************************************************/ #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 = 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_20deg_nu.h b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h index 8a515c8..361c97c 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_20deg_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PIP_XSEC_1DTPI_20DEG_NU_H_SEEN #define MINERVA_CC1PIP_XSEC_1DTPI_20DEG_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pip_XSec_1DTpi_20deg_nu : public Measurement1D { public: MINERvA_CC1pip_XSec_1DTpi_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~MINERvA_CC1pip_XSec_1DTpi_20deg_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx index 1a581e0..b9c4d0f 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.cxx @@ -1,112 +1,112 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1DTpi_nu.h" //******************************************************************** MINERvA_CC1pip_XSec_1DTpi_nu::MINERvA_CC1pip_XSec_1DTpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pip_XSec_1DTpi_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#pi} (MeV)"); fSettings.SetYTitle("d#sigma/dT_{#pi} (cm^{2}/MeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fFullPhaseSpace = !fSettings.Found("name", "_20deg"); fFluxCorrection = fSettings.Found("name","fluxcorr"); fSettings.SetTitle("MINERvA_CC1pip_XSec_1DTpi_nu"); fIsShape = fSettings.Found("type","shape"); if (fFullPhaseSpace) { if (fIsShape) { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_shape.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_cov_shape.csv"); } else { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_cov.csv"); } } else { if (fIsShape) { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_20_shape.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_20_cov_shape.csv"); } else { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_20.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CC1pip/ccpip_Tpi_20_cov.csv"); } } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); // Scale the MINERvA data to account for the flux difference if (fFluxCorrection) { for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 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_1DTpi_nu.h b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.h index 1583ab1..97703ed 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.h +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1DTpi_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PIP_XSEC_1DTPI_NU_H_SEEN #define MINERVA_CC1PIP_XSEC_1DTPI_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pip_XSec_1DTpi_nu : public Measurement1D { public: MINERvA_CC1pip_XSec_1DTpi_nu(nuiskey samplekey); virtual ~MINERvA_CC1pip_XSec_1DTpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); bool fFullPhaseSpace; bool fFluxCorrection; private: }; #endif diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.cxx index 63dbdbb..25c3ecc 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.cxx @@ -1,168 +1,168 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1D_2017Update.h" //******************************************************************** void MINERvA_CC1pip_XSec_1D_2017Update::SetupDataSettings(){ //******************************************************************** // Set Distribution std::string name = fSettings.GetS("name"); if (!name.compare("MINERvA_CC1pip_XSec_1DTpi_nu_2017")) fDist = kTpi; else if (!name.compare("MINERvA_CC1pip_XSec_1Dth_nu_2017")) fDist= kth; else if (!name.compare("MINERvA_CC1pip_XSec_1Dpmu_nu_2017")) fDist= kpmu; else if (!name.compare("MINERvA_CC1pip_XSec_1Dthmu_nu_2017")) fDist= kthmu; else if (!name.compare("MINERvA_CC1pip_XSec_1DQ2_nu_2017")) fDist= kQ2; else if (!name.compare("MINERvA_CC1pip_XSec_1DEnu_nu_2017")) fDist= kEnu; // Define what files to use from the dist std::string datafile = ""; std::string covarfile = ""; std::string titles = ""; std::string distdescript = ""; switch(fDist){ case (kTpi): datafile = "cc1pip_updated_1DTpi"; covarfile = "cc1pip_updated_1DTpi"; titles = "CC1#pi Updated;T_{#pi} (MeV);d#sigma/dT_{#pi} (cm^{2}/nucleon/MeV)"; break; case (kth): datafile = "cc1pip_updated_1Dth"; covarfile = "cc1pip_updated_1Dth"; titles = "CC1#pi Updated;#theta_{#pi};d#sigma/d#theta_{#pi} (cm^{2}/nucleon)"; break; case (kpmu): datafile = "cc1pip_updated_1Dpmu"; covarfile = "cc1pip_updated_1Dpmu"; titles = "CC1#pi Updated;p_{#mu} (GeV);d#sigma/dp_{#mu} (cm^{2}/nucleon/GeV)"; break; case (kthmu): datafile = "cc1pip_updated_1Dthmu"; covarfile = "cc1pip_updated_1Dthmu"; titles ="CC1#pi Updated;#theta_{#mu};d#sigma/d#theta_{#mu} (cm^{2}/nucleon)"; break; case (kQ2): datafile = "cc1pip_updated_1DQ2"; covarfile = "cc1pip_updated_1DQ2"; titles ="CC1#pi Updated;Q^{2} (GeV^{2});d#sigma/dQ^{2} (cm^{2}/nucleon/GeV^{2})"; break; case (kEnu): datafile = "cc1pip_updated_1DEnu"; covarfile = "cc1pip_updated_1DEnu"; - titles ="CC1#pi Updated;E_{#nu} (GeV);#sigma(E_#nu) (cm^{2}/nucleon)"; + titles ="CC1#pi Updated;E_{#nu} (GeV);#sigma(E_{#nu}) (cm^{2}/nucleon)"; break; default: NUIS_ABORT("Unknown Analysis Distribution : " << fDist); } // Choose shape or rate covariance fIsShape = fSettings.Found("type","SHAPE"); std::string covid = fIsShape ? "_shapecov.txt" : "_ratecov.txt"; // Now setup each data distribution and description. std::string descrip = distdescript + \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu ONLY \n" \ "Signal: Any event with 1 muon, and 1pi+ or 1pi- in FS. W < 1.8"; fSettings.SetDescription(descrip); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/070717/" + datafile + "_data.txt" ); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/070717/" + covarfile + covid ); fSettings.SetTitle( GeneralUtils::ParseToStr(titles,";")[0] ); fSettings.SetXTitle( GeneralUtils::ParseToStr(titles,";")[1] ); fSettings.SetYTitle( GeneralUtils::ParseToStr(titles,";")[2] ); return; } //******************************************************************** MINERvA_CC1pip_XSec_1D_2017Update::MINERvA_CC1pip_XSec_1D_2017Update(nuiskey samplekey) { //******************************************************************** // Define Sample Settings common to all data distributions fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); SetupDataSettings(); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // If Enu setup scale factor for Enu Unfolded, otherwise use differential if (fDist == kEnu) fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); else fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CC1pip_XSec_1D_2017Update::FillEventVariables(FitEvent *event) { //******************************************************************** fXVar = -999.9; 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 Tpi = Ppip.E() - Ppip.Mag(); double th = (180./M_PI)*FitUtils::th(Pnu, Ppip); double pmu = Pmu.Vect().Mag()/1.E3; // GeV double thmu = (180.0/M_PI)*FitUtils::th(Pnu, Pmu); double Q2 = fabs((Pmu - Pnu).Mag2()) / 1.E6; // Using true here? double Enu = Pnu.E() / 1.E3; switch(fDist){ case kTpi: fXVar = Tpi; break; case kth: fXVar = th; break; case kpmu: fXVar = pmu; break; case kthmu: fXVar = thmu; break; case kQ2: fXVar = Q2; break; case kEnu: fXVar = Enu; break; default: NUIS_ABORT("DIST NOT FOUND : " << fDist); } }; //******************************************************************** bool MINERvA_CC1pip_XSec_1D_2017Update::isSignal(FitEvent *event) { //******************************************************************** // Only seem to release full phase space return SignalDef::isCC1pip_MINERvA_2017(event, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.h b/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.h index 2b45e56..26e8339 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.h +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1D_2017Update.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PIP_XSEC_1D_2017UPDATE_NU_H_SEEN #define MINERVA_CC1PIP_XSEC_1D_2017UPDATE_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pip_XSec_1D_2017Update : public Measurement1D { public: MINERvA_CC1pip_XSec_1D_2017Update(nuiskey samplekey); virtual ~MINERvA_CC1pip_XSec_1D_2017Update() {}; void SetupDataSettings(); void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: int fDist; enum DataDistribution { kTpi, kth, kpmu, kthmu, kQ2, kEnu } CC1pip_DataDistributions; }; #endif diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.cxx index d6894f2..f74d1a3 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 +// Copyright 2016-2021 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 . *******************************************************************************/ #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 = 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_20deg_nu.h b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.h index 5517008..bc97790 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.h +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_20deg_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PIP_XSEC_1DTH_20DEG_NU_H_SEEN #define MINERVA_CC1PIP_XSEC_1DTH_20DEG_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pip_XSec_1Dth_20deg_nu : public Measurement1D { public: MINERvA_CC1pip_XSec_1Dth_20deg_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile); virtual ~MINERvA_CC1pip_XSec_1Dth_20deg_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void Write(std::string drawOpt); private: double hadMass; TH1D *hadMassHist; }; #endif diff --git a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx index a9cb690..b9562f1 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.cxx @@ -1,113 +1,113 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CC1pip_XSec_1Dth_nu.h" //******************************************************************** MINERvA_CC1pip_XSec_1Dth_nu::MINERvA_CC1pip_XSec_1Dth_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CC1pip_XSec_1Dth_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (degrees)"); fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2}/degrees/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fFullPhaseSpace = !fSettings.Found("name", "_20deg"); fFluxCorrection = fSettings.Found("name","fluxcorr"); fSettings.SetTitle("MINERvA_CC1pip_XSec_1Dth_nu"); fIsShape = fSettings.Found("type","shape"); if (fFullPhaseSpace){ if (fIsShape) { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_shape.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_cov_shape.csv"); } else { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_cov.csv"); } // Restricted Phase Space } else { if (fIsShape) { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_shape.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_cov_shape.csv"); } else { fSettings.SetDataInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir()+"/data/MINERvA/CC1pip/ccpip_theta_20_cov.csv"); } } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); // Scale the MINERvA data to account for the flux difference if (fFluxCorrection) { for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 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_CC1pip_XSec_1Dth_nu.h b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.h index c669c77..3d0ef3b 100644 --- a/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.h +++ b/src/MINERvA/MINERvA_CC1pip_XSec_1Dth_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CC1PIP_XSEC_1DTH_NU_H_SEEN #define MINERVA_CC1PIP_XSEC_1DTH_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CC1pip_XSec_1Dth_nu : public Measurement1D { public: MINERvA_CC1pip_XSec_1Dth_nu(nuiskey samplekey); virtual ~MINERvA_CC1pip_XSec_1Dth_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); bool fFullPhaseSpace; bool fFluxCorrection; private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.cxx index d31528d..11ab084 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.cxx @@ -1,77 +1,77 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1DEnu_antinu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1DEnu_antinu::MINERvA_CCCOHPI_XSec_1DEnu_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1DEnu_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Reverse Horn Current numu \n" \ "Signal: Any event with 1 mu+, 1pi-, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#nu} (cm^{2}/GeV/C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1DEnu_antinu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Enu_nubar_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Enu_nubar_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1DEnu_antinu::FillEventVariables(FitEvent *event) { fXVar = event->GetNeutrinoIn()->fP.E()/1000.; return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1DEnu_antinu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, -14, -211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.h index d7e5d81..12205a0 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DENU_ANTINU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DENU_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1DEnu_antinu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1DEnu_antinu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1DEnu_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.cxx index 4165ef6..a093f39 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.cxx @@ -1,76 +1,76 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1DEnu_nu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1DEnu_nu::MINERvA_CCCOHPI_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1DEnu_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu \n" \ "Signal: Any event with 1 mu-, 1pi+, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#nu} (cm^{2}/GeV/C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1DEnu_nu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Enu_nu_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Enu_nu_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { fXVar = event->GetNeutrinoIn()->fP.E()/1000.; return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1DEnu_nu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.h index 8619992..32b1d68 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEnu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DENU_NU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1DEnu_nu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1DEnu_nu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.cxx index bae166a..7ef294c 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.cxx @@ -1,81 +1,81 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_antinu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1DEpi_antinu::MINERvA_CCCOHPI_XSec_1DEpi_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1DEpi_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Reverse Horn Current numu \n" \ "Signal: Any event with 1 mu+, 1pi-, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#pi} (cm^{2}/GeV/C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1DEpi_antinu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Epi_nubar_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Epi_nubar_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)/TotalIntegratedFlux("width")*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1DEpi_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-211) == 0) return; TLorentzVector Ppi = event->GetHMFSParticle(-211)->fP; fXVar = Ppi.E()/1000.; return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1DEpi_antinu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, -14, -211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.h index 6f45792..cc8c0f4 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DEPI_ANTINU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DEPI_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1DEpi_antinu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1DEpi_antinu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1DEpi_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.cxx index 575659b..a649912 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.cxx @@ -1,81 +1,81 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_nu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1DEpi_nu::MINERvA_CCCOHPI_XSec_1DEpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1DEpi_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu \n" \ "Signal: Any event with 1 mu-, 1pi+, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#pi} (cm^{2}/GeV/C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1DEpi_nu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Epi_nu_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Epi_nu_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)/TotalIntegratedFlux("width")*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); std::cout << "MINERvA_CCCOHPI_XSec_1DEpi_nu.cxx : Data Integral = " << fDataHist->Integral() << std::endl; }; void MINERvA_CCCOHPI_XSec_1DEpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0) return; TLorentzVector Ppi = event->GetHMFSParticle(211)->fP; fXVar = Ppi.E()/1000.; return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1DEpi_nu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.h index 53045e4..2592939 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DEpi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DEPI_NU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DEPI_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1DEpi_nu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1DEpi_nu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1DEpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.cxx index 0cc2838..6e8164a 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.cxx @@ -1,84 +1,84 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_antinu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1DQ2_antinu::MINERvA_CCCOHPI_XSec_1DQ2_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1DQ2_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Reverse Horn Current numu \n" \ "Signal: Any event with 1 mu+, 1pi-, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#pi} (cm^{2}/GeV/C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1DQ2_antinu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Q2_nubar_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Q2_nubar_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)/TotalIntegratedFlux("width")*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1DQ2_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-211) == 0 || event->NumISParticle(-14) == 0 || event->NumFSParticle(-13) == 0) return; TLorentzVector Ppi = event->GetHMFSParticle(-211)->fP; TLorentzVector Pnu = event->GetHMISParticle(-14)->fP; TLorentzVector Pmu = event->GetHMFSParticle(-13)->fP; double Q2 = (Pmu - Pnu).Mag2()/1.E6; fXVar = Q2; return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1DQ2_antinu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, -14, -211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.h index dde6ce6..8a4fdab 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DQ2_ANTINU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DQ2_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1DQ2_antinu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1DQ2_antinu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1DQ2_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.cxx index fad6408..1dc9016 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.cxx @@ -1,82 +1,82 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_nu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1DQ2_nu::MINERvA_CCCOHPI_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1DQ2_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu \n" \ "Signal: Any event with 1 mu-, 1pi+, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#pi} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#pi} (cm^{2}/GeV/C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1DQ2_nu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Q2_nu_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Q2_nu_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)/TotalIntegratedFlux("width")*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0 || event->NumISParticle(14) == 0 || event->NumFSParticle(13) == 0) return; TLorentzVector Ppi = event->GetHMFSParticle(211)->fP; TLorentzVector Pnu = event->GetHMISParticle(14)->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Q2 = (Pmu - Pnu).Mag2()/1.E6; fXVar = Q2; return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1DQ2_nu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.h index d22b181..38186f0 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1DQ2_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DQ2_NU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1DQ2_nu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1DQ2_nu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.cxx index 774c621..0463753 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.cxx @@ -1,82 +1,82 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1Dth_antinu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1Dth_antinu::MINERvA_CCCOHPI_XSec_1Dth_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1Dth_antinu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Reverse Horn Current numu \n" \ "Signal: Any event with 1 mu+, 1pi-, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (deg.)"); fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2}/deg./C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numub"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1Dth_antinu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Thpi_nubar_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Thpi_nubar_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)/TotalIntegratedFlux("width")*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1Dth_antinu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(-211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi = event->GetHMFSParticle(-211)->fP; fXVar = (180. / M_PI) * FitUtils::th(Pnu, Ppi); return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1Dth_antinu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numub + 12C --> mu+ + pi- + 12C' return SignalDef::isCCCOH(event, -14, -211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.h index 8626bb8..999fabd 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_antinu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DTH_ANTINU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DTH_ANTINU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1Dth_antinu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1Dth_antinu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1Dth_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.cxx index 3219b80..f25feb9 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.cxx @@ -1,82 +1,82 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCCOHPI_XSec_1Dth_nu.h" //******************************************************************** MINERvA_CCCOHPI_XSec_1Dth_nu::MINERvA_CCCOHPI_XSec_1Dth_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCCOHPI_XSec_1Dth_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current numu \n" \ "Signal: Any event with 1 mu-, 1pi+, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (deg.)"); fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2}/deg./C^{12})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCCOHPI_XSec_1Dth_nu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Thpi_nu_data.csv"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/Thpi_nu_cov.csv"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents)/TotalIntegratedFlux("width")*13; // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MINERvA_CCCOHPI_XSec_1Dth_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi = event->GetHMFSParticle(211)->fP; fXVar = (180. / M_PI) * FitUtils::th(Pnu, Ppi); return; }; //******************************************************************** bool MINERvA_CCCOHPI_XSec_1Dth_nu::isSignal(FitEvent *event) { //******************************************************************** // Signal: numu + 12C --> mu- + pi+ + 12C' return SignalDef::isCCCOH(event, 14, 211, EnuMin, EnuMax); } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.h index f0e7e4e..747d166 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_1Dth_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSEC_1DTH_NU_H_SEEN #define MINERVA_CCCOHPI_XSEC_1DTH_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCCOHPI_XSec_1Dth_nu : public Measurement1D { public: MINERvA_CCCOHPI_XSec_1Dth_nu(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_1Dth_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.cxx b/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.cxx index 23e3191..c2a70b7 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.cxx +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.cxx @@ -1,210 +1,210 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCCOHPI_XSec_joint.h" #include "MINERvA_CCCOHPI_XSec_1DEnu_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DEnu_nu.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_nu.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_nu.h" #include "MINERvA_CCCOHPI_XSec_1Dth_antinu.h" #include "MINERvA_CCCOHPI_XSec_1Dth_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** void MINERvA_CCCOHPI_XSec_joint::SetupDataSettings() { //******************************************************************** // Set Distribution std::string name = fSettings.GetS("name"); if (!name.compare("MINERvA_CCCOHPI_XSec_1DEpi_joint")) fDist = kEpi; else if (!name.compare("MINERvA_CCCOHPI_XSec_1Dth_joint")) fDist = kth; else if (!name.compare("MINERvA_CCCOHPI_XSec_1DQ2_joint")) fDist = kQ2; else if (!name.compare("MINERvA_CCCOHPI_XSec_1DEnu_joint")) fDist = kEnu; // Define what files to use from the dist std::string datafile = ""; std::string covarfile = ""; std::string titles = ""; std::string distdescript = ""; switch (fDist) { case (kEpi): datafile = "Epi_joint_data.csv"; covarfile = "Epi_joint_cov.csv"; titles = "CC-Coherent #pi;E_{#pi} Bins;d#sigma/dE_{#pi} (cm^{2}/GeV/C12)"; break; case (kth): datafile = "Thpi_joint_data.csv"; covarfile = "Thpi_joint_cov.csv"; titles = "CC-Coherent #pi;#theta_{#pi} Bins;d#sigma/d#theta_{#pi} (cm^{2}/C12)"; break; case (kQ2): datafile = "Q2_joint_data.csv"; covarfile = "Q2_joint_cov.csv"; titles = "CC-Coherent #pi;Q^{2} Bins;d#sigma/dQ^{2} (cm^{2}/GeV^{2}/C12)"; break; case (kEnu): datafile = "Enu_joint_data.csv"; covarfile = "Enu_joint_cov.csv"; titles = "CC-Coherent #pi;E_{#nu} Bins;#sigma(E_{#nu}) (cm^{2}/C12"; break; default: NUIS_ABORT("Unknown Analysis Distribution : " << fDist); } // Now setup each data distribution and description. std::string descrip = distdescript + "Target: CH \n" "Flux: 2 Files, MINERvA FHC numu;MINERvA FHC numubar \n" "Signal: Any event with 1 electron, any nucleons, and " "no other FS particles \n"; fSettings.SetDescription(descrip); fSettings.SetDataInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/" + datafile); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCcoh/" + covarfile); fSettings.SetTitle(GeneralUtils::ParseToStr(titles, ";")[0]); fSettings.SetXTitle(GeneralUtils::ParseToStr(titles, ";")[1]); fSettings.SetYTitle(GeneralUtils::ParseToStr(titles, ";")[2]); return; } //******************************************************************** MINERvA_CCCOHPI_XSec_joint::MINERvA_CCCOHPI_XSec_joint(nuiskey samplekey) { //******************************************************************** // Define Sample Settings common to all data distributions fSettings = LoadSampleSettings(samplekey); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); SetupDataSettings(); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- fScaleFactor = 0.0; // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Setup Sub Measurements // ------------------------------------------------------- SetupSubMeasurements(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCCOHPI_XSec_joint::SetupSubMeasurements() { //******************************************************************** // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA Joint requires input files in format: nu;antinu"); } std::string inFileNeutrino = fSubInFiles.at(0); std::string inFileAntineutrino = fSubInFiles.at(1); // Create some config keys nuiskey nukey = Config::CreateKey("sample"); nukey.SetS("input", inFileNeutrino); nukey.SetS("type", fSettings.GetS("type")); nuiskey antinukey = Config::CreateKey("sample"); antinukey.SetS("input", inFileAntineutrino); antinukey.SetS("type", fSettings.GetS("type")); // Create samples for given DIST switch (fDist) { case kEpi: nukey.SetS("name", "MINERvA_CCCOHPI_XSec_1DEpi_nu"); MIN_nu = new MINERvA_CCCOHPI_XSec_1DEpi_nu(nukey); antinukey.SetS("name", "MINERvA_CCCOHPI_XSec_1DEpi_antinu"); MIN_anu = new MINERvA_CCCOHPI_XSec_1DEpi_antinu(antinukey); break; case kth: nukey.SetS("name", "MINERvA_CCCOHPI_XSec_1Dth_nu"); MIN_nu = new MINERvA_CCCOHPI_XSec_1Dth_nu(nukey); antinukey.SetS("name", "MINERvA_CCCOHPI_XSec_1Dth_antinu"); MIN_anu = new MINERvA_CCCOHPI_XSec_1Dth_antinu(antinukey); break; case kEnu: nukey.SetS("name", "MINERvA_CCCOHPI_XSec_1DEnu_nu"); MIN_nu = new MINERvA_CCCOHPI_XSec_1DEnu_nu(nukey); antinukey.SetS("name", "MINERvA_CCCOHPI_XSec_1DEnu_antinu"); MIN_anu = new MINERvA_CCCOHPI_XSec_1DEnu_antinu(antinukey); break; case kQ2: nukey.SetS("name", "MINERvA_CCCOHPI_XSec_1DQ2_nu"); MIN_nu = new MINERvA_CCCOHPI_XSec_1DQ2_nu(nukey); antinukey.SetS("name", "MINERvA_CCCOHPI_XSec_1DQ2_antinu"); MIN_anu = new MINERvA_CCCOHPI_XSec_1DQ2_antinu(antinukey); break; } // Add to chain for processing fSubChain.clear(); fSubChain.push_back(MIN_anu); fSubChain.push_back(MIN_nu); } //******************************************************************** void MINERvA_CCCOHPI_XSec_joint::MakePlots() { //******************************************************************** TH1D *MIN_nu_mc = (TH1D *)MIN_nu->GetMCHistogram(); TH1D *MIN_anu_mc = (TH1D *)MIN_anu->GetMCHistogram(); int count = 0; for (int i = 0; i < MIN_nu_mc->GetNbinsX(); i++) { fMCHist->SetBinContent(count + 1, MIN_nu_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, MIN_nu_mc->GetBinError(i + 1)); fMCHist->GetXaxis()->SetBinLabel(count + 1, GeneralUtils::IntToStr(count + 1).c_str()); count++; } for (int i = 0; i < MIN_anu_mc->GetNbinsX(); i++) { fMCHist->SetBinContent(count + 1, MIN_anu_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, MIN_anu_mc->GetBinError(i + 1)); fMCHist->GetXaxis()->SetBinLabel(count + 1, GeneralUtils::IntToStr(count + 1).c_str()); count++; } return; } diff --git a/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.h b/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.h index e64205b..d65c2b0 100644 --- a/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.h +++ b/src/MINERvA/MINERvA_CCCOHPI_XSec_joint.h @@ -1,61 +1,61 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCCOHPI_XSec_joint_H_SEEN #define MINERVA_CCCOHPI_XSec_joint_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "Measurement1D.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_nu.h" #include "MINERvA_CCCOHPI_XSec_1DEpi_antinu.h" #include "MINERvA_CCCOHPI_XSec_1Dth_nu.h" #include "MINERvA_CCCOHPI_XSec_1Dth_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DEnu_nu.h" #include "MINERvA_CCCOHPI_XSec_1DEnu_antinu.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_nu.h" #include "MINERvA_CCCOHPI_XSec_1DQ2_antinu.h" class MINERvA_CCCOHPI_XSec_joint : public JointMeas1D { public: MINERvA_CCCOHPI_XSec_joint(nuiskey samplekey); virtual ~MINERvA_CCCOHPI_XSec_joint() {}; void MakePlots(); void SetupDataSettings(); void SetupSubMeasurements(); enum DataDistribution { kEpi, kth, kQ2, kEnu } CCCOH_DataDistributions; private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; Measurement1D* MIN_nu; Measurement1D* MIN_anu; int fDist; }; #endif diff --git a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.cxx index a1605bb..ff58ea8 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.cxx +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.cxx @@ -1,130 +1,111 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCDIS_XSec_1DEnu_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCDIS_XSec_1DEnu_nu::MINERvA_CCDIS_XSec_1DEnu_nu(std::string name, std::string inputfile, std::string type) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCDIS_XSec_1DEnu_nu sample."; // Setup common settings fSettings = LoadSampleSettings(name, inputfile, type); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG/MASK", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 50.0); fSettings.DefineAllowedTargets("Pb,Fe,C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCDIS_XSec_1DEnu_nu"); target = ""; 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 == "") { NUIS_ERR(WRN, "target " << target << " was not found!"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- double binsx[8] = {5.00, 10.00, 15.00, 20.00, 25.00, 30.00, 40.00, 50.00}; CreateDataHistogram(7, binsx); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCDIS_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Need to calculate Q2 and W using the MINERvA method double Enu = Pnu.E() / 1000.; double Emu = Pmu.E() / 1000.; double theta = FitUtils::th(Pnu, Pmu); Q2 = 4 * Enu * Emu * sin(theta / 2.) * sin(theta / 2.); W = sqrt(PhysConst::mass_nucleon * PhysConst::mass_nucleon + 2 * PhysConst::mass_nucleon * (Enu - Emu) - Q2); fXVar = Enu; return; } //******************************************************************** bool MINERvA_CCDIS_XSec_1DEnu_nu::isSignal(FitEvent *event) { //******************************************************************* if (!SignalDef::isCCINC(event, 14, this->EnuMin, this->EnuMax)) return false; // Restrict the phase space to theta < 17 degrees if (!SignalDef::IsRestrictedAngle(event, 14, 13, 17)) return false; if (Q2 < 1.0) return false; if (W < 2.0) return false; return true; }; - -//******************************************************************** -void MINERvA_CCDIS_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; ifMCStat->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_CCDIS_XSec_1DEnu_nu.h b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.h index bca64dd..daf72b5 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.h +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_nu.h @@ -1,49 +1,47 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCDIS_1DEnu_nu_H_SEEN #define MINERVA_CCDIS_1DEnu_nu_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CCDIS_XSec_1DEnu_nu : public Measurement1D { //******************************************************************** public: MINERvA_CCDIS_XSec_1DEnu_nu(std::string name, std::string inputfile, std::string type); virtual ~MINERvA_CCDIS_XSec_1DEnu_nu() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); - void ScaleEvents(); - double GetChi2(){return 0.0;}; private: double Q2, W; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.cxx b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.cxx index 5baa811..273b04e 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.cxx +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.cxx @@ -1,148 +1,139 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCDIS_XSec_1DEnu_ratio.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCDIS_XSec_1DEnu_ratio::MINERvA_CCDIS_XSec_1DEnu_ratio( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCDIS_XSec_1DEnu_ratio sample."; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle(" d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG,FULL/MASK", "FIX/FULL"); fSettings.SetEnuRange(5.0, 50.0); // CCQELike plot information fSettings.SetTitle("MINERvA_CCDIS_XSec_1DEnu_ratio"); fIsRatio = true; nBins = 7; target = ""; if (fSettings.Found("name", "C12")) target = "C12"; else if (fSettings.Found("name", "Fe56")) target = "Fe56"; else if (fSettings.Found("name", "Pb208")) target = "Pb208"; else { NUIS_ABORT("target " << target << " was not found!"); } fSettings.SetDataInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCDIS/CCDIS_" + target + "_CH_ratio_Enu_data.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCDIS/CCDIS_" + target + "_CH_ratio_Enu_stat.csv;" + GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCDIS/CCDIS_" + target + "_CH_ratio_Enu_syst.csv"); FinaliseSampleSettings(); // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA CCDIS ratio requires input files in format: " "NUMERATOR;DENOMINATOR"); } std::string inFileNUM = fSubInFiles.at(0); std::string inFileDEN = fSubInFiles.at(1); // Scaling Setup --------------------------------------------------- // Ratio of sub classes so non needed // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); // Need to overlay the sqrt covariance diagonals onto the data histogram - StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar); + // False stops it complaining that the data hist errors aren't set yet + StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1, false); // Need to scale the covariance by 1E-76... this cancels with the factor of // 1E76 introduced in StatUtils::GetChi2FromCov Who says two wrongs don't make // a right ScaleCovar(1E76); // Setup Experiments ------------------------------------------------------- std::string type = samplekey.GetS("type"); NUM = new MINERvA_CCDIS_XSec_1DEnu_nu( "MINERvA_CCDIS_XSec_1DEnu_" + target + "_CH_NUM", inFileNUM, type); DEN = new MINERvA_CCDIS_XSec_1DEnu_nu( "MINERvA_CCDIS_XSec_1DEnu_" + target + "_CH_DEN", inFileDEN, type); NUM->SetNoData(); DEN->SetNoData(); // Add to chain for processing this->fSubChain.clear(); this->fSubChain.push_back(NUM); this->fSubChain.push_back(DEN); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCDIS_XSec_1DEnu_ratio::MakePlots() { //******************************************************************** UInt_t sample = 0; for (std::vector::const_iterator expIter = this->fSubChain.begin(); expIter != this->fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); if (sample == 0) this->NUM = static_cast(exp); else if (sample == 1) this->DEN = static_cast(exp); else break; sample++; } // Now make the ratio histogram - TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); - TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); - - for (int i = 0; i < nBins; ++i) { - double binVal = 0; - double binErr = 0; - - if (DEN_MC->GetBinContent(i + 1) && NUM_MC->GetBinContent(i + 1)) { - binVal = NUM_MC->GetBinContent(i + 1) / DEN_MC->GetBinContent(i + 1); - double fractErrNUM = - NUM_MC->GetBinError(i + 1) / NUM_MC->GetBinContent(i + 1); - double fractErrDEN = - DEN_MC->GetBinError(i + 1) / DEN_MC->GetBinContent(i + 1); - binErr = - binVal * sqrt(fractErrNUM * fractErrNUM + fractErrDEN * fractErrDEN); - } - - this->fMCHist->SetBinContent(i + 1, binVal); - this->fMCHist->SetBinError(i + 1, binErr); - } + TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); + TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); + this->fMCHist = PlotUtils::GetRatioPlot(NUM_MC, DEN_MC, this->fMCHist); + + TH1D *NUM_FINE = (TH1D *)this->NUM->GetFineList().at(0)->Clone(); + TH1D *DEN_FINE = (TH1D *)this->DEN->GetFineList().at(0)->Clone(); + this->fMCFine = PlotUtils::GetRatioPlot(NUM_FINE, DEN_FINE); + this->fMCFine ->SetNameTitle(Form("%s_MC_FINE", fSettings.GetName().c_str()), + Form("%s_MC_FINE%s", fSettings.GetName().c_str(), + fSettings.GetFullTitles().c_str())); return; } diff --git a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.h b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.h index 5fe5ee8..2c70a07 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.h +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1DEnu_ratio.h @@ -1,52 +1,52 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCDIS_XSec_1DEnu_ratio_H_SEEN #define MINERVA_CCDIS_XSec_1DEnu_ratio_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "MINERvA_CCDIS_XSec_1DEnu_nu.h" class MINERvA_CCDIS_XSec_1DEnu_ratio : public JointMeas1D { public: MINERvA_CCDIS_XSec_1DEnu_ratio(nuiskey samplekey); virtual ~MINERvA_CCDIS_XSec_1DEnu_ratio() {}; void MakePlots(); // This is a dummy function as it is not required for the ratio (and does bad bad things) void ScaleEvents(){return;};; private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; // Need to have the distributions for the numerator and denominator stored separately MINERvA_CCDIS_XSec_1DEnu_nu * NUM; MINERvA_CCDIS_XSec_1DEnu_nu * DEN; Int_t nBins; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.cxx b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.cxx index 97bf4b5..07040b7 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.cxx +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.cxx @@ -1,130 +1,111 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCDIS_XSec_1Dx_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCDIS_XSec_1Dx_nu::MINERvA_CCDIS_XSec_1Dx_nu(std::string name, std::string inputfile, std::string type) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCDIS_XSec_1Dx_nu sample."; // Setup common settings fSettings = LoadSampleSettings(name, inputfile, type); fSettings.SetDescription(descrip); fSettings.SetXTitle("Reconstructed Bjorken x"); fSettings.SetYTitle("d#sigma/dx (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG/MASK", "FIX/DIAG"); fSettings.SetEnuRange(5.0, 50.0); fSettings.DefineAllowedTargets("Pb,Fe,C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCDIS_XSec_1Dx_nu"); target = ""; 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 == "") { NUIS_ABORT("target " << target << " was not found!"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- double binsx[6] = {0.00, 0.10, 0.20, 0.30, 0.40, 0.75}; CreateDataHistogram(5, binsx); FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCDIS_XSec_1Dx_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Need to calculate Q2 and W using the MINERvA method double Enu = Pnu.E() / 1000.; double Emu = Pmu.E() / 1000.; double theta = FitUtils::th(Pnu, Pmu); Q2 = 4 * Enu * Emu * sin(theta / 2.) * sin(theta / 2.); W = sqrt(PhysConst::mass_nucleon * PhysConst::mass_nucleon + 2 * PhysConst::mass_nucleon * (Enu - Emu) - Q2); fXVar = Q2 / (2 * PhysConst::mass_nucleon * (Enu - Emu)); return; } //******************************************************************** bool MINERvA_CCDIS_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 (!SignalDef::IsRestrictedAngle(event, 14, 13, 17)) return false; if (Q2 < 1.0) return false; if (W < 2.0) return false; return true; }; - -//******************************************************************** -void MINERvA_CCDIS_XSec_1Dx_nu::ScaleEvents() { - //******************************************************************** - - Measurement1D::ScaleEvents(); - // this->fDataHist = (TH1D*)this->GetMCList().at(0)->Clone(); - - // this->fMCHist->Scale(this->fScaleFactor, "width"); - - // // Proper error scaling - ROOT Freaks out with xsec weights sometimes - // for(int i=0; ifMCStat->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_CCDIS_XSec_1Dx_nu.h b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.h index c774cbb..a984703 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.h +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_nu.h @@ -1,48 +1,46 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCDIS_1Dx_nu_H_SEEN #define MINERVA_CCDIS_1Dx_nu_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CCDIS_XSec_1Dx_nu : public Measurement1D { //******************************************************************** public: MINERvA_CCDIS_XSec_1Dx_nu(std::string name, std::string inputfile, std::string type); virtual ~MINERvA_CCDIS_XSec_1Dx_nu() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); - void ScaleEvents(); - double GetChi2(){return 0.0;}; private: double Q2, W; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.cxx b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.cxx index c3ca9e1..cd9b137 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.cxx +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.cxx @@ -1,147 +1,137 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCDIS_XSec_1Dx_ratio.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCDIS_XSec_1Dx_ratio::MINERvA_CCDIS_XSec_1Dx_ratio(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCDIS_XSec_1Dx_ratio sample."; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Reconstructed Bjorken x"); fSettings.SetYTitle("d#sigma/dx (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG,FULL/MASK", "FIX/FULL"); fSettings.SetEnuRange(5.0, 50.0); // CCQELike plot information fSettings.SetTitle("MINERvA_CCDIS_XSec_1Dx_ratio"); fIsRatio = true; nBins = 5; target = ""; if (fSettings.Found("name", "C12")) target = "C12"; else if (fSettings.Found("name", "Fe56")) target = "Fe56"; else if (fSettings.Found("name", "Pb208")) target = "Pb208"; else { NUIS_ABORT("target " << target << " was not found!"); } fSettings.SetDataInput(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCDIS/CCDIS_" + target + "_CH_ratio_x_data.csv"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCDIS/CCDIS_" + target + "_CH_ratio_x_stat.csv;" + GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCDIS/CCDIS_" + target + "_CH_ratio_x_syst.csv"); FinaliseSampleSettings(); // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA CCDIS ratio requires input files in format: " "NUMERATOR;DENOMINATOR"); } std::string inFileNUM = fSubInFiles.at(0); std::string inFileDEN = fSubInFiles.at(1); // Scaling Setup --------------------------------------------------- // Ratio of sub classes so non needed // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCovarFromMultipleTextFiles(fSettings.GetCovarInput()); - // Need to overlay the sqrt covariance diagonals (*1E-38) onto the data - // histogram - StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar); + // Need to overlay the sqrt covariance diagonals (*1E-38) onto the data hist + // False stops it complaining that the data hist errors aren't set yet + StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1, false); // Need to scale the covariance by 1E-76... this cancels with the factor of // 1E76 introduced in StatUtils::GetChi2FromCov Who says two wrongs don't make // a right ScaleCovar(1E76); // Setup Experiments ------------------------------------------------------- std::string type = samplekey.GetS("type"); NUM = new MINERvA_CCDIS_XSec_1Dx_nu( "MINERvA_CCDIS_XSec_1Dx_" + target + "_CH_NUM", inFileNUM, type); DEN = new MINERvA_CCDIS_XSec_1Dx_nu( "MINERvA_CCDIS_XSec_1Dx_" + target + "_CH_DEN", inFileDEN, type); NUM->SetNoData(); DEN->SetNoData(); // Add to chain for processing this->fSubChain.clear(); this->fSubChain.push_back(NUM); this->fSubChain.push_back(DEN); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCDIS_XSec_1Dx_ratio::MakePlots() { //******************************************************************** UInt_t sample = 0; for (std::vector::const_iterator expIter = this->fSubChain.begin(); expIter != this->fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); if (sample == 0) this->NUM = static_cast(exp); else if (sample == 1) this->DEN = static_cast(exp); else break; sample++; } // Now make the ratio histogram TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); - - for (int i = 0; i < nBins; ++i) { - double binVal = 0; - double binErr = 0; - - if (DEN_MC->GetBinContent(i + 1) && NUM_MC->GetBinContent(i + 1)) { - binVal = NUM_MC->GetBinContent(i + 1) / DEN_MC->GetBinContent(i + 1); - double fractErrNUM = - NUM_MC->GetBinError(i + 1) / NUM_MC->GetBinContent(i + 1); - double fractErrDEN = - DEN_MC->GetBinError(i + 1) / DEN_MC->GetBinContent(i + 1); - binErr = - binVal * sqrt(fractErrNUM * fractErrNUM + fractErrDEN * fractErrDEN); - } - - this->fMCHist->SetBinContent(i + 1, binVal); - this->fMCHist->SetBinError(i + 1, binErr); - } - + this->fMCHist = PlotUtils::GetRatioPlot(NUM_MC, DEN_MC, this->fMCHist); + + // Also the fine hist + TH1D *NUM_FINE = (TH1D *)this->NUM->GetFineList().at(0)->Clone(); + TH1D *DEN_FINE = (TH1D *)this->DEN->GetFineList().at(0)->Clone(); + this->fMCFine = PlotUtils::GetRatioPlot(NUM_FINE, DEN_FINE); + this->fMCFine ->SetNameTitle(Form("%s_MC_FINE", fSettings.GetName().c_str()), + Form("%s_MC_FINE%s", fSettings.GetName().c_str(), + fSettings.GetFullTitles().c_str())); return; } diff --git a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.h b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.h index 5686c8a..8054e9c 100644 --- a/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.h +++ b/src/MINERvA/MINERvA_CCDIS_XSec_1Dx_ratio.h @@ -1,52 +1,52 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCDIS_XSec_1Dx_ratio_H_SEEN #define MINERVA_CCDIS_XSec_1Dx_ratio_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "MINERvA_CCDIS_XSec_1Dx_nu.h" class MINERvA_CCDIS_XSec_1Dx_ratio : public JointMeas1D { public: MINERvA_CCDIS_XSec_1Dx_ratio(nuiskey samplekey); virtual ~MINERvA_CCDIS_XSec_1Dx_ratio() {}; void MakePlots(); // This is a dummy function as it is not required for the ratio (and does bad bad things) void ScaleEvents(){return;}; private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; // Need to have the distributions for the numerator and denominator stored separately MINERvA_CCDIS_XSec_1Dx_nu * NUM; MINERvA_CCDIS_XSec_1Dx_nu * DEN; Int_t nBins; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx index 78fcb7a..6505180 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1DEnu_nu.h" //******************************************************************** MINERvA_CCNpip_XSec_1DEnu_nu::MINERvA_CCNpip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCNpip_XSec_1DEnu_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("d#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCNpip_XSec_1DEnu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-enu.csv" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-enu.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); // 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.)); } SetCorrelationFromTextFile(fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCNpip_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Enu = Pnu.E()/1000.; fXVar = Enu; }; //******************************************************************** // 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, true); } diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.h b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.h index d6d1f31..a616cf8 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.h +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DEnu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCNPIP_XSEC_1DENU_NU_H_SEEN #define MINERVA_CCNPIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCNpip_XSec_1DEnu_nu : public Measurement1D { public: MINERvA_CCNpip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~MINERvA_CCNpip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool isNew; }; #endif diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx index 4e78eb9..e5a98d5 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.cxx @@ -1,88 +1,88 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1DQ2_nu.h" //******************************************************************** MINERvA_CCNpip_XSec_1DQ2_nu::MINERvA_CCNpip_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCNpip_XSec_1DQ2_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCNpip_XSec_1DQ2_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-q2.csv" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-q2.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); // 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.)); } SetCorrelationFromTextFile(fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCNpip_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double q2 = -1 * (Pnu - Pmu).Mag2() / 1.E6; fXVar = q2; }; //******************************************************************** 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_1DQ2_nu.h b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.h index b7faf50..acb0ba7 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.h +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DQ2_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCNPIP_XSEC_1DQ2_NU_H_SEEN #define MINERVA_CCNPIP_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCNpip_XSec_1DQ2_nu : public Measurement1D { public: MINERvA_CCNpip_XSec_1DQ2_nu(nuiskey samplekey); virtual ~MINERvA_CCNpip_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool isNew; }; #endif diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx index 7346525..7838ba3 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.cxx @@ -1,296 +1,296 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCNpip_XSec_1DTpi_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCNpip_XSec_1DTpi_nu::MINERvA_CCNpip_XSec_1DTpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCNpip_XSec_1DTpi_nu sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 electron, any nucleons, and " "no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#pi} (MeV)"); fSettings.SetYTitle("(1/T#Phi) dN_{#pi}/dT_{#pi} (cm^{2}/MeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fFullPhaseSpace = !fSettings.Found("name", "_20deg"); fFluxCorrection = fSettings.Found("name", "fluxcorr"); fUpdatedData = !fSettings.Found("name", "2015"); fSettings.SetTitle("MINERvA_CCNpip_XSec_1DTpi_nu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- // Full Phase Space if (fFullPhaseSpace) { // 2016 release if (fUpdatedData) { SetDataFromTextFile( 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.)); } // This is a correlation matrix, not covariance matrix, so needs to be // converted SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2016/" "nu-ccNpi+-correlation-pion-kinetic-energy.csv"); // 2015 release } else { // If we're doing shape only if (fIsShape) { SetDataFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_shape.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_shape_cov.txt"); // If we're doing full cross-section } else { SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_cov.txt"); } } // Restricted Phase Space } else { // Only 2015 data released restricted muon phase space cross-section // unfortunately if (fUpdatedData) { NUIS_ABORT(fName << " has no updated 2016 data for restricted phase space! " "Using 2015 data."); } // If we're using the shape only data if (fIsShape) { SetDataFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_shape.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_shape_cov.txt"); // Or total cross-section } else { SetDataFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_Tpi_20deg_cov.txt"); } } // Scale the MINERvA data to account for the flux difference // Adjust MINERvA data to flux correction; roughly a 11% normalisation // increase in data Please change when MINERvA releases new data! if (fFluxCorrection) { for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } } // Make some auxillary helper plots onePions = (TH1D *)(fDataHist->Clone()); onePions->SetNameTitle((fName + "_1pions").c_str(), (fName + "_1pions" + fPlotTitles).c_str()); SetAutoProcessTH1(onePions, kCMD_Reset, kCMD_Scale, kCMD_Norm); twoPions = (TH1D *)(fDataHist->Clone()); twoPions->SetNameTitle((fName + "_2pions").c_str(), (fName + "_2pions;" + fPlotTitles).c_str()); SetAutoProcessTH1(twoPions, kCMD_Reset, kCMD_Scale, kCMD_Norm); threePions = (TH1D *)(fDataHist->Clone()); threePions->SetNameTitle((fName + "_3pions").c_str(), (fName + "_3pions" + fPlotTitles).c_str()); SetAutoProcessTH1(threePions, kCMD_Reset, kCMD_Scale, kCMD_Norm); morePions = (TH1D *)(fDataHist->Clone()); morePions->SetNameTitle((fName + "_4pions").c_str(), (fName + "_4pions" + fPlotTitles).c_str()); SetAutoProcessTH1(morePions, kCMD_Reset, kCMD_Scale, kCMD_Norm); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** // Here we have to fill for every pion we find in the event void MINERvA_CCNpip_XSec_1DTpi_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(211) == 0 && event->NumFSParticle(-211) == 0) return; if (event->NumFSParticle(13) == 0) return; // Need to make this use event boxes // Clear out the vectors GetPionBox()->Reset(); TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; // Loop over the particle stack for (unsigned int j = 2; j < event->Npart(); ++j) { // Only include alive particles if (event->GetParticleState(j) != kFinalState) 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.; GetPionBox()->fTpiVect.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 return SignalDef::isCCNpip_MINERvA(event, EnuMin, EnuMax, !fFullPhaseSpace, !fUpdatedData); } //******************************************************************** // Need to override FillHistograms() here because we fill the histogram N_pion // times void MINERvA_CCNpip_XSec_1DTpi_nu::FillHistograms() { //******************************************************************** if (Signal) { unsigned int nPions = GetPionBox()->fTpiVect.size(); // Need to loop over all the pions in the sample for (size_t k = 0; k < nPions; ++k) { double tpi = GetPionBox()->fTpiVect[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); } if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, tpi, 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); // Make an auto processed pion stack // 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_1DTpi_nu.h b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.h index 5b99b92..919644e 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.h +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1DTpi_nu.h @@ -1,56 +1,56 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCNPIP_XSEC_1DTPI_NU_H_SEEN #define MINERVA_CCNPIP_XSEC_1DTPI_NU_H_SEEN #include "Measurement1D.h" #include "MINERvAVariableBoxes.h" class MINERvA_CCNpip_XSec_1DTpi_nu : public Measurement1D { public: MINERvA_CCNpip_XSec_1DTpi_nu(nuiskey samplekey); virtual ~MINERvA_CCNpip_XSec_1DTpi_nu() {}; void FillEventVariables(FitEvent *event); void FillHistograms(); bool isSignal(FitEvent *event); void ScaleEvents(); void Write(std::string drawOpts); /// \brief Use Tpi Box to save all pion info on signal events inline NTpiVariableBox1D* GetPionBox(){ return static_cast(GetBox()); }; /// \brief Create Tpi Box for this sample inline MeasurementVariableBox* CreateBox(){ return new NTpiVariableBox1D(); }; bool fFullPhaseSpace; bool fUpdatedData; bool fFluxCorrection; private: TH1D *onePions; TH1D *twoPions; TH1D *threePions; TH1D *morePions; }; #endif diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx index e58a334..e4da379 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1Dpmu_nu.h" //******************************************************************** MINERvA_CCNpip_XSec_1Dpmu_nu::MINERvA_CCNpip_XSec_1Dpmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCNpip_XSec_1Dpmu_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("d#sigma/dp_{#mu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCNpip_XSec_1Dpmu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-muon-momentum.csv" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-muon-momentum.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); // 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.)); } SetCorrelationFromTextFile(fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** // Very simple event variable fill void MINERvA_CCNpip_XSec_1Dpmu_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.; fXVar = pmu; }; //******************************************************************** // 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_1Dpmu_nu.h b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.h index 9f70ca0..7ce1369 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.h +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dpmu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCNPIP_XSEC_1DPMU_NU_H_SEEN #define MINERVA_CCNPIP_XSEC_1DPMU_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCNpip_XSec_1Dpmu_nu : public Measurement1D { public: MINERvA_CCNpip_XSec_1Dpmu_nu(nuiskey samplekey); virtual ~MINERvA_CCNpip_XSec_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool isNew; }; #endif diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx index 1b219c2..65cfef3 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.cxx @@ -1,288 +1,288 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCNpip_XSec_1Dth_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCNpip_XSec_1Dth_nu::MINERvA_CCNpip_XSec_1Dth_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCNpip_XSec_1Dth_nu sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 electron, any nucleons, and " "no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#pi} (degrees)"); fSettings.SetYTitle( "(1/T#Phi) dN_{#pi}/d#theta_{#pi} (cm^{2}/degrees/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fFullPhaseSpace = !fSettings.Found("name", "_20deg"); fFluxCorrection = fSettings.Found("name", "fluxcorr"); fUpdatedData = !fSettings.Found("name", "2015"); fSettings.SetTitle("MINERvA_CCNpip_XSec_1Dth_nu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- // Full Phase Space if (fFullPhaseSpace) { // 2016 release data if (fUpdatedData) { SetDataFromTextFile( 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 SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-pion-angle.csv"); // 2015 release data } else { // 2015 release allows for shape comparisons if (fIsShape) { SetDataFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_shape.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_shape_cov.txt"); } else { SetDataFromTextFile(GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_cov.txt"); } } // Restricted Phase Space Data } else { // 2016 release data unfortunately not released in 20degree forward-going, // revert to 2015 data if (fUpdatedData) { NUIS_ABORT(fName << " has no updated 2016 data for restricted phase space! Using " "2015 data."); } // Only 2015 20deg data if (fIsShape) { SetDataFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg_shape.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg_shape_cov.txt"); } else { SetDataFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg.txt"); SetCorrelationFromTextFile( GeneralUtils::GetTopLevelDir() + "/data/MINERvA/CCNpip/2015/MINERvA_CCNpi_th_20deg_cov.txt"); } } // Scale the MINERvA data to account for the flux difference // Adjust MINERvA data to flux correction; roughly a 11% normalisation // increase in data Please change when MINERvA releases new data! if (fFluxCorrection) { for (int i = 0; i < fDataHist->GetNbinsX() + 1; i++) { fDataHist->SetBinContent(i + 1, fDataHist->GetBinContent(i + 1) * 1.11); } } // Make some auxillary helper plots onePions = (TH1D *)(fDataHist->Clone()); onePions->SetNameTitle((fName + "_1pions").c_str(), (fName + "_1pions" + fPlotTitles).c_str()); SetAutoProcessTH1(onePions, kCMD_Reset, kCMD_Scale, kCMD_Norm); twoPions = (TH1D *)(fDataHist->Clone()); twoPions->SetNameTitle((fName + "_2pions").c_str(), (fName + "_2pions;" + fPlotTitles).c_str()); SetAutoProcessTH1(twoPions, kCMD_Reset, kCMD_Scale, kCMD_Norm); threePions = (TH1D *)(fDataHist->Clone()); threePions->SetNameTitle((fName + "_3pions").c_str(), (fName + "_3pions" + fPlotTitles).c_str()); SetAutoProcessTH1(threePions, kCMD_Reset, kCMD_Scale, kCMD_Norm); morePions = (TH1D *)(fDataHist->Clone()); morePions->SetNameTitle((fName + "_4pions").c_str(), (fName + "_4pions" + fPlotTitles).c_str()); SetAutoProcessTH1(morePions, kCMD_Reset, kCMD_Scale, kCMD_Norm); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; // ******************************************** // 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) { // ******************************************** if (event->NumFSParticle(211) == 0 && event->NumFSParticle(-211) == 0) return; if (event->NumFSParticle(13) == 0) return; GetBox()->Reset(); TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->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 <= 0) continue; if ((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); GetPionBox()->fthpiVect.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, !fUpdatedData); } //******************************************************************** // Need to override FillHistograms() here because we fill the histogram N_pion // times void MINERvA_CCNpip_XSec_1Dth_nu::FillHistograms() { //******************************************************************** if (Signal) { unsigned int nPions = GetPionBox()->fthpiVect.size(); // Need to loop over all the pions in the event for (size_t k = 0; k < nPions; ++k) { double th = GetPionBox()->fthpiVect[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); } if (fMCHist_Modes) fMCHist_Modes->Fill(Mode, th, Weight); // PlotUtils::FillNeutModeArray(fMCHist_PDG, Mode, th, Weight); } } 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_1Dth_nu.h b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.h index f95a315..04ca91f 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.h +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dth_nu.h @@ -1,55 +1,55 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCNPIP_XSEC_1DTH_NU_H_SEEN #define MINERVA_CCNPIP_XSEC_1DTH_NU_H_SEEN #include "Measurement1D.h" #include "MINERvAVariableBoxes.h" class MINERvA_CCNpip_XSec_1Dth_nu : public Measurement1D { public: MINERvA_CCNpip_XSec_1Dth_nu(nuiskey samplekey); virtual ~MINERvA_CCNpip_XSec_1Dth_nu() {}; void FillEventVariables(FitEvent *event); void FillHistograms(); bool isSignal(FitEvent *event); void Write(std::string drawOpt); bool fFullPhaseSpace; bool fUpdatedData; bool fFluxCorrection; /// \brief Use thpi Box to save all pion info on signal events inline NthpiVariableBox1D* GetPionBox(){ return static_cast(GetBox()); }; /// \brief Create thpi Box for this sample inline MeasurementVariableBox* CreateBox(){ return new NthpiVariableBox1D(); }; private: bool isNew; TH1D *onePions; TH1D *twoPions; TH1D *threePions; TH1D *morePions; }; #endif diff --git a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx index 12d98df..2d7ad81 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.cxx @@ -1,93 +1,93 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCNpip_XSec_1Dthmu_nu.h" //******************************************************************** MINERvA_CCNpip_XSec_1Dthmu_nu::MINERvA_CCNpip_XSec_1Dthmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCNpip_XSec_1Dthmu_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#theta_{#mu} (degrees)"); fSettings.SetYTitle("d#sigma/d#theta_{#mu} (cm^{2}/degrees/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCNpip_XSec_1Dthmu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-xsec-muon-theta.csv" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CCNpip/2016/nu-ccNpi+-correlation-muon-angle.csv"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); // 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.)); } SetCorrelationFromTextFile(fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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 hadMass = FitUtils::Wrec(Pnu, Pmu); double thmu = -999; if (hadMass < 1800) thmu = (180. / M_PI) * FitUtils::th(Pnu, Pmu); fXVar = thmu; }; //******************************************************************** // 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_CCNpip_XSec_1Dthmu_nu.h b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.h index 8eb152d..5add7ae 100644 --- a/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.h +++ b/src/MINERvA/MINERvA_CCNpip_XSec_1Dthmu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCNPIP_XSEC_1DTHMU_NU_H_SEEN #define MINERVA_CCNPIP_XSEC_1DTHMU_NU_H_SEEN #include "Measurement1D.h" class MINERvA_CCNpip_XSec_1Dthmu_nu : public Measurement1D { public: MINERvA_CCNpip_XSec_1Dthmu_nu(nuiskey samplekey); virtual ~MINERvA_CCNpip_XSec_1Dthmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool isNew; }; #endif diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx index 386907b..2d62c05 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.cxx @@ -1,209 +1,214 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCQE_XSec_1DQ2_antinu.h" //******************************************************************** MINERvA_CCQE_XSec_1DQ2_antinu::MINERvA_CCQE_XSec_1DQ2_antinu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCQE_XSec_1DQ2_antinu sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current Numubar \n" "Signal: True CCQE/2p2h defined at the vertex level \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); isFluxFix = !fSettings.Found("name", "_oldflux"); fullphasespace = !fSettings.Found("name", "_20deg"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCQE_XSec_1DQ2_antinu"); fSaveExtra = FitPar::Config().GetParB("MINERvASaveExtraCCQE"); std::string basedir = FitPar::GetDataBase() + "/MINERvA/CCQE/"; std::string datafilename = ""; std::string covarfilename = ""; // Full Phase Space if (fullphasespace) { if (isFluxFix) { if (fIsShape) { NUIS_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. "); } datafilename = "Q2QE_numubar_data_fluxfix.txt"; covarfilename = "Q2QE_numubar_covar_fluxfix.txt"; // Correlation Matrix } else { if (fIsShape) { datafilename = "Q2QE_numubar_data_SHAPE-extracted.txt"; covarfilename = "Q2QE_numubar_covar_SHAPE-extracted.txt"; // correlation } else { datafilename = "Q2QE_numubar_data.txt"; covarfilename = "Q2QE_numubar_covar.txt"; // Correlation } } // Restricted Phase Space } else { if (isFluxFix) { if (fIsShape) { NUIS_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. "); } datafilename = "20deg_Q2QE_numubar_data_fluxfix.txt"; covarfilename = "20deg_Q2QE_numubar_covar_fluxfix.txt"; // Correlation } else { if (fIsShape) { datafilename = "20deg_Q2QE_numubar_data_SHAPE-extracted.txt"; covarfilename = "20deg_Q2QE_numubar_covar_SHAPE-extracted.txt"; // Correlation } else { datafilename = "20deg_Q2QE_numubar_data.txt"; covarfilename = "20deg_Q2QE_numubar_covar.txt"; // Correlation } } } fSettings.SetDataInput(basedir + datafilename); fSettings.SetCovarInput(basedir + covarfilename); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * 13. / 7. / TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); - SetCorrelationFromTextFile(fSettings.GetCovarInput()); + + // Ergh, the pain of supporting many slightly different versions of the same analysis + if (isFluxFix) SetCovarFromTextFile(fSettings.GetCovarInput()); + else SetCorrelationFromTextFile(fSettings.GetCovarInput()); + + if (isFluxFix) ScaleData(1E-38); if (fSaveExtra) { fExtra_Eav = new TH1D((fSettings.GetName() + "Eav").c_str(), "Eav", 30, 0.0, 1.0); fExtra_Eav_MODES = new MINERvAUtils::ModeStack( (fSettings.GetName() + "EavMODES").c_str(), "EavMODES", fExtra_Eav); // fExtra_Eav_MODES->SetReverseStack(); SetAutoProcess(fExtra_Eav); SetAutoProcess(fExtra_Eav_MODES); fExtra_EavQ2 = new TH2D((fSettings.GetName() + "EavQ2").c_str(), "EavQ2", 12, 0.0, 2.0, 50, 0.0, 1.0); fExtra_EavQ2_MODES = new MINERvAUtils::ModeStack( (fSettings.GetName() + "EavQ2MODES").c_str(), "EavQ2MODES", fExtra_EavQ2); // fExtra_EavQ2_MODES->SetReverseStack(); SetAutoProcess(fExtra_EavQ2); SetAutoProcess(fExtra_EavQ2_MODES); fEavQ2Cut = new TF1((fSettings.GetName() + "f1").c_str(), "0.03 + 0.3*x", 0.0, 2.0); SetAutoProcess(fEavQ2Cut); } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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; if (fSaveExtra) { double pm = 938.2720813; double pe = pm + 120.0; FitParticle *fakeproton = new FitParticle(0.0, 0.0, sqrt(pe * pe - pm * pm), pe, 2212, kFinalState); double range = MINERvAUtils::RangeInScintillator(fakeproton, 100); pm = 139.57018; pe = pm + 65; // FitParticle* fakepion = new FitParticle(0.0,0.0,sqrt(pe*pe-pm*pm), pe, // 211, kFinalState); double pionrange = // MINERvAUtils::RangeInScintillator(fakepion, 100); double Eav = 0.0; for (uint i = 0; i < event->NParticles(); i++) { if (event->GetParticleState(i) != kFinalState) continue; int pid = event->GetParticlePDG(i); double ParticleEav = 0.0; if (abs(pid) == 13) continue; if (pid != 2112 and pid != 22 and pid != 111) { ParticleEav = MINERvAUtils::GetEDepositOutsideRangeInScintillator( event->GetParticle(i), range) / 1.E3; } else if (pid == 22 or pid == 111) { ParticleEav = event->GetParticle(i)->fP.E() / 1.E3; } Eav += ParticleEav; } fExtra_Eav->Fill(Eav); fExtra_Eav_MODES->Fill(event->Mode, Eav); fExtra_EavQ2->Fill(q2qe, Eav); fExtra_EavQ2_MODES->Fill(event->Mode, q2qe, Eav); } 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_antinu.h b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.h index fcc6629..79c4920 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.h +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_antinu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCQE_XSec_1DQ2_antinu_H_SEEN #define MINERVA_CCQE_XSec_1DQ2_antinu_H_SEEN #include "Measurement1D.h" #include "MINERvAUtils.h" //******************************************************************** class MINERvA_CCQE_XSec_1DQ2_antinu : public Measurement1D { //******************************************************************** public: MINERvA_CCQE_XSec_1DQ2_antinu(nuiskey samplekey); virtual ~MINERvA_CCQE_XSec_1DQ2_antinu() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: bool isFluxFix, fullphasespace; bool fSaveExtra; TH1D* fExtra_Eav; MINERvAUtils::ModeStack* fExtra_Eav_MODES; TH2D* fExtra_EavQ2; MINERvAUtils::ModeStack* fExtra_EavQ2_MODES; TF1* fEavQ2Cut; }; #endif diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx index 338396d..f48e118 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.cxx @@ -1,202 +1,213 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCQE_XSec_1DQ2_joint.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCQE_XSec_1DQ2_joint::MINERvA_CCQE_XSec_1DQ2_joint(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCQE_XSec_1DQ2_joint sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 electron, any nucleons, and " "no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); isFluxFix = !fSettings.Found("name", "_oldflux"); fullphasespace = !fSettings.Found("name", "_20deg"); nBins = 16; fIsRatio = false; fIsSummed = false; fSaveSubMeas = true; // CCQELike plot information fSettings.SetTitle("MINERvA_CCQE_XSec_1DQ2_joint"); std::string basedir = FitPar::GetDataBase() + "/MINERvA/CCQE/"; std::string datafilename = ""; std::string covarfilename = ""; std::string neutrinoclass = ""; std::string antineutrinoclass = ""; + // Add some warnings + if (!isFluxFix) { + NUIS_ERR(WRN, "The 2013 CCQE results from MINERvA have been updated to account for a flux recalculation..."); + NUIS_ERR(WRN, "Unless you're sure you want the old flux, be warned!"); + } + // Full Phase Space if (fullphasespace) { if (isFluxFix) { if (fIsShape) { NUIS_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. "); } 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"; + neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_oldflux"; + antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_oldflux"; } // Restricted Phase Space } else { if (isFluxFix) { if (fIsShape) { NUIS_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. "); } 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"; + neutrinoclass = "MINERvA_CCQE_XSec_1DQ2_nu_20deg_oldflux"; + antineutrinoclass = "MINERvA_CCQE_XSec_1DQ2_antinu_20deg_oldflux"; } } fSettings.SetDataInput(basedir + datafilename); fSettings.SetCovarInput(basedir + covarfilename); fSettings.DefineAllowedSpecies("numu,numub"); - std::cout << "Finalising sample settings for joint fit = " << fIsJoint - << std::endl; FinaliseSampleSettings(); // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA Joint requires input files in format: antinu;nu"); } 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); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); - if (fullphasespace and isFluxFix) - SetCovarFromTextFile(fSettings.GetCovarInput()); - else { - SetCorrelationFromTextFile(fSettings.GetCovarInput()); - } + + // Ergh, the pain of supporting many slightly different versions of the same analysis + if (isFluxFix) SetCovarFromTextFile(fSettings.GetCovarInput()); + else SetCorrelationFromTextFile(fSettings.GetCovarInput()); + + if (isFluxFix) ScaleData(1E-38); // Setup Sub classes nuiskey antinukey = Config::CreateKey("sample"); antinukey.SetS("name", antineutrinoclass); antinukey.SetS("input", inFileAntineutrino); antinukey.SetS("type", fSettings.GetS("type")); MIN_anu = new MINERvA_CCQE_XSec_1DQ2_antinu(antinukey); nuiskey nukey = Config::CreateKey("sample"); nukey.SetS("name", neutrinoclass); nukey.SetS("input", inFileNeutrino); nukey.SetS("type", fSettings.GetS("type")); MIN_nu = new MINERvA_CCQE_XSec_1DQ2_nu(nukey); // Add to chain for processing this->fSubChain.clear(); - this->fSubChain.push_back(MIN_anu); - this->fSubChain.push_back(MIN_nu); + + // Supremely confusingly, the original MINERvA results are given numubar--numu + // but the updates are numu--numubar. Because we support both, we need this hideousness + if (isFluxFix){ + this->fSubChain.push_back(MIN_nu); + this->fSubChain.push_back(MIN_anu); + } else { + this->fSubChain.push_back(MIN_anu); + this->fSubChain.push_back(MIN_nu); + } // Final setup --------------------------------------------------- FinaliseMeasurement(); + + fSaveFine = false; }; //******************************************************************** void MINERvA_CCQE_XSec_1DQ2_joint::MakePlots() { //******************************************************************** UInt_t sample = 0; for (std::vector::const_iterator expIter = fSubChain.begin(); expIter != fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); if (sample == 0) { MIN_anu = static_cast(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(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_joint.h b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.h index e74f055..8ed004f 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.h +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_joint.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_1DQ2_joint_H_SEEN #define MINERVA_1DQ2_joint_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "MINERvA_CCQE_XSec_1DQ2_nu.h" #include "MINERvA_CCQE_XSec_1DQ2_antinu.h" class MINERvA_CCQE_XSec_1DQ2_joint : public JointMeas1D { public: MINERvA_CCQE_XSec_1DQ2_joint(nuiskey samplekey); virtual ~MINERvA_CCQE_XSec_1DQ2_joint() {}; void MakePlots(); private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; bool isFluxFix, fullphasespace; // Need to have the neutrino and anti-neutrino objects here MINERvA_CCQE_XSec_1DQ2_nu * MIN_nu; MINERvA_CCQE_XSec_1DQ2_antinu * MIN_anu; Int_t nBins; }; #endif diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx index 8868df1..7f91dc1 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.cxx @@ -1,211 +1,211 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCQE_XSec_1DQ2_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCQE_XSec_1DQ2_nu::MINERvA_CCQE_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCQE_XSec_1DQ2_nu sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current Numu \n" "Signal: True CCQE/2p2h defined at the vertex level \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(1.5, 10.0); fSettings.DefineAllowedTargets("C,H"); isFluxFix = !fSettings.Found("name", "_oldflux"); fullphasespace = !fSettings.Found("name", "_20deg"); fSaveExtra = FitPar::Config().GetParB("MINERvASaveExtraCCQE"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCQE_XSec_1DQ2_nu"); std::string basedir = FitPar::GetDataBase() + "/MINERvA/CCQE/"; std::string datafilename = ""; std::string covarfilename = ""; // Full Phase Space if (fullphasespace) { if (isFluxFix) { if (fIsShape) { NUIS_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. "); } 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) { NUIS_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. "); } 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"; } } } fSettings.SetDataInput(basedir + datafilename); fSettings.SetCovarInput(basedir + covarfilename); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 * 13.0 / 6.0 / (fNEvents + 0.)) / TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); - if (!isFluxFix or !fullphasespace) { - SetCorrelationFromTextFile(fSettings.GetCovarInput()); - } else { - SetCovarFromTextFile(fSettings.GetCovarInput()); - } + // Ergh, the pain of supporting many slightly different versions of the same analysis + if (isFluxFix) SetCovarFromTextFile(fSettings.GetCovarInput()); + else SetCorrelationFromTextFile(fSettings.GetCovarInput()); + + if (isFluxFix) ScaleData(1E-38); if (fSaveExtra) { fExtra_Eav = new TH1D((fSettings.GetName() + "Eav").c_str(), "Eav", 30, 0.0, 1.0); fExtra_Eav_MODES = new MINERvAUtils::ModeStack( (fSettings.GetName() + "EavMODES").c_str(), "EavMODES", fExtra_Eav); // fExtra_Eav_MODES->SetReverseStack(); SetAutoProcess(fExtra_Eav); SetAutoProcess(fExtra_Eav_MODES); fExtra_EavQ2 = new TH2D((fSettings.GetName() + "EavQ2").c_str(), "EavQ2", 12, 0.0, 2.0, 50, 0.0, 1.0); fExtra_EavQ2_MODES = new MINERvAUtils::ModeStack( (fSettings.GetName() + "EavQ2MODES").c_str(), "EavQ2MODES", fExtra_EavQ2); // fExtra_EavQ2_MODES->SetReverseStack(); SetAutoProcess(fExtra_EavQ2); SetAutoProcess(fExtra_EavQ2_MODES); fEavQ2Cut = new TF1((fSettings.GetName() + "f1").c_str(), "0.03 + 0.3*x", 0.0, 2.0); SetAutoProcess(fEavQ2Cut); } // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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; // Calculate from scratch the vertex size if (fSaveExtra) { double pm = 938.2720813; double pe = pm + 120.0; FitParticle *fakeproton = new FitParticle(0.0, 0.0, sqrt(pe * pe - pm * pm), pe, 2212, kFinalState); double range = MINERvAUtils::RangeInScintillator(fakeproton, 100); pm = 139.57018; pe = pm + 65; // FitParticle* fakepion = new FitParticle(0.0,0.0,sqrt(pe*pe-pm*pm), pe, // 211, kFinalState); double pionrange = // MINERvAUtils::RangeInScintillator(fakepion, 100); double Eav = 0.0; for (uint i = 0; i < event->NParticles(); i++) { if (event->GetParticleState(i) != kFinalState) continue; int pid = event->GetParticlePDG(i); double ParticleEav = 0.0; if (pid == 13) continue; if (pid != 2112 and pid != 22 and pid != 111) { ParticleEav = MINERvAUtils::GetEDepositOutsideRangeInScintillator( event->GetParticle(i), range) / 1.E3; } else if (pid == 22 or pid == 111) { ParticleEav = event->GetParticle(i)->fP.E() / 1.E3; } Eav += ParticleEav; } fExtra_Eav->Fill(Eav); fExtra_Eav_MODES->Fill(event->Mode, Eav); fExtra_EavQ2->Fill(q2qe, Eav); fExtra_EavQ2_MODES->Fill(event->Mode, q2qe, Eav); } return; } //******************************************************************** bool MINERvA_CCQE_XSec_1DQ2_nu::isSignal(FitEvent *event) { //******************************************************************* return SignalDef::isCCQEnumu_MINERvA(event, EnuMin, EnuMax, fullphasespace); } diff --git a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.h b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.h index ce2dba7..1691a0a 100644 --- a/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.h +++ b/src/MINERvA/MINERvA_CCQE_XSec_1DQ2_nu.h @@ -1,70 +1,70 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_1DQ2_nu_H_SEEN #define MINERVA_1DQ2_nu_H_SEEN #include "Measurement1D.h" #include "MINERvAUtils.h" ///\brief MINERvA CCQE+2p2h Analysis : Q2 Distribution /// ///\n Ref: ///\n Input: CH events generated with at least CCQE+2p2h interaction modes with flux given in Ref. //******************************************************************** class MINERvA_CCQE_XSec_1DQ2_nu : public Measurement1D { //******************************************************************** public: ///\brief Setup data histograms and full covariance matrix ///\n Available fit options: FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK ///\n Sample is given as /neutron. /// ///\n Valid Sample Names: ///\n 1. MINERvA_CCQE_XSec_1DQ2_nu - Latest update full phase space ///\n 2. MINERvA_CCQE_XSec_1DQ2_nu_20deg - Latest update restricted phase space ///\n 3. MINERvA_CCQE_XSec_1DQ2_nu_oldflux - Old flux from original release, full phase space ///\n 4. MINERvA_CCQE_XSec_1DQ2_nu_20deg_oldflux - Old flux from original release, restricted phase space MINERvA_CCQE_XSec_1DQ2_nu(nuiskey samplekey); virtual ~MINERvA_CCQE_XSec_1DQ2_nu() {}; ///\brief Signal is True CCQE+2p2h /// ///\n 1. True Mode == 1 or 2 ///\n 2. 1.5 < Enu < 10.0 ///\n 3. Muon Angle < 20deg (Restricted PS) bool isSignal(FitEvent* event); ///\brief Determine Q2 from the muon void FillEventVariables(FitEvent *event); private: bool isFluxFix; /// Flag for using updated flux bool fullphasespace; /// Flag for restricting phase space bool fSaveExtra; TH1D* fExtra_Eav; MINERvAUtils::ModeStack* fExtra_Eav_MODES; TH2D* fExtra_EavQ2; MINERvAUtils::ModeStack* fExtra_EavQ2_MODES; TF1* fEavQ2Cut; }; #endif diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx index 0b537be..be5ff81 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.cxx @@ -1,125 +1,106 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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, std::string type) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCinc_XSec_1DEnu_nu sample. \n" "Target: CH \n" "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 muon, any nucleons, and no " "other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(name, inputfile, type); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG/MASK", "FIX/DIAG"); fSettings.SetEnuRange(2.0, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCinc_XSec_1DEnu_nu"); target = ""; 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 == "") { NUIS_ABORT("target " << target << " was not found!"); } // fSettings.SetSmearingInput( FitPar::GetDataBase() + // "/MINERvA/CCinc/CCinc_"+target+"_x_smear.csv" ); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- double binsx[9] = {2, 3, 4, 5, 6, 8, 10, 15, 20}; CreateDataHistogram(8, binsx); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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; fXVar = Pnu.E() / 1000.; ThetaMu = Pnu.Vect().Angle(Pmu.Vect()); return; } //******************************************************************** bool MINERvA_CCinc_XSec_1DEnu_nu::isSignal(FitEvent *event) { //******************************************************************* if (!SignalDef::isCCINC(event, 14, this->EnuMin, this->EnuMax)) return false; // Restrict the phase space to theta < 17 degrees if (ThetaMu > 0.296706) 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; ifMCStat->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_1DEnu_nu.h b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.h index 47c0829..e7cf09e 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.h +++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_nu.h @@ -1,49 +1,47 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCinc_1DEnu_nu_H_SEEN #define MINERVA_CCinc_1DEnu_nu_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CCinc_XSec_1DEnu_nu : public Measurement1D { //******************************************************************** public: MINERvA_CCinc_XSec_1DEnu_nu(std::string name, std::string inputfile, std::string type); virtual ~MINERvA_CCinc_XSec_1DEnu_nu() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); - void ScaleEvents(); - double GetChi2(){return 0.0;}; private: double ThetaMu; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx index 30009f3..00671ba 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.cxx @@ -1,145 +1,136 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCinc_XSec_1DEnu_ratio.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCinc_XSec_1DEnu_ratio::MINERvA_CCinc_XSec_1DEnu_ratio( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCinc_XSec_1DEnu_ratio sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 electron, any nucleons, and " "no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle(" d#sigma/dE_{#nu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG,FULL/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 20.0); // CCQELike plot information fSettings.SetTitle("MINERvA_CCinc_XSec_1DEnu_ratio"); fIsRatio = true; nBins = 8; target = ""; if (fSettings.Found("name", "C12")) target = "C12"; else if (fSettings.Found("name", "Fe56")) target = "Fe56"; else if (fSettings.Found("name", "Pb208")) target = "Pb208"; else { NUIS_ABORT("target " << target << " was not found!"); } std::string basedir = FitPar::GetDataBase() + "/MINERvA/CCinc/"; fSettings.SetDataInput(basedir + "CCinc_" + target + "_CH_ratio_Enu_data.csv"); fSettings.SetCovarInput(basedir + "CCinc_" + target + "_CH_ratio_Enu_covar.csv"); FinaliseSampleSettings(); // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA CCinc ratio requires input files in format: " "NUMERATOR;DENOMINATOR"); } std::string inFileNUM = fSubInFiles.at(0); std::string inFileDEN = fSubInFiles.at(1); // Scaling Setup --------------------------------------------------- // Ratio of sub classes so non needed // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); // This function forces in a factor of 1E76 to the covariance. // This cancels with the factor of 1E38 which is added to the data in the chi2 // calculation... Who said two wrongs don't make a right? SetCorrelationFromTextFile(fSettings.GetCovarInput()); // Setup Experiments ------------------------------------------------------- std::string type = samplekey.GetS("type"); NUM = new MINERvA_CCinc_XSec_1DEnu_nu( "MINERvA_CCinc_XSec_1DEnu_" + target + "_CH_NUM", inFileNUM, type); DEN = new MINERvA_CCinc_XSec_1DEnu_nu( "MINERvA_CCinc_XSec_1DEnu_" + target + "_CH_DEN", inFileDEN, type); NUM->SetNoData(); DEN->SetNoData(); // Add to chain for processing this->fSubChain.clear(); this->fSubChain.push_back(NUM); this->fSubChain.push_back(DEN); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCinc_XSec_1DEnu_ratio::MakePlots() { //******************************************************************** UInt_t sample = 0; for (std::vector::const_iterator expIter = this->fSubChain.begin(); expIter != this->fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); if (sample == 0) this->NUM = static_cast(exp); else if (sample == 1) this->DEN = static_cast(exp); else break; sample++; } // Now make the ratio histogram TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); - - for (int i = 0; i < nBins; ++i) { - double binVal = 0; - double binErr = 0; - - if (DEN_MC->GetBinContent(i + 1) && NUM_MC->GetBinContent(i + 1)) { - binVal = NUM_MC->GetBinContent(i + 1) / DEN_MC->GetBinContent(i + 1); - double fractErrNUM = - NUM_MC->GetBinError(i + 1) / NUM_MC->GetBinContent(i + 1); - double fractErrDEN = - DEN_MC->GetBinError(i + 1) / DEN_MC->GetBinContent(i + 1); - binErr = - binVal * sqrt(fractErrNUM * fractErrNUM + fractErrDEN * fractErrDEN); - } - - this->fMCHist->SetBinContent(i + 1, binVal); - this->fMCHist->SetBinError(i + 1, binErr); - } + this->fMCHist = PlotUtils::GetRatioPlot(NUM_MC, DEN_MC, this->fMCHist); + + // Fine ratio for good measure + TH1D *NUM_FINE = (TH1D *)this->NUM->GetFineList().at(0)->Clone(); + TH1D *DEN_FINE = (TH1D *)this->DEN->GetFineList().at(0)->Clone(); + this->fMCFine = PlotUtils::GetRatioPlot(NUM_FINE, DEN_FINE); + this->fMCFine ->SetNameTitle(Form("%s_MC_FINE", fSettings.GetName().c_str()), + Form("%s_MC_FINE%s", fSettings.GetName().c_str(), + fSettings.GetFullTitles().c_str())); return; } diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.h b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.h index c7de8b2..f25b331 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.h +++ b/src/MINERvA/MINERvA_CCinc_XSec_1DEnu_ratio.h @@ -1,52 +1,52 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCinc_XSec_1DEnu_ratio_H_SEEN #define MINERVA_CCinc_XSec_1DEnu_ratio_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "MINERvA_CCinc_XSec_1DEnu_nu.h" class MINERvA_CCinc_XSec_1DEnu_ratio : public JointMeas1D { public: MINERvA_CCinc_XSec_1DEnu_ratio(nuiskey samplekey); virtual ~MINERvA_CCinc_XSec_1DEnu_ratio() {}; void MakePlots(); // This is a dummy function as it is not required for the ratio (and does bad bad things) void ScaleEvents(){return;};; private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; // Need to have the distributions for the numerator and denominator stored separately MINERvA_CCinc_XSec_1DEnu_nu * NUM; MINERvA_CCinc_XSec_1DEnu_nu * DEN; Int_t nBins; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.cxx index 2175f90..7eddbf3 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 +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCinc_XSec_1Dx_nu.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCinc_XSec_1Dx_nu::MINERvA_CCinc_XSec_1Dx_nu(std::string name, std::string inputfile, std::string type) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCinc_XSec_1Dx_nu sample. \n" "Target: CH \n" "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 muon, any nucleons, and no " "other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(name, inputfile, type); fSettings.SetDescription(descrip); fSettings.SetXTitle("Reconstructed Bjorken x"); fSettings.SetYTitle("d#sigma/dx (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG/MASK", "FIX/DIAG"); fSettings.SetEnuRange(2.0, 20.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetTitle("MINERvA_CCinc_XSec_1Dx_nu"); target = ""; 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 == "") { NUIS_ABORT("target " << target << " was not found!"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- double binsx[7] = {0, 0.1, 0.3, 0.7, 0.9, 1.1, 1.5}; CreateDataHistogram(6, binsx); std::string basedir = FitPar::GetDataBase() + "/MINERvA/CCinc/"; std::string smearfilename = "CCinc_" + target + "_x_smear.csv"; SetSmearingMatrix(basedir + smearfilename, 6, 7); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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; return true; }; //******************************************************************** void MINERvA_CCinc_XSec_1Dx_nu::ScaleEvents() { //******************************************************************** this->ApplySmearingMatrix(); Measurement1D::ScaleEvents(); } diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.h b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.h index 95f88f4..57f1232 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.h +++ b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_nu.h @@ -1,48 +1,48 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCinc_1Dx_nu_H_SEEN #define MINERVA_CCinc_1Dx_nu_H_SEEN #include "Measurement1D.h" //******************************************************************** class MINERvA_CCinc_XSec_1Dx_nu : public Measurement1D { //******************************************************************** public: MINERvA_CCinc_XSec_1Dx_nu(std::string name, std::string inputfile, std::string type); virtual ~MINERvA_CCinc_XSec_1Dx_nu() {}; // Functions for handling each neut event void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void ScaleEvents(); double GetChi2(){return 0.0;}; private: double Enu_rec, ThetaMu, bjork_x; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx index f14aaca..8884c2f 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.cxx @@ -1,143 +1,127 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_CCinc_XSec_1Dx_ratio.h" #include "MINERvA_SignalDef.h" //******************************************************************** MINERvA_CCinc_XSec_1Dx_ratio::MINERvA_CCinc_XSec_1Dx_ratio(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCinc_XSec_1Dx_ratio sample. \n" "Target: CH \n" "Flux: MINERvA Forward Horn Current nue + nuebar \n" "Signal: Any event with 1 electron, any nucleons, and " "no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Reconstructed Bjorken x"); fSettings.SetYTitle("d#sigma/dx (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX/DIAG,FULL/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 20.0); // CCQELike plot information fSettings.SetTitle("MINERvA_CCinc_XSec_1Dx_ratio"); fIsRatio = true; nBins = 8; target = ""; if (fSettings.Found("name", "C12")) target = "C12"; else if (fSettings.Found("name", "Fe56")) target = "Fe56"; else if (fSettings.Found("name", "Pb208")) target = "Pb208"; else { NUIS_ABORT("target " << target << " was not found!"); } std::string basedir = FitPar::GetDataBase() + "/MINERvA/CCinc/"; fSettings.SetDataInput(basedir + "CCinc_" + target + "_CH_ratio_x_data.csv"); fSettings.SetCovarInput(basedir + "CCinc_" + target + "_CH_ratio_x_covar.csv"); FinaliseSampleSettings(); // Get parsed input files if (fSubInFiles.size() != 2) { NUIS_ABORT("MINERvA CCinc ratio requires input files in format: " "NUMERATOR;DENOMINATOR"); } std::string inFileNUM = fSubInFiles.at(0); std::string inFileDEN = fSubInFiles.at(1); // Scaling Setup --------------------------------------------------- // Ratio of sub classes so non needed // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); // This function forces in a factor of 1E76 to the covariance. // This cancels with the factor of 1E38 which is added to the data in the chi2 // calculation... Who said two wrongs don't make a right? SetCorrelationFromTextFile(fSettings.GetCovarInput()); // Setup Experiments ------------------------------------------------------- std::string type = samplekey.GetS("type"); NUM = new MINERvA_CCinc_XSec_1Dx_nu( "MINERvA_CCinc_XSec_1Dx_" + target + "_CH_NUM", inFileNUM, type); DEN = new MINERvA_CCinc_XSec_1Dx_nu( "MINERvA_CCinc_XSec_1Dx_" + target + "_CH_DEN", inFileDEN, type); NUM->SetNoData(); DEN->SetNoData(); // Add to chain for processing this->fSubChain.clear(); this->fSubChain.push_back(NUM); this->fSubChain.push_back(DEN); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; //******************************************************************** void MINERvA_CCinc_XSec_1Dx_ratio::MakePlots() { //******************************************************************** UInt_t sample = 0; for (std::vector::const_iterator expIter = this->fSubChain.begin(); expIter != this->fSubChain.end(); expIter++) { MeasurementBase *exp = static_cast(*expIter); if (sample == 0) this->NUM = static_cast(exp); else if (sample == 1) this->DEN = static_cast(exp); else break; sample++; } // Now make the ratio histogram TH1D *NUM_MC = (TH1D *)this->NUM->GetMCList().at(0)->Clone(); TH1D *DEN_MC = (TH1D *)this->DEN->GetMCList().at(0)->Clone(); - - for (int i = 0; i < nBins; ++i) { - double binVal = 0; - double binErr = 0; - - if (DEN_MC->GetBinContent(i + 1) && NUM_MC->GetBinContent(i + 1)) { - binVal = NUM_MC->GetBinContent(i + 1) / DEN_MC->GetBinContent(i + 1); - double fractErrNUM = - NUM_MC->GetBinError(i + 1) / NUM_MC->GetBinContent(i + 1); - double fractErrDEN = - DEN_MC->GetBinError(i + 1) / DEN_MC->GetBinContent(i + 1); - binErr = - binVal * sqrt(fractErrNUM * fractErrNUM + fractErrDEN * fractErrDEN); - } - - this->fMCHist->SetBinContent(i + 1, binVal); - this->fMCHist->SetBinError(i + 1, binErr); - } + this->fMCHist = PlotUtils::GetRatioPlot(NUM_MC, DEN_MC, fMCHist); return; } diff --git a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.h b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.h index d2bae7f..c3794f5 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.h +++ b/src/MINERvA/MINERvA_CCinc_XSec_1Dx_ratio.h @@ -1,52 +1,52 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_CCinc_XSec_1Dx_ratio_H_SEEN #define MINERVA_CCinc_XSec_1Dx_ratio_H_SEEN // Fit Includes #include "MeasurementBase.h" #include "JointMeas1D.h" #include "MINERvA_CCinc_XSec_1Dx_nu.h" class MINERvA_CCinc_XSec_1Dx_ratio : public JointMeas1D { public: MINERvA_CCinc_XSec_1Dx_ratio(nuiskey samplekey); virtual ~MINERvA_CCinc_XSec_1Dx_ratio() {}; void MakePlots(); // This is a dummy function as it is not required for the ratio (and does bad bad things) void ScaleEvents(){return;};; private: // This is a dummy, the signal is defined separately for each sample! bool isSignal(){return false;}; // Need to have the distributions for the numerator and denominator stored separately MINERvA_CCinc_XSec_1Dx_nu * NUM; MINERvA_CCinc_XSec_1Dx_nu * DEN; Int_t nBins; std::string target; }; #endif diff --git a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx index e9c9d47..23fb072 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx +++ b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.cxx @@ -1,153 +1,153 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MINERvA_SignalDef.h" #include "MINERvA_CCinc_XSec_2DEavq3_nu.h" //******************************************************************** MINERvA_CCinc_XSec_2DEavq3_nu::MINERvA_CCinc_XSec_2DEavq3_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MINERvA_CCinc_XSec_2DEavq3_nu sample. \n" \ "Target: CH \n" \ "Flux: MINERvA Medium Energy FHC numu \n" \ "Signal: CC-inclusive with theta < 20deg \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("q_{3} (GeV)"); fSettings.SetYTitle("E_{avail} (GeV)"); fSettings.SetZTitle("d^{2}#sigma/dq_{3}dE_{avail} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/MASK", "FIX/FULL"); fSettings.SetEnuRange(2.0, 6.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MINERvA_CCinc_XSec_2DEavq3_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MINERvA/CCEavq3/data_2D.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MINERvA/CCEavq3/covar_2D.txt" ); fSettings.SetMapInput( FitPar::GetDataBase() + "/MINERvA/CCEavq3/map_2D.txt" ); fSettings.DefineAllowedSpecies("numu"); 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"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-42 / (fNEvents + 0.)) / this->TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- Double_t binx[7] = {0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.8}; Double_t biny[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}; CreateDataHistogram(7, binx, 17, biny); SetDataValuesFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-42); SetMapValuesFromText( fSettings.GetMapInput() ); SetCholDecompFromTextFile( fSettings.GetCovarInput(), 67); ScaleCovar(1E-16); StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, fMapHist, 1E-38, false); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MINERvA_CCinc_XSec_2DEavq3_nu::FillEventVariables(FitEvent *event) { //******************************************************************** // Separate 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/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.h b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.h index 5b274e7..6c52724 100644 --- a/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.h +++ b/src/MINERvA/MINERvA_CCinc_XSec_2DEavq3_nu.h @@ -1,68 +1,68 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_XSEC_CCINC_2DEAVQ3_H_SEEN #define MINERVA_XSEC_CCINC_2DEAVQ3_H_SEEN #include "Measurement2D.h" //******************************************************************** class MINERvA_CCinc_XSec_2DEavq3_nu : public Measurement2D { //******************************************************************** public: // Constructor MINERvA_CCinc_XSec_2DEavq3_nu(nuiskey samplekey); // Destructor virtual ~MINERvA_CCinc_XSec_2DEavq3_nu() { // Remove all the content histograms // for (int i = 0; i < 9; i++) // delete this->fMCHist_content[i]; // delete everything /* delete difHist; */ /* delete evtsignalHist; */ /* delete fluxsignalHist; */ /* delete fMapHist; */ /* delete status; */ /* delete PDGHistogram; */ /* // Delete MODE histograms */ /* for (int i = 0; i < 60; i++) */ /* delete fMCHist_PDG[i]; */ return; }; // Required functions bool isSignal(FitEvent *nvect); void FillEventVariables(FitEvent *event); protected: // Cuts bool hadroncut; bool useq3true; bool splitMEC_PN_NN; }; #endif diff --git a/src/MINERvA/MINERvA_SignalDef.cxx b/src/MINERvA/MINERvA_SignalDef.cxx index 7511dc8..405312a 100644 --- a/src/MINERvA/MINERvA_SignalDef.cxx +++ b/src/MINERvA/MINERvA_SignalDef.cxx @@ -1,512 +1,521 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitUtils.h" #include "SignalDef.h" #include "MINERvA_SignalDef.h" #include "MINERvAUtils.h" namespace SignalDef { // ********************************* // MINERvA CC1pi+/- signal definition (2015 release) // Note: There is a 2016 release which is different to this (listed below), but // it is CCNpi+ and has a different W cut -// Note2: The W cut is implemented in the class implementation in MINERvA/ -// rather than here so we can draw events that don't pass the W cut (W cut is -// 1.4 GeV) -// Could possibly be changed for slight speed increase since less events -// would be used // // MINERvA signal is slightly different to MiniBooNE // // Exactly one negative muon // Exactly one charged pion (both + and -); however, there is a Michel e- // requirement but UNCLEAR IF UNFOLDED OR NOT (so don't know if should be // applied) // Exactly 1 charged pion exits (so + and - charge), however, has Michel // electron requirement, so look for + only here? // No restriction on neutral pions or other mesons // MINERvA has unfolded and not unfolded muon phase space for 2015 +// W_TRUE < 1.4 GeV // // Possible issues with the data: // 1) pi- is allowed in signal even when Michel cut included; most pi- is // efficiency corrected in GENIE 2) There is a T_pi < 350 MeV cut coming from // requiring a stopping pion; this is efficiency corrected in GENIE 3) There is // a 1.5 < Enu < 10.0 cut in signal definition 4) There is an angular muon cut // which is sometimes efficiency corrected (why we have bool isRestricted below) // // Nice things: // Much data given: with and without muon angle cuts and with and without shape // only data + covariance // bool isCC1pip_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool isRestricted) { // ********************************* // Signal is both pi+ and pi- // WARNING: PI- CONTAMINATION IS FULLY GENIE BECAUSE THE MICHEL TAG // First, make sure it's CCINC if (!isCCINC(event, 14, EnuMin, EnuMax)) return false; // Allow pi+/pi- int piPDG[] = {211, -211}; int nLeptons = event->NumFSLeptons(); int nPion = event->NumFSParticle(piPDG); // Check that the desired pion exists and is the only meson if (nPion != 1) return false; // Check that there is only one final state lepton if (nLeptons != 1) return false; // MINERvA released another CC1pi+ xsec without muon unfolding! // here the muon angle is < 20 degrees (seen in MINOS) TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; if (isRestricted) { double th_nu_mu = FitUtils::th(pmu, pnu) * 180. / M_PI; if (th_nu_mu >= 20) return false; } - // Extract Hadronic Mass - double hadMass = FitUtils::Wrec(pnu, pmu); + double hadMass = 9999.99; // Actual cut is True GENIE Ws! Arg.! Use gNtpcConv definition. #ifdef __GENIE_ENABLED__ if (event->fType == kGENIE) { EventRecord *gevent = static_cast(event->genie_event->event); const Interaction *interaction = gevent->Summary(); const Kinematics &kine = interaction->Kine(); double Ws = kine.W(true); - // std::cout << "Ws versus WRec = " << Ws << " vs " << hadMass << " " << - // kine.W(false) << std::endl; hadMass = Ws * 1000.0; } +#else + // Extract Hadronic Mass + // Cut is *INDEED* on Wtrue, not Wrec, so need to pass initial state nucleon too + // Either a proton or a nucleon + int nucPDG[] = {2212, 2112}; + // This won't work perfectly for 2p2h though + FitParticle *part = event->GetHMISParticle(nucPDG); + // There may not be an initial state nucleon if it's a coherent event + if (part == NULL) { + return 9999.999; + } + TLorentzVector pnuc = part->P4(); + hadMass = FitUtils::Wtrue(pnu, pmu, pnuc); + #endif if (hadMass > 1400.0) return false; return true; }; // Updated MINERvA 2017 Signal using Wexp and no restriction on angle bool isCC1pip_MINERvA_2017(FitEvent *event, double EnuMin, double EnuMax) { // Signal is both pi+ and pi- // WARNING: PI- CONTAMINATION IS FULLY GENIE BECAUSE THE MICHEL TAG // First, make sure it's CCINC if (!isCCINC(event, 14, EnuMin, EnuMax)) return false; // Allow pi+/pi- int piPDG[] = {211, -211}; int nLeptons = event->NumFSLeptons(); int nPion = event->NumFSParticle(piPDG); // Check that the desired pion exists and is the only meson if (nPion != 1) return false; // Check that there is only one final state lepton if (nLeptons != 1) return false; // Get Muon and Lepton Kinematics TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; // Extract Hadronic Mass + // This time it's Wrec, not Wtrue double hadMass = FitUtils::Wrec(pnu, pmu); // Cut on 2017 data is still 1.4 GeV if (hadMass > 1400.0) return false; return true; }; // ********************************* // MINERvA CCNpi+/- signal definition from 2016 publication // Different to CC1pi+/- listed above; additional has W < 1.8 GeV // // For notes on strangeness of signal definition, see CC1pip_MINERvA // // One negative muon // At least one charged pion // 1.5 < Enu < 10 // No restrictions on pi0 or other mesons or baryons // W_reconstructed (ignoring initial state motion) cut at 1.8 GeV // // Also writes number of pions (nPions) if studies on this want to be done... bool isCCNpip_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool isRestricted, bool isWtrue) { // ********************************* // First, make sure it's CCINC if (!isCCINC(event, 14, EnuMin, EnuMax)) return false; int nLeptons = event->NumFSLeptons(); // Write the number of pions to the measurement class... // Maybe better to just do that inside the class? int nPions = event->NumFSParticle(PhysConst::pdg_charged_pions); // Check that there is a pion! if (nPions == 0) return false; // Check that there is only one final state lepton if (nLeptons != 1) return false; // Need the muon and the neutrino to check angles and W TLorentzVector pnu = event->GetNeutrinoIn()->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; // MINERvA released some data with restricted muon angle // Here the muon angle is < 20 degrees (seen in MINOS) if (isRestricted) { double th_nu_mu = FitUtils::th(pmu, pnu) * 180. / M_PI; if (th_nu_mu >= 20.) return false; } // Lastly check the W cut (always at 1.8 GeV) double Wrec = FitUtils::Wrec(pnu, pmu) + 0.; // Actual cut is True GENIE Ws! Arg.! Use gNtpcConv definition. if (isWtrue) { #ifdef __GENIE_ENABLED__ if (event->fType == kGENIE) { GHepRecord *ghep = static_cast(event->genie_event->event); const Interaction *interaction = ghep->Summary(); const Kinematics &kine = interaction->Kine(); double Ws = kine.W(true); Wrec = Ws * 1000.0; // Say Wrec is Ws } #endif } if (Wrec > 1800. || Wrec < 0.0) return false; return true; }; //******************************************************************** bool isCCQEnumu_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool fullphasespace) { //******************************************************************** if (!isCCQELike(event, 14, EnuMin, EnuMax)) return false; TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; double ThetaMu = pnu.Vect().Angle(pmu.Vect()); double Enu_rec = FitUtils::EnuQErec(pmu, cos(ThetaMu), 34., true); // If Restricted phase space if (!fullphasespace && ThetaMu > 0.34906585) return false; // restrict energy range if (Enu_rec < EnuMin || Enu_rec > EnuMax) return false; return true; }; //******************************************************************** bool isCCQEnumubar_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool fullphasespace) { //******************************************************************** if (!isCCQELike(event, -14, EnuMin, EnuMax)) return false; TLorentzVector pnu = event->GetHMISParticle(-14)->fP; TLorentzVector pmu = event->GetHMFSParticle(-13)->fP; double ThetaMu = pnu.Vect().Angle(pmu.Vect()); double Enu_rec = FitUtils::EnuQErec(pmu, cos(ThetaMu), 30., true); // If Restricted phase space if (!fullphasespace && ThetaMu > 0.34906585) return false; // restrict energy range if (Enu_rec < EnuMin || Enu_rec > EnuMax) return false; return true; } //******************************************************************** bool isCCincLowRecoil_MINERvA(FitEvent *event, double EnuMin, double EnuMax) { //******************************************************************** if (!isCCINC(event, 14, EnuMin, EnuMax)) return false; // Need at least one muon if (event->NumFSParticle(13) < 1) return false; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; TLorentzVector pnu = event->GetHMISParticle(14)->fP; // Cut on muon angle greated than 20deg if (cos(pnu.Vect().Angle(pmu.Vect())) < 0.93969262078) return false; // Cut on muon energy < 1.5 GeV if (pmu.E() / 1000.0 < 1.5) return false; return true; } // Used in 2014 muon+proton analysis // Events with muon angles up to 70 degrees // One right sign muon, at least one proton, no pions // proton kinetic energies greater than 100 MeV bool isCC0pi1p_MINERvA(FitEvent *event, double enumin, double enumax) { bool signal = (isCC0pi(event, 14, enumin, enumax) && // Require numu CC0pi event HasProtonKEAboveThreshold(event, 110.0) && // With proton above threshold (event->GetHMFSMuon())->P3().Angle((event->GetNeutrinoIn())->P3()) * 180. / M_PI < 70 // And muon within production angle ); return signal; } // 2015 analysis just asks for 1pi0 and no pi+/pi- bool isCC1pi0_MINERvA_2015(FitEvent *event, double EnuMin, double EnuMax) { bool CC1pi0_anu = SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); return CC1pi0_anu; } // 2016 analysis just asks for 1pi0 and no other charged tracks. Half-open to // interpretation: we go with "charged tracks" meaning pions. You'll be forgiven // for thinking proton tracks should be included here too but we checked with // MINERvA bool isCC1pi0_MINERvA_2016(FitEvent *event, double EnuMin, double EnuMax) { bool CC1pi0_anu = SignalDef::isCC1pi(event, -14, 111, EnuMin, EnuMax); /* // Additionally look for charged proton track // Comment: This is _NOT_ in the signal definition but was tested bool HasProton = event->HasFSParticle(2212); if (CC1pi0_anu) { if (!HasProton) { return true; } else { return false; } } else { return false; } */ return CC1pi0_anu; } // 2016 analysis just asks for 1pi0 and no other charged tracks bool isCC1pi0_MINERvA_nu(FitEvent *event, double EnuMin, double EnuMax) { bool CC1pi0_nu = SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); return CC1pi0_nu; } //******************************************************************** bool isCC0pi_MINERvAPTPZ(FitEvent *event, int nuPDG, double emin, double emax) { //******************************************************************** // Check it's CCINC if (!SignalDef::isCCINC(event, nuPDG, emin, emax)) return false; // Make Angle Cut > 20.0 TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; double th_nu_mu = FitUtils::th(pmu, pnu) * 180. / M_PI; if (th_nu_mu >= 20.0) return false; int genie_n_muons = 0; int genie_n_mesons = 0; int genie_n_heavy_baryons_plus_pi0s = 0; int genie_n_photons = 0; for (unsigned int i = 0; i < event->NParticles(); ++i) { FitParticle *p = event->GetParticle(i); if (p->Status() != kFinalState) continue; int pdg = p->fPID; double energy = p->fP.E(); if (pdg == 13) { genie_n_muons++; } else if (pdg == 22 && energy > 10.0) { genie_n_photons++; } else if (abs(pdg) == 211 || abs(pdg) == 321 || abs(pdg) == 323 || pdg == 111 || pdg == 130 || pdg == 310 || pdg == 311 || pdg == 313 || abs(pdg) == 221 || abs(pdg) == 331) { genie_n_mesons++; } else if (pdg == 3112 || pdg == 3122 || pdg == 3212 || pdg == 3222 || pdg == 4112 || pdg == 4122 || pdg == 4212 || pdg == 4222 || pdg == 411 || pdg == 421 || pdg == 111) { genie_n_heavy_baryons_plus_pi0s++; } } if (genie_n_muons == 1 && genie_n_mesons == 0 && genie_n_heavy_baryons_plus_pi0s == 0 && genie_n_photons == 0) return true; + return false; } // ************************************************** // Section VI Event Selection of // https://journals.aps.org/prd/pdf/10.1103/PhysRevD.97.052002 Anti-neutrino // charged-current Post-FSI final states without // mesons, // prompt photons above nuclear deexcitation // energies heavy baryons protons above kinetic // energy of 120 MeV // Muon-neutrino angle of 20 degrees // Parallel muon momentum: 1.5 GeV < P|| < 15 GeV --- N.B. APPARENTLY NOT // INCLUDED, see below Transverse muon momentum: pT < 1.5 GeV --- N.B. // APPARENTLY NOT INCLUDED, see below bool isCC0pi_anti_MINERvAPTPZ(FitEvent *event, int nuPDG, double emin, double emax) { // ************************************************** // Check it's CCINC if (!SignalDef::isCCINC(event, nuPDG, emin, emax)) return false; TLorentzVector pnu = event->GetNeutrinoIn()->fP; TLorentzVector pmu = event->GetHMFSParticle(-13)->fP; // Make Angle Cut > 20.0 double th_nu_mu = FitUtils::th(pmu, pnu) * 180. / M_PI; if (th_nu_mu >= 20.0) return false; // Heidi Schellman (schellmh@science.oregonstate.edu) assured me that the p_t // and p_z (or p_||) cuts aren't actually implemented as a signal definition: // they're only implemented in the binning for p_t and p_z (but not Q2QE and // EnuQE) /* // Cut on pT and pZ Double_t px = pmu.X()/1.E3; Double_t py = pmu.Y()/1.E3; Double_t pt = sqrt(px*px+py*py); // Don't want to assume the event generators all have neutrino coming along z // pz is muon momentum projected onto the neutrino direction Double_t pz = pmu.Vect().Dot(pnu.Vect()*(1.0/pnu.Vect().Mag()))/1.E3; if (pz > 15 || pz < 1.5) return false; if (pt > 1.5) return false; */ // Find if there are any protons above 120 MeV kinetic energy if (HasProtonKEAboveThreshold(event, 120.0)) return false; // Particle counters int genie_n_muons = 0; int genie_n_mesons = 0; int genie_n_heavy_baryons_plus_pi0s = 0; int genie_n_photons = 0; // Loop over the particles in the event and count them up for (unsigned int i = 0; i < event->NParticles(); ++i) { FitParticle *p = event->GetParticle(i); if (p->Status() != kFinalState) continue; int pdg = p->fPID; double energy = p->fP.E(); // Any charged muons if (abs(pdg) == 13) { genie_n_muons++; // De-excitation photons } else if (pdg == 22 && energy > 10.0) { genie_n_photons++; // Mesons } else if (abs(pdg) == 211 || abs(pdg) == 321 || abs(pdg) == 323 || pdg == 111 || pdg == 130 || pdg == 310 || pdg == 311 || pdg == 313 || abs(pdg) == 221 || abs(pdg) == 331) { genie_n_mesons++; // Heavy baryons and pi0s } else if (abs(pdg) == 3112 || abs(pdg) == 3122 || abs(pdg) == 3212 || abs(pdg) == 3222 || abs(pdg) == 4112 || abs(pdg) == 4122 || abs(pdg) == 4212 || abs(pdg) == 4222 || abs(pdg) == 411 || abs(pdg) == 421 || abs(pdg) == 111) { genie_n_heavy_baryons_plus_pi0s++; } } // Look for one muon with no mesons, heavy baryons or deexcitation photons if (genie_n_muons == 1 && genie_n_mesons == 0 && genie_n_heavy_baryons_plus_pi0s == 0 && genie_n_photons == 0) return true; return false; } // MINERvA CC0pi transverse variables signal defintion bool isCC0piNp_MINERvA_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; // Muon momentum cuts if (pmu.Vect().Mag() < 1500 || pmu.Vect().Mag() > 10000) return false; // Muon angle cuts if (pmu.Vect().Angle(pnu.Vect()) > (M_PI / 180.0) * 20.0) return false; const double ctheta_cut = cos((M_PI / 180.0) * 70.0); //Did you find a proton in the PS? if (MINERvAUtils::GetProtonInRange(event, 450, 1200, ctheta_cut).E() == 0) return false; return true; }; } // namespace SignalDef diff --git a/src/MINERvA/MINERvA_SignalDef.h b/src/MINERvA/MINERvA_SignalDef.h index f51ef54..0379252 100644 --- a/src/MINERvA/MINERvA_SignalDef.h +++ b/src/MINERvA/MINERvA_SignalDef.h @@ -1,101 +1,101 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINERVA_SIGNALDEF_H_SEEN #define MINERVA_SIGNALDEF_H_SEEN #include "FitEvent.h" namespace SignalDef { // ********************************* /// MINERvA CC1pi+/- signal definition (2015 release) /// Note: There is a 2016 release which is different to this (listed below), /// but /// it is CCNpi+ and has a different W cut /// Note2: The W cut is implemented in the class implementation in MINERvA/ /// rather than here so we can draw events that don't pass the W cut (W cut is /// 1.4 GeV) /// Could possibly be changed for slight speed increase since less events /// would be used /// /// MINERvA signal is slightly different to MiniBooNE /// /// Exactly one negative muon /// Exactly one charged pion (both + and -); however, there is a Michel e- /// requirement but UNCLEAR IF UNFOLDED OR NOT (so don't know if should be /// applied) /// Exactly 1 charged pion exits (so + and - charge), however, has Michel /// electron requirement, so look for + only here? /// No restriction on neutral pions or other mesons /// MINERvA has unfolded and not unfolded muon phase space for 2015 /// /// Possible problems: /// 1) Should there be a pi+ only cut implemented due to Michel requirement, or /// is pi- events filled from MC? /// 2) There is a T_pi < 350 MeV cut coming from requiring a stopping pion so /// the /// Michel e is seen, this is also unclear if it's unfolded so any pion is OK /// /// Nice things: /// Much data given: with and without muon angle cuts and with and without shape /// only data + covariance bool isCC1pip_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool isRestricted = false); bool isCC1pip_MINERvA_2017(FitEvent *event, double EnuMin, double EnuMax); // ********************************* /// MINERvA CCNpi+/- signal definition from 2016 publication /// Different to CC1pi+/- listed above; additional has W < 1.8 GeV /// /// Still asks for a Michel e and still unclear if this is unfolded or not /// Says stuff like "requirement that a Michel e isolates a subsample that is /// more nearly a pi+ prodution", yet the signal definition is both pi+ and pi-? /// /// One negative muon /// At least one charged pion /// 1.5 < Enu < 10 /// No restrictions on pi0 or other mesons or baryons /// /// Also writes number of pions (nPions) if studies on this want to be done... bool isCCNpip_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool isRestricted = false, bool isWtrue=false); bool isCCQEnumu_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool fullphasespace = true); bool isCCQEnumubar_MINERvA(FitEvent *event, double EnuMin, double EnuMax, bool fullphasespace = true); bool isCCincLowRecoil_MINERvA(FitEvent *event, double EnuMin, double EnuMax); bool isCC0pi1p_MINERvA(FitEvent *event, double enumin, double enumax); bool isCC1pi0_MINERvA_2015(FitEvent *event, double EnuMin, double EnuMax); bool isCC1pi0_MINERvA_2016(FitEvent *event, double EnuMin, double EnuMax); bool isCC1pi0_MINERvA_nu(FitEvent *event, double EnuMin, double EnuMax); bool isCC0piNp_MINERvA_STV(FitEvent *event, double EnuMin, double EnuMax); bool isCC0pi_MINERvAPTPZ(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isCC0pi_anti_MINERvAPTPZ(FitEvent* event, int nuPDG, double EnuMin = 0, double EnuMax = 0); } #endif diff --git a/src/MicroBooNE/CMakeLists.txt b/src/MicroBooNE/CMakeLists.txt index e5b18d4..eddcb78 100644 --- a/src/MicroBooNE/CMakeLists.txt +++ b/src/MicroBooNE/CMakeLists.txt @@ -1,48 +1,48 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES MicroBooNE_CCInc_XSec_2DPcos_nu.cxx ) set(HEADERFILES MicroBooNE_CCInc_XSec_2DPcos_nu.h ) set(LIBNAME expMicroBooNE) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/MicroBooNE) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.cxx b/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.cxx index 1105ab2..f0db2c6 100644 --- a/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.cxx +++ b/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.cxx @@ -1,268 +1,278 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MicroBooNE_CCInc_XSec_2DPcos_nu.h" namespace { // Mapping of polybins to costheta slices int kDUMMY = std::numeric_limits::max(); static size_t const NRows = 9; static size_t const NRowBins[] = {5, 5, 5, 4, 4, 4, 5, 5, 5}; static int const PolyBinIDs[NRows][5] = {{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, kDUMMY}, {20, 21, 22, 23, kDUMMY}, {24, 25, 26, 27, kDUMMY}, {28, 29, 30, 31, 32}, {33, 34, 35, 36, 37}, {38, 39, 40, 41, 42}}; // Bin edges static double const EdgesCt[] = {-1.00, -0.50, 0.00, 0.27, 0.45, 0.62, 0.76, 0.86, 0.94, 1.00}; static double const EdgesP[NRows][6] = { {0.00, 0.18, 0.30, 0.45, 0.77, 2.50}, {0.00, 0.18, 0.30, 0.45, 0.77, 2.50}, {0.00, 0.18, 0.30, 0.45, 0.77, 2.50}, {0.00, 0.30, 0.45, 0.77, 2.50, (double)kDUMMY}, {0.00, 0.30, 0.45, 0.77, 2.50, (double)kDUMMY}, {0.00, 0.30, 0.45, 0.77, 2.50, (double)kDUMMY}, {0.00, 0.30, 0.45, 0.77, 1.28, 2.50}, {0.00, 0.30, 0.45, 0.77, 1.28, 2.50}, {0.00, 0.30, 0.45, 0.77, 1.28, 2.50}}; } // namespace //******************************************************************** MicroBooNE_CCInc_XSec_2DPcos_nu::MicroBooNE_CCInc_XSec_2DPcos_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MicroBooNE_CCInc_XSec_2DPcos_nu sample. \n" "Target: Ar \n" "Flux: BNB FHC numu \n" "Signal: CC inclusive \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("P_{#mu}^{reco} (GeV)"); - fSettings.SetYTitle("cos#theta_{#mu}^{reco}"); - fSettings.SetZTitle( - "d^{2}#sigma/dP_{#mu}^{reco}dcos#theta_{#mu}^{reco} (cm^{2}/GeV)"); + fSettings.SetXTitle("p_{#mu}^{reco} (GeV)-cos#theta_{#mu}^{reco}"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}^{reco}dcos#theta_{#mu}^{reco} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("Ar"); // Plot information fSettings.SetTitle("MicroBooNE_CCInc_XSec_2DPcos_nu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width") / (fNEvents + 0.)) * 1E-38 / (TotalIntegratedFlux())); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + + fSaveFine = false; }; bool MicroBooNE_CCInc_XSec_2DPcos_nu::isSignal(FitEvent *event) { return SignalDef::isCCINC(event, 14, EnuMin, EnuMax); }; void MicroBooNE_CCInc_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; }; void MicroBooNE_CCInc_XSec_2DPcos_nu::FillHistograms() { Measurement1D::FillHistograms(); if (Signal) { fMCHist_Fine2D->Fill(fXVar, fYVar, Weight); FillMCSlice(fXVar, fYVar, Weight); } } void MicroBooNE_CCInc_XSec_2DPcos_nu::ConvertEventRates() { for (size_t i = 0; i < fMCHist_Slices.size(); i++) { fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion Measurement1D::ConvertEventRates(); // Apply MC truth -> reco smearing std::vector slices_true; for (size_t i = 0; i < fMCHist_Slices.size(); i++) { TH1D *h = (TH1D *)fMCHist_Slices[i]->Clone( TString(fMCHist_Slices[i]->GetName()) + "_true"); slices_true.push_back(h); } for (int ireco = 1; ireco < fMCHist->GetNbinsX() + 1; ireco++) { double total = 0; for (int itrue = 1; itrue < fMCHist->GetNbinsX() + 1; itrue++) { std::pair idx = fPolyBinMap[itrue]; TH1D *h = slices_true[idx.first]; total += h->GetBinContent(idx.second + 1) * h->GetBinWidth(idx.second + 1) * fSmearingMatrix->operator()(ireco - 1, itrue - 1); } std::pair idx = fPolyBinMap[ireco]; TH1D *h = fMCHist_Slices[idx.first]; h->SetBinContent(idx.second + 1, total / h->GetBinWidth(idx.second + 1)); } for (size_t i = 0; i < slices_true.size(); i++) { delete slices_true[i]; } // Scale MC slices also by their width in Y for (size_t i = 0; i < fMCHist_Slices.size(); i++) { float w = EdgesCt[i + 1] - EdgesCt[i]; fMCHist_Slices[i]->Scale(1.0 / w); } // Convert into 1D list fMCHist->Reset(); int bincount = 0; for (size_t i = 0; i < fDataHist_Slices.size(); i++) { for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fMCHist->SetBinContent(bincount + 1, fMCHist_Slices[i]->GetBinContent(j + 1)); fMCHist->SetBinError(bincount + 1, fMCHist_Slices[i]->GetBinError(j + 1)); bincount++; } } } void MicroBooNE_CCInc_XSec_2DPcos_nu::FillMCSlice(double x, double y, double w) { if (y >= -1.00 && y < -0.50) fMCHist_Slices[0]->Fill(x, w); else if (y >= -0.50 && y < 0.00) fMCHist_Slices[1]->Fill(x, w); else if (y >= 0.00 && y < 0.27) fMCHist_Slices[2]->Fill(x, w); else if (y >= 0.27 && y < 0.45) fMCHist_Slices[3]->Fill(x, w); else if (y >= 0.45 && y < 0.62) fMCHist_Slices[4]->Fill(x, w); else if (y >= 0.62 && y < 0.76) fMCHist_Slices[5]->Fill(x, w); else if (y >= 0.76 && y < 0.86) fMCHist_Slices[6]->Fill(x, w); else if (y >= 0.86 && y < 0.94) fMCHist_Slices[7]->Fill(x, w); else if (y >= 0.94 && y <= 1.00) fMCHist_Slices[8]->Fill(x, w); } void MicroBooNE_CCInc_XSec_2DPcos_nu::SetHistograms() { + + std::string sample_name = fSettings.GetName(); + // Read in 1D Data Histograms fInputFile = new TFile((FitPar::GetDataBase() + "/MicroBooNE/CCinc/microboone_numu_cc_inclusive.root") .c_str()); // Read in 1D Data fDataHist = (TH1D *)fInputFile->Get("xsec_data"); - fDataHist->SetName("MicroBooNE_CCInc_XSec_2DPcos_nu_DATA"); + fDataHist->SetNameTitle(Form("%s_data", sample_name.c_str()), + Form("%s_data%s", sample_name.c_str(), + fSettings.GetFullTitles().c_str())); fDataHist->Scale(1e-38); - - fMCHist_Fine2D = new TH2D("MicroBooNE_CCInc_XSec_2DPcos_nu_Fine2D", - "MicroBooNE_CCInc_XSec_2DPcos_nu_Fine2D", 400, 0.0, - 2.5, 100, -1.0, 1.0); + + fMCHist_Fine2D = new TH2D(Form("%s_MC_FINE_2D", sample_name.c_str()), + Form("%s_MC_FINE_2D; p_{#mu}^{reco} (GeV); cos#theta_{#mu}^{reco};%s", + sample_name.c_str(), fSettings.GetYTitle().c_str()), + 400, 0.0, 2.5, 100, -1.0, 1.0); SetAutoProcessTH1(fMCHist_Fine2D); // Load covariance matrix - TH2D *tempcov = (TH2D *)fInputFile->Get("covariance_matrix"); + TH2D *tempcov = (TH2D*)fInputFile->Get("covariance_matrix"); fFullCovar = new TMatrixDSym(fDataHist->GetNbinsX()); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = tempcov->GetBinContent(i + 1, j + 1); } } fDecomp = StatUtils::GetDecomp(fFullCovar); // Load smearing matrix TH2D *tempsmear = (TH2D *)fInputFile->Get("smearing_matrix"); fSmearingMatrix = new TMatrixDSym(fDataHist->GetNbinsX()); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fSmearingMatrix)(i, j) = tempsmear->GetBinContent(i + 1, j + 1); } } for (size_t i = 0; i < NRows; i++) { for (size_t j = 0; j < NRowBins[i]; j++) { int id = PolyBinIDs[i][j]; fPolyBinMap[id] = std::make_pair(i, j); } } // Split 1D data into cos(theta) slices for (size_t i = 0; i < NRows; i++) { - TString name = Form("MicroBooNE_CCInc_XSec_2DPcos_nu_data_Slice%lu", i); - TH1D *h = new TH1D(name, name, NRowBins[i], EdgesP[i]); + TString name = Form("%s_data_Slice%lu", sample_name.c_str(), i); + TString title = Form("%s_data_Slice%lu; p_{#mu}^{reco} (GeV);%s", + sample_name.c_str(), i, fSettings.GetYTitle().c_str()); + TH1D *h = new TH1D(name, title, NRowBins[i], EdgesP[i]); h->Sumw2(); fDataHist_Slices.push_back(h); for (size_t j = 0; j < NRowBins[i]; j++) { int binid = PolyBinIDs[i][j]; h->SetBinContent(j + 1, fDataHist->GetBinContent(binid)); float err = sqrt((*fFullCovar)(binid - 1, binid - 1)) * 1e-38; h->SetBinError(j + 1, err); fDataHist->SetBinError(binid, err); } fMCHist_Slices.push_back((TH1D *)h->Clone()); - name = Form("MicroBooNE_CCInc_XSec_2DPcos_nu_MC_Slice%lu", i); - fMCHist_Slices[i]->SetNameTitle(name, name); + name = Form("%s_MC_Slice%lu", sample_name.c_str(), i); + title = Form("%s_MC_Slice%lu; p_{#mu}^{reco} (GeV);%s", + sample_name.c_str(), i, fSettings.GetYTitle().c_str()); + fMCHist_Slices[i]->SetNameTitle(name, title); fMCHist_Slices[i]->Reset(); SetAutoProcessTH1(fDataHist_Slices[i], kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); } } diff --git a/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.h b/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.h index a9c9f36..0c4eb22 100644 --- a/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.h +++ b/src/MicroBooNE/MicroBooNE_CCInc_XSec_2DPcos_nu.h @@ -1,64 +1,64 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MICROBOONE_CCINC_2DPCOS_NU_H_SEEN #define MICROBOONE_CCINC_2DPCOS_NU_H_SEEN #include "Measurement1D.h" #include "MeasurementVariableBox2D.h" #include "TH2Poly.h" class MicroBooNE_CCInc_XSec_2DPcos_nu : public Measurement1D { public: /// Basic Constructor. MicroBooNE_CCInc_XSec_2DPcos_nu(nuiskey samplekey); /// Virtual Destructor ~MicroBooNE_CCInc_XSec_2DPcos_nu(){}; /// Numu CCinc Signal Definition bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. void SetHistograms(); /// Bin Pmu CosThetaMu void FillEventVariables(FitEvent *customEvent); /// Smear and build 1D MC histogram from slices void ConvertEventRates(); // Fill Histograms void FillHistograms(); private: TFile *fInputFile; TH2D *fMCHist_Fine2D; TMatrixDSym *fSmearingMatrix; std::map > fPolyBinMap; std::vector fMCHist_Slices; std::vector fDataHist_Slices; void FillMCSlice(double x, double y, double w); }; #endif diff --git a/src/MiniBooNE/CMakeLists.txt b/src/MiniBooNE/CMakeLists.txt index f2f69dd..2d12aac 100644 --- a/src/MiniBooNE/CMakeLists.txt +++ b/src/MiniBooNE/CMakeLists.txt @@ -1,97 +1,97 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx MiniBooNE_CCQE_XSec_1DEnu_nu.cxx MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx MiniBooNE_CCQE_XSec_1DQ2_nu.cxx MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx MiniBooNE_CCQE_XSec_2DTcos_nu.cxx MiniBooNE_CC1pip_XSec_1DTu_nu.cxx MiniBooNE_NCEL_XSec_Treco_nu.cxx MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx MiniBooNE_NC1pi0_XSec_1Dppi0_nu.cxx MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.cxx MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.cxx MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.cxx ) set(HEADERFILES MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h MiniBooNE_CC1pi0_XSec_1DEnu_nu.h MiniBooNE_CCQE_XSec_1DEnu_nu.h MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h MiniBooNE_CC1pi0_XSec_1DQ2_nu.h MiniBooNE_CCQE_XSec_1DQ2_antinu.h MiniBooNE_CC1pi0_XSec_1DTu_nu.h MiniBooNE_CC1pip_XSec_1DEnu_nu.h MiniBooNE_CCQE_XSec_1DQ2_nu.h MiniBooNE_CC1pip_XSec_1DQ2_nu.h MiniBooNE_CCQE_XSec_2DTcos_antinu.h MiniBooNE_CC1pip_XSec_1DTpi_nu.h MiniBooNE_CCQE_XSec_2DTcos_nu.h MiniBooNE_CC1pip_XSec_1DTu_nu.h MiniBooNE_NCEL_XSec_Treco_nu.h MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h MiniBooNE_Boxes.h ) set(LIBNAME expMiniBooNE) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/MiniBooNE) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx index 099eb86..3987bd4 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.cxx @@ -1,97 +1,100 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1DEnu_nu.h" //******************************************************************** MiniBooNE_CC1pi0_XSec_1DEnu_nu::MiniBooNE_CC1pi0_XSec_1DEnu_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pi0_XSec_1DEnu_nu sample. \n" "Target: CH2 \n" "Flux: MiniBooNE Forward Horn Current \n" "Signal: Any event with 1 muon, 1 neutral pion, any " "nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.5, 2.0); fSettings.DefineAllowedTargets("C,H"); + // Because this dataset seems to have a broken covariance, add a strong warning + NUIS_ERR(WRN, "Sample " << fSettings.GetName() << " is known to give nonsensical chi-square values!"); + // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pi0_XSec_1DEnu_nu"); fSettings.SetDataInput(FitPar::GetDataBase() + "MiniBooNE/CC1pi0/totalxsec_edit.txt"); fSettings.SetCovarInput(FitPar::GetDataBase() + "MiniBooNE/CC1pi0/totalxsec_covar.txt"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (14.08); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCorrelationFromTextFile(fSettings.GetCovarInput()); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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 // // The signal definition is: // Exactly one negative muon // 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_1DEnu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.h index c4ed8d2..cc9cf32 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DEnu_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PI0_XSEC_1DENU_NU_H_SEEN #define MINIBOONE_CC1PI0_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pi0_XSec_1DEnu_nu : public Measurement1D { public: MiniBooNE_CC1pi0_XSec_1DEnu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pi0_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx index 4316e32..a7ad506 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.cxx @@ -1,82 +1,82 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1DQ2_nu.h" //******************************************************************** MiniBooNE_CC1pi0_XSec_1DQ2_nu::MiniBooNE_CC1pi0_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pi0_XSec_1DQ2_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{CC#pi}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.5, 2.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pi0_XSec_1DQ2_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdq2_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdq2_covar.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MiniBooNE_CC1pi0_XSec_1DQ2_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double q2 = -1*(Pnu-Pmu).Mag2()/(1.E6); fXVar = q2; 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_1DQ2_nu.h b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.h index 274622d..4cb2c5e 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DQ2_nu.h @@ -1,39 +1,39 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PI0_XSEC_1DQ2_NU_H_SEEN #define MINIBOONE_CC1PI0_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "FitUtils.h" #include "SignalDef.h" class MiniBooNE_CC1pi0_XSec_1DQ2_nu : public Measurement1D { public: MiniBooNE_CC1pi0_XSec_1DQ2_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pi0_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx index 07df183..ad1ca90 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.cxx @@ -1,84 +1,84 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1DTu_nu.h" //******************************************************************** MiniBooNE_CC1pi0_XSec_1DTu_nu::MiniBooNE_CC1pi0_XSec_1DTu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pi0_XSec_1DTu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#mu} (GeV)"); - fSettings.SetYTitle("d#sigma/dE_{#mu} (cm^{2}/GeV^{2}/CH_{2})"); + fSettings.SetYTitle("d#sigma/dE_{#mu} (cm^{2}/GeV/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.5, 2.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pi0_XSec_1DTu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdemu_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdemu_covar.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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); 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_1DTu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.h index 9f76ccc..c714274 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1DTu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PI0_XSEC_1DTU_NU_H_SEEN #define MINIBOONE_CC1PI0_XSEC_1DTU_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pi0_XSec_1DTu_nu : public Measurement1D { public: MiniBooNE_CC1pi0_XSec_1DTu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pi0_XSec_1DTu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx index 757046a..7b05d21 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h" //******************************************************************** MiniBooNE_CC1pi0_XSec_1Dcosmu_nu::MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pi0_XSec_1Dcosmu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#mu}"); fSettings.SetYTitle("d#sigma/dcos#theta_{#mu} (cm^{2}/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.5, 2.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pi0_XSec_1Dcosmu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdcosmu_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdcosmu_covar.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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+ 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_1Dcosmu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h index 7e6a291..e9a5689 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcosmu_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PI0_XSEC_1DCOSMU_NU_H_SEEN #define MINIBOONE_CC1PI0_XSEC_1DCOSMU_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pi0_XSec_1Dcosmu_nu : public Measurement1D { public: MiniBooNE_CC1pi0_XSec_1Dcosmu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pi0_XSec_1Dcosmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx index a0ad302..a0c995a 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.cxx @@ -1,85 +1,85 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h" //******************************************************************** MiniBooNE_CC1pi0_XSec_1Dcospi0_nu::MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pi0_XSec_1Dcospi0_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#pi^{0}}"); fSettings.SetYTitle("d#sigma/dcos#theta_{#pi^{0}} (cm^{2}/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.5, 2.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pi0_XSec_1Dcospi0_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdcospi_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/CC1pi0/dxsecdcospi_covar.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCorrelationFromTextFile( fSettings.GetCovarInput() ); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_1Dcospi0_nu.h b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h index 3780d45..46507d3 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dcospi0_nu.h @@ -1,37 +1,37 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PI0_XSEC_1DCOSPI0_NU_H_SEEN #define MINIBOONE_CC1PI0_XSEC_1DCOSPI0_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pi0_XSec_1Dcospi0_nu : public Measurement1D { public: MiniBooNE_CC1pi0_XSec_1Dcospi0_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pi0_XSec_1Dcospi0_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx index 09919a9..b396082 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.cxx @@ -1,91 +1,91 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h" MiniBooNE_CC1pi0_XSec_1Dppi0_nu::MiniBooNE_CC1pi0_XSec_1Dppi0_nu(nuiskey confkey) { // 1. Initalise sample Settings (all overrideable in cardfile) -------------- fSettings = LoadSampleSettings(confkey); // Must go first fSettings.SetDescription(""); - fSettings.SetXTitle("p_{#pi^{0}} (GeV/c)"); + fSettings.SetXTitle("p_{#pi^{0}} (GeV)"); fSettings.SetYTitle("d#sigma/dp_{#pi^{0}} (cm^{2}/GeV/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.5, 2.0); fSettings.SetSuggestedFlux( FitPar::GetDataBase() + "/MiniBooNE/ccqe/mb_fhc_flux.root"); fSettings.SetTitle("MiniBooNE #nu_#mu CC1#pi^{0} on CH"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pi0/dxsecdppi_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pi0/dxsecdppi_covar.txt" ); fSettings.DefineAllowedSpecies("numu"); fSettings.DefineAllowedTargets("C,H"); FinaliseSampleSettings(); // Must go after all settings // 2. Set Scale Factor ------------------------------------------------------- fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (14.08) / TotalIntegratedFlux("width"); // 3. Plot Setup ------------------------------------------------------- SetDataValues( fSettings.GetDataInput() ); SetCovarMatrixFromCorrText( fSettings.GetCovarInput(), fDataHist->GetNbinsX() ); SetShapeCovar(); // Create a Target Species Stack copying data fTargetStack = new TargetTypeStack( fSettings.Name() + "_TGT", "Target Contributions" + fSettings.PlotTitles(), fDataHist); SetAutoProcessTH1(fTargetStack); // Final MC Setup // Must go last FinaliseMeasurement(); }; 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); fXVar = p_pi0; fTargetPDG = event->fTargetPDG; return; }; //******************************************************************** bool MiniBooNE_CC1pi0_XSec_1Dppi0_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pi(event, 14, 111, EnuMin, EnuMax); } //******************************************************************** void MiniBooNE_CC1pi0_XSec_1Dppi0_nu::FillExtraHistograms(MeasurementVariableBox* box, double weight){ //******************************************************************** if (!Signal) return; fTargetStack->Fill( fTargetPDG, fXVar, weight ); } diff --git a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h index 6b45035..559bd11 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pi0_XSec_1Dppi0_nu.h @@ -1,40 +1,40 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PI0_XSEC_1DPPI0_NU_H_SEEN #define MINIBOONE_CC1PI0_XSEC_1DPPI0_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pi0_XSec_1Dppi0_nu : public Measurement1D { public: MiniBooNE_CC1pi0_XSec_1Dppi0_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pi0_XSec_1Dppi0_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* box, double weight); private: int fTargetPDG; TargetTypeStack* fTargetStack; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx index 03e177e..c5d5390 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.cxx @@ -1,110 +1,110 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DEnu_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_1DEnu_nu::MiniBooNE_CC1pip_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_1DEnu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (MeV)"); fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pip_XSec_1DEnu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pip/ccpipXSec_enu.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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 // 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_1DEnu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.h index de8ff7a..728a3ab 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DEnu_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_1DENU_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pip_XSec_1DEnu_nu : public Measurement1D { public: MiniBooNE_CC1pip_XSec_1DEnu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx index 403e066..8eb4d4d 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.cxx @@ -1,84 +1,84 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DQ2_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_1DQ2_nu::MiniBooNE_CC1pip_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_1DQ2_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2}_{CC#pi} (GeV^{2})"); - fSettings.SetYTitle("d#sigma/dQ_{CC#pi^{+}}^{2} (cm^{2}/MeV^{2}/CH_{2})"); + fSettings.SetXTitle("Q^{2}_{CC#pi^{+}} (GeV^{2})"); + fSettings.SetYTitle("d#sigma/dQ_{CC#pi^{+}}^{2} (cm^{2}/GeV^{2}/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); // No energy range given in v1r0 fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE CC1pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pip/ccpipXSec_Q2.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon 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 // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MiniBooNE_CC1pip_XSec_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 MiniBooNE CC1pi+ double q2 = -1*(Pnu-Pmu).Mag2()/1e6; fXVar = q2; 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_1DQ2_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.h index 5e64e6d..3c2c9de 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DQ2_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_1DQ2_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_1DQ2_NU_H_SEEN // Fit Includes #include "Measurement1D.h" class MiniBooNE_CC1pip_XSec_1DQ2_nu : public Measurement1D { public: MiniBooNE_CC1pip_XSec_1DQ2_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx index 1becf55..e591cf4 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DTpi_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_1DTpi_nu::MiniBooNE_CC1pip_XSec_1DTpi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_1DTpi_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#pi} (MeV)"); - fSettings.SetYTitle("d#sigma/dT_{#pi^{+}}} (cm^{2}/MeV/CH_{2})"); + fSettings.SetYTitle("d#sigma/dT_{#pi} (cm^{2}/MeV/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pip_XSec_1DTpi_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pip/ccpipXSec_KEpi.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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_1DTpi_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.h index 95e12e9..b19b583 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTpi_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_1DTPI_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_1DTPI_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pip_XSec_1DTpi_nu : public Measurement1D { public: MiniBooNE_CC1pip_XSec_1DTpi_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_1DTpi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx index 2979051..1cb866b 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.cxx @@ -1,84 +1,84 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_1DTu_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_1DTu_nu::MiniBooNE_CC1pip_XSec_1DTu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_1DTu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#mu} (MeV)"); fSettings.SetYTitle("d#sigma/dT_{#mu} (cm^{2}/MeV/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CC1pip_XSec_1DTu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/CC1pip/ccpipXSec_KEmu.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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_1DTu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.h index c8d2137..e3a1795 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_1DTu_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_1DTU_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_1DTU_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CC1pip_XSec_1DTu_nu : public Measurement1D { public: MiniBooNE_CC1pip_XSec_1DTu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_1DTu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx index b56c78c..a4e0f51 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.cxx @@ -1,85 +1,85 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_2DQ2Enu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("E_{#nu} (MeV); Q^{2} (MeV^{2}/c^{4})"); - fSettings.SetYTitle("Q^{2} (MeV^{2}/c^{4})"); - fSettings.SetZTitle(" d#sigma(E_{#nu})/dQ^{2} (cm^{2}/(MeV^{2}/c^{4})/CH_{2})"); + fSettings.SetXTitle("E_{#nu} (MeV)"); + fSettings.SetYTitle("Q^{2} (MeV^{2})"); + fSettings.SetZTitle("d#sigma(E_{#nu})/dQ^{2} (cm^{2}/MeV^{2}/CH_{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_CC1pip_XSec_2DQ2Enu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pip/ccpipXSecs.root;QSQVENUXSec" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (14.08); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** void MiniBooNE_CC1pip_XSec_2DQ2Enu_nu::FillEventVariables(FitEvent *event) { //******************************************************************** if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double Enu = Pnu.E(); double Q2 = -1*(Pnu-Pmu).Mag2(); 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_2DQ2Enu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h index d1e505f..dee292d 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DQ2Enu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_2DQ2ENU_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_2DQ2ENU_NU_H_SEEN #include "Measurement2D.h" class MiniBooNE_CC1pip_XSec_2DQ2Enu_nu : public Measurement2D { public: MiniBooNE_CC1pip_XSec_2DQ2Enu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_2DQ2Enu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx index a6de49f..4a301e8 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_2DTpiCospi_nu::MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_2DTpiCospi_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#pi} (MeV)"); fSettings.SetYTitle("cos#theta_{#pi}"); fSettings.SetZTitle("d^{2}#sigma/dT_{#pi}dcos#theta_{#pi} (cm^{2}/MeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_CC1pip_XSec_2DTpiCospi_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pip/ccpipXSecs.root;PICTVKEXSec" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_2DTpiCospi_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h index 287fa00..e61b611 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiCospi_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_2DTPICOSPI_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_2DTPICOSPI_NU_H_SEEN #include "Measurement2D.h" class MiniBooNE_CC1pip_XSec_2DTpiCospi_nu : public Measurement2D { public: MiniBooNE_CC1pip_XSec_2DTpiCospi_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_2DTpiCospi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx index 35300f1..90cc90c 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_2DTpiEnu_nu::MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_2DTpiEnu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (MeV)"); fSettings.SetYTitle("T_{#pi} (MeV)"); fSettings.SetZTitle("d#sigma(E_{#nu})/dT_{#pi} (cm^{2}/MeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_CC1pip_XSec_2DTpiEnu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pip/ccpipXSecs.root;PIKEVENUXSec" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_2DTpiEnu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h index 1fdddd2..d2231aa 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTpiEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_2DTPIENU_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_2DTPIENU_NU_H_SEEN #include "Measurement2D.h" class MiniBooNE_CC1pip_XSec_2DTpiEnu_nu : public Measurement2D { public: MiniBooNE_CC1pip_XSec_2DTpiEnu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_2DTpiEnu_nu() {}; //void SetDataValues(std::string fileLocation); void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx index 935f875..e2204ad 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_2DTuCosmu_nu::MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_2DTuCosmu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#mu} (MeV)"); fSettings.SetYTitle("cos#theta_{#mu}"); fSettings.SetZTitle("d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/MeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_CC1pip_XSec_2DTuCosmu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pip/ccpipXSecs.root;MUCTVKEXSec" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08)/TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_2DTuCosmu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h index f0614fa..39bb855 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuCosmu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_2DTUCOSMU_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_2DTUCOSMU_NU_H_SEEN #include "Measurement2D.h" class MiniBooNE_CC1pip_XSec_2DTuCosmu_nu : public Measurement2D { public: MiniBooNE_CC1pip_XSec_2DTuCosmu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_2DTuCosmu_nu() {}; //void SetDataValues(std::string fileLocation); void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx index a186c6e..1c3a4db 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.cxx @@ -1,86 +1,86 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h" //******************************************************************** MiniBooNE_CC1pip_XSec_2DTuEnu_nu::MiniBooNE_CC1pip_XSec_2DTuEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CC1pip_XSec_2DTuEnu_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (MeV)"); fSettings.SetYTitle("T_{#mu} (MeV)"); fSettings.SetZTitle("d#sigma(E_{#nu})/dT_{#mu} (cm^{2}/MeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.107); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_CC1pip_XSec_2DTuEnu_nu"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/CC1pip/ccpipXSecs.root;MUKEVENUXSec" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/double(fNEvents)*(14.08); // Plot Setup ------------------------------------------------------- SetDataFromRootFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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_CC1pip_XSec_2DTuEnu_nu.h b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h index 24dba02..60c221c 100644 --- a/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CC1pip_XSec_2DTuEnu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CC1PIP_XSEC_2DTUENU_NU_H_SEEN #define MINIBOONE_CC1PIP_XSEC_2DTUENU_NU_H_SEEN #include "Measurement2D.h" class MiniBooNE_CC1pip_XSec_2DTuEnu_nu : public Measurement2D { public: MiniBooNE_CC1pip_XSec_2DTuEnu_nu(nuiskey samplekey); virtual ~MiniBooNE_CC1pip_XSec_2DTuEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.cxx index d668fa9..1624355 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.cxx @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_1DEnu_nu.h" //******************************************************************** MiniBooNE_CCQE_XSec_1DEnu_nu::MiniBooNE_CCQE_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CCQE_XSec_1DEnu_nu sample. \n" "Target: CH2 \n" "Flux: MiniBooNE Forward Horn Current\n" "Signal: Any event with 1 muon, any nucleons, and no " "other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); - fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/Neutron)"); + fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/neutron)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.4, 2.0); fSettings.DefineAllowedTargets("C,H"); fSettings.FoundFill("name", "CCQELike", ccqelike, true); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CCQE_XSec_1DEnu_nu"); if (ccqelike) { fSettings.SetDataInput(FitPar::GetDataBase() + "MiniBooNE/ccqe/asne_like.txt"); } else { fSettings.SetDataInput(FitPar::GetDataBase() + "MiniBooNE/ccqe/asne_con.txt"); } fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2 fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents) * (14.08/6.0); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MiniBooNE_CCQE_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (isSignal(event)) { fXVar = event->GetNeutrinoIn()->fP.E() * 1E-3; } }; bool MiniBooNE_CCQE_XSec_1DEnu_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_CCQE_XSec_1DEnu_nu.h b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.h index 053f861..1438c3c 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.h +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DEnu_nu.h @@ -1,38 +1,38 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CCQE_XSEC_1DENU_NU_H_SEEN #define MINIBOONE_CCQE_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_CCQE_XSec_1DEnu_nu : public Measurement1D { public: MiniBooNE_CCQE_XSec_1DEnu_nu(nuiskey samplekey); virtual ~MiniBooNE_CCQE_XSec_1DEnu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); bool ccqelike; ///. *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_1DQ2_antinu.h" #include MiniBooNE_CCQE_XSec_1DQ2_antinu::MiniBooNE_CCQE_XSec_1DQ2_antinu( nuiskey samplekey) { // Sample overview std::string descrip = "MiniBooNE CCQE/CC0pi sample. \n" "Target: CH2.08 \n" "Flux: CCQE = Forward Horn Current numu \n" " CC0pi = Forward Horn Current numu+numub \n" "Signal: CCQE = True CCQE + True 2p2h (Mode == 1 or 2) \n" " CC0pi = Events with 1 mu+/mu-, N nucleons, 0 other"; // 1. Initalise sample Settings --------------------------------------- fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetSuggestedFlux(FitPar::GetDataBase() + "/MiniBooNE/ccqe/mb_ccqe_flux.root"); // Define input data information fSettings.FoundFill("name", "CCQELike", fCCQElike, true); fSettings.FoundFill("name", "CTarg", fUseCorrectedCTarget, true); if (fCCQElike && fUseCorrectedCTarget) { NUIS_ABORT("Sample: MiniBooNE_CCQE_XSec_1DQ2_antinu cannot run in both " "QELike and C-Target mode. You're welcome to add the data set."); } if (fCCQElike) { // CCQELike plot information fSettings.SetTitle("MiniBooNE #nu_#mu CCQE on CH"); fSettings.SetDataInput(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_con.txt"); fSettings.SetCovarInput(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_diagcovar"); fSettings.SetDefault("ccqelikebkg_input", FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_bkg_ccqe.txt"); fSettings.SetDefault("ccpimbkg_input", FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_bkg_ccpim.txt"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu,numub"); fSettings.DefineAllowedTargets("C,H"); } else if (!fUseCorrectedCTarget) { // CCQE Plot Information fSettings.SetTitle("MiniBooNE #nu_#mu CC0#pi on CH"); fSettings.SetDataInput(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_con.txt"); fSettings.SetCovarInput(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_diagcovar"); fSettings.DefineAllowedSpecies("numu"); fSettings.DefineAllowedTargets("C,H"); } else { // CCQE Corrected Target Plot Information fSettings.SetTitle("MiniBooNE #nu_#mu CC0#pi on C"); fSettings.SetDataInput(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_con_ctarget.txt"); fSettings.SetCovarInput(FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/asqq_diagcovar"); fSettings.DefineAllowedSpecies("numu"); fSettings.DefineAllowedTargets("C"); } FinaliseSampleSettings(); // 2. Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon // Multiply by 14.08/6.0 to get per neutron double NNucPerNTarg = fUseCorrectedCTarget ? 12.0 / 6.0 : 14.08 / 8.0; fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * NNucPerNTarg / TotalIntegratedFlux()); // 3. Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCovarFromDiagonal(); /// /// If CCQELike is used an additional the CCQELike BKG is used and a PDG /// Histogram is saved if (fCCQElike) { // CCQELike Data fDataHist_CCQELIKE = PlotUtils::GetTH1DFromFile(fSettings.GetS("ccqelikebkg_input"), fSettings.GetName() + "_CCQELIKE_data"); fDataHist_CCQELIKE->SetNameTitle( (fSettings.Name() + "_CCQELIKE_BKG").c_str(), ("MiniBooNE #nu_#mu CCQE-Like Backgrounds" + fSettings.PlotTitles()) .c_str()); fDataHist->Add(fDataHist_CCQELIKE); SetAutoProcessTH1(fDataHist_CCQELIKE, kCMD_Write); // CCQELike MC fMCHist_CCQELIKE = new NuNuBarTrueModeStack( fSettings.Name() + "_CCQELIKE_MC", "CCQE-like MC" + fSettings.PlotTitles(), fDataHist_CCQELIKE); SetAutoProcessTH1(fMCHist_CCQELIKE); // Data CCRES fDataHist_CCPIM = PlotUtils::GetTH1DFromFile(fSettings.GetS("ccpimbkg_input"), fSettings.GetName() + "_CCPIM_BKG_data"); fDataHist_CCPIM->SetNameTitle( (fSettings.Name() + "_CCPIM_data").c_str(), ("MiniBooNE #nu_#mu CCQE-Like Backgrounds" + fSettings.PlotTitles()) .c_str()); SetAutoProcessTH1(fDataHist_CCQELIKE, kCMD_Write); // MC CCRES fMCHist_CCPIM = new NuNuBarTrueModeStack( fSettings.Name() + "_CCPIM_BKG_MC", "CCQE-like BKG CC-RES" + fSettings.PlotTitles(), fDataHist_CCPIM); SetAutoProcessTH1(fMCHist_CCPIM); // Make NON CCPIM fDataHist_NONCCPIM = (TH1D *)fDataHist_CCQELIKE->Clone(); fDataHist_NONCCPIM->SetNameTitle((fName + "_data_NONCCPIM").c_str(), (fName + "_data_NONCCPIM").c_str()); fDataHist_NONCCPIM->Add(fDataHist_CCPIM, -1.0); SetAutoProcessTH1(fDataHist_NONCCPIM, kCMD_Write); fMCHist_NONCCPIM = new NuNuBarTrueModeStack( fSettings.Name() + "_NONCCPIM_BKG", "CCQE-like BKG CC-NonRES" + fSettings.PlotTitles(), fDataHist_NONCCPIM); SetAutoProcessTH1(fMCHist_NONCCPIM); } FinaliseMeasurement(); }; 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); fPDGnu = event->PDGnu(); 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)) { return true; } } else { if (SignalDef::isCCQELike(event, -14, EnuMin, EnuMax)) return true; } return false; }; void MiniBooNE_CCQE_XSec_1DQ2_antinu::FillExtraHistograms( MeasurementVariableBox *vars, double weight) { // No Extra Hists if not ccqelike if (!fCCQElike or !Signal) return; // Fill Stacks if (Mode != -1 and Mode != -2) { if (fabs(Mode) == 11 or fabs(Mode) == 12 or fabs(Mode == 13)) { fMCHist_CCPIM->Fill(fPDGnu, Mode, fXVar, weight); } else { fMCHist_NONCCPIM->Fill(fPDGnu, Mode, fXVar, weight); } } fMCHist_CCQELIKE->Fill(fPDGnu, Mode, fXVar, weight); } diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.h b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.h index 86a188d..5bd9978 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.h +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_antinu.h @@ -1,65 +1,65 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CCQE_XSEC_1DQ2_ANTINU_H_SEEN #define MINIBOONE_CCQE_XSEC_1DQ2_ANTINU_H_SEEN #include "Measurement1D.h" #include "MeasurementBase.h" #include "MiniBooNE_Boxes.h" /// MiniBooNE antinu CCQE sample class : arXiv:1002:2680 class MiniBooNE_CCQE_XSec_1DQ2_antinu : public Measurement1D { public: /// Default constructor. Setup from the following name keys /// MiniBooNE_CCQE_XSec_1DQ2_antinu \n /// MiniBooNE_CCQELike_XSec_1DQ2_antinu \n /// MiniBooNE_CCQE_XSec_1DQ2_antinu_CTarg MiniBooNE_CCQE_XSec_1DQ2_antinu(nuiskey samplekey); virtual ~MiniBooNE_CCQE_XSec_1DQ2_antinu() {}; /// Main fill event variables: X = Q2_QE void FillEventVariables(FitEvent *event); /// Signal definition: antinumu CCQE+2p2h or numu/antinumu CC0pi bool isSignal(FitEvent *event); /// Uses MiniBooNE_CCQELike_Box instead. // MeasurementVariableBox* CreateBox(); /// Fills extra PDG Histograms void FillExtraHistograms(MeasurementVariableBox* vars, double weight = 1.0); private: bool fCCQElike; ///< Flag for running in CCQELike mode bool fUseCorrectedCTarget; ///< Flag for using corrected `C-Target' data. TH1D* fDataHist_CCQELIKE; ///< CCQELike data contribution TH1D* fDataHist_CCPIM; ///< CCPIM data contribution TH1D* fDataHist_NONCCPIM; ///< NONCCPIM data contribution NuNuBarTrueModeStack* fMCHist_NONCCPIM; ///< Plots in CCQELike mode to tag PDG of the NONCCPIM NuNuBarTrueModeStack* fMCHist_CCPIM; ///< Plots in CCQELike mode to tag PDG of the CCPIM NuNuBarTrueModeStack* fMCHist_CCQELIKE; ///< Plots in CCQELike mode to tag PDG numu/numubar modes int fPDGnu; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx index ecb4edf..1d05cc8 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.cxx @@ -1,183 +1,183 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_1DQ2_nu.h" //******************************************************************** MiniBooNE_CCQE_XSec_1DQ2_nu::MiniBooNE_CCQE_XSec_1DQ2_nu(nuiskey samplekey) { //******************************************************************** // Initalise sample Settings --------------------------------------- fSettings = LoadSampleSettings(samplekey); fSettings.FoundFill("name", "CCQELike", ccqelike, true); // Multiple constructors for similar samples if (ccqelike) Setup_MiniBooNE_CCQELike_XSec_1DQ2_nu(); else Setup_MiniBooNE_CCQE_XSec_1DQ2_nu(); // Final Check for all requirements, necessary to setup all extra plots. FinaliseMeasurement(); } //******************************************************************** void MiniBooNE_CCQE_XSec_1DQ2_nu::Setup_MiniBooNE_CCQE_XSec_1DQ2_nu() { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE CCQE sample. \n" \ "Target: CH2.08 \n" \ "Flux: CCQE = Forward Horn Current numu \n" \ "Signal: CCQE = True CCQE + True 2p2h (Mode == 1 or 2) \n"; // Setup common settings fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetSuggestedFlux( FitPar::GetDataBase() + "/MiniBooNE/ccqe/mb_ccqe_flux.root"); // CCQE Plot Information fSettings.SetTitle("MiniBooNE #nu_#mu CC0#pi"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/asqq_con.txt" ); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // 2. Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon // Multiply by 14.08/6.0 to get per neutron fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * (14.08 / 6.0) / TotalIntegratedFlux()); // 3. Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromDiagonal(); }; //******************************************************************** void MiniBooNE_CCQE_XSec_1DQ2_nu::Setup_MiniBooNE_CCQELike_XSec_1DQ2_nu() { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE CC0pi sample. \n" \ "Target: CH2.08 \n" \ "Flux: MiniBooNE Forward Horn Current numu \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2}_{QE} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ_{QE}^{2} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetSuggestedFlux( FitPar::GetDataBase() + "/MiniBooNE/ccqe/mb_ccqe_flux.root"); // CCQELike plot information fSettings.SetTitle("MiniBooNE #nu_#mu CCQE"); fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/asqq_like.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/asqq_diagcovar" ); fSettings.SetDefault( "ccqelikebkg_input", FitPar::GetDataBase() + "/MiniBooNE/ccqe/asqq_bkg.txt" ); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu,numub"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon // Multiply by 14.08/6.0 to get per neutron fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * (14.08 / 6.0) / TotalIntegratedFlux()); // Plot Setup ------------------------------------------------------- fDataHist = PlotUtils::GetTH1DFromFile( fSettings.GetDataInput(), fSettings.GetName() ); fDataHist->SetTitle( (fSettings.Title() + fSettings.PlotTitles()).c_str() ); // Make Data CCQELike BKG fDataHist_CCQELIKE = PlotUtils::GetTH1DFromFile( fSettings.GetS("ccqelikebkg_input"), fSettings.GetName() + "_CCQELIKEBKG_data" ); fDataHist_CCQELIKE->SetNameTitle( (fSettings.Name() + "_CCQELIKE_BKG_data").c_str(), ("MiniBooNE #nu_#mu CCQE-Like Backgrounds" + fSettings.PlotTitles()).c_str() ); // fDataHist->Add(fDataHist_CCQELIKE); SetAutoProcessTH1(fDataHist_CCQELIKE, kCMD_Write); // Make MC Clone fMCHist_CCQELIKE = new TrueModeStack( fSettings.Name() + "_CCQELIKE_BKG_MC", "CCQE-like BKG MC" + fSettings.PlotTitles(), fDataHist_CCQELIKE); SetAutoProcessTH1(fMCHist_CCQELIKE); }; //******************************************************************** 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; }; void MiniBooNE_CCQE_XSec_1DQ2_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight) { // No Extra Hists if not ccqelike if (!ccqelike) return; if ((Mode != 1 and Mode != 2) and (Signal)) { fMCHist_CCQELIKE->Fill(Mode, fXVar, weight); } return; } diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.h b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.h index 260c4e4..9957b82 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.h +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_1DQ2_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CCQE_XSEC_1DQ2_NU_H_SEEN #define MINIBOONE_CCQE_XSEC_1DQ2_NU_H_SEEN #include "Measurement1D.h" //******************************************************************** class MiniBooNE_CCQE_XSec_1DQ2_nu : public Measurement1D { //******************************************************************** public: MiniBooNE_CCQE_XSec_1DQ2_nu(nuiskey samplekey); virtual ~MiniBooNE_CCQE_XSec_1DQ2_nu() {}; // Multiple Constrictuors. void Setup_MiniBooNE_CCQE_XSec_1DQ2_nu(); void Setup_MiniBooNE_CCQELike_XSec_1DQ2_nu(); void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight = 1.0); private: double q2qe; ///. *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_2DTcos_antinu.h" //******************************************************************** MiniBooNE_CCQE_XSec_2DTcos_antinu::MiniBooNE_CCQE_XSec_2DTcos_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CCQE_XSec_2DTcos_antinu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#mu} (GeV)"); fSettings.SetYTitle("cos#theta_{#mu}"); fSettings.SetZTitle("d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.130); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CCQE_XSec_2DTcos_antinu"); ccqelike = fSettings.Found("name", "CCQELike"); if (!ccqelike) { fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/aski_like.txt" ); fSettings.SetErrorInput( FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/aski_err.txt" ); fSettings.DefineAllowedSpecies("numub"); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/aski_like.txt" ); fSettings.SetErrorInput( FitPar::GetDataBase() + "/MiniBooNE/anti-ccqe/aski_err.txt" ); fMeasurementSpeciesType = kNumuWithWrongSignMeasurement; fSettings.DefineAllowedSpecies("numu,numub"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * (14.08 / 8.) / TotalIntegratedFlux()); // Plot Setup ------------------------------------------------------- Double_t binx[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 biny[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}; CreateDataHistogram(19, binx, 21, biny); SetDataValuesFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-41); SetDataErrorsFromTextFile( fSettings.GetErrorInput() ); ScaleDataErrors(1E-41); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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_antinu.h b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.h index a0aced5..bac452a 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.h +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_antinu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CCQE_XSEC_2DTcos_ANTINU_H_SEEN #define MINIBOONE_CCQE_XSEC_2DTcos_ANTINU_H_SEEN #include "Measurement2D.h" //******************************************************************** class MiniBooNE_CCQE_XSec_2DTcos_antinu : public Measurement2D { //******************************************************************** public: MiniBooNE_CCQE_XSec_2DTcos_antinu(nuiskey samplekey); virtual ~MiniBooNE_CCQE_XSec_2DTcos_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double Ekmu, costheta, q2qe; bool bad_particle, ccqelike; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx index 049b090..b390947 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.cxx @@ -1,125 +1,125 @@ -/// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +/// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_CCQE_XSec_2DTcos_nu.h" //******************************************************************** MiniBooNE_CCQE_XSec_2DTcos_nu::MiniBooNE_CCQE_XSec_2DTcos_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_CCQE_XSec_2DTcos_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 electron, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{#mu} (GeV)"); fSettings.SetYTitle("cos#theta_{#mu}"); fSettings.SetZTitle("d^{2}#sigma/dT_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 3.0); fSettings.SetNormError(0.101); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("MiniBooNE_CCQE_XSec_2DTcos_nu"); ccqelike = fSettings.Found("name", "CCQELike"); if (!ccqelike) { fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/aski_con.txt" ); fSettings.SetErrorInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/aski_err.txt" ); fSettings.DefineAllowedSpecies("numu"); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/aski_like.txt" ); fSettings.SetErrorInput( FitPar::GetDataBase() + "/MiniBooNE/ccqe/aski_err.txt" ); fMeasurementSpeciesType = kNumuWithWrongSignMeasurement; fSettings.DefineAllowedSpecies("numu,numub"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38 / (fNEvents + 0.)) * 14.08 / 6. / TotalIntegratedFlux(); // Plot Setup ------------------------------------------------------- Double_t binx[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 biny[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}; CreateDataHistogram(19, binx, 21, biny); SetDataValuesFromTextFile( fSettings.GetDataInput() ); ScaleData(1E-41); SetDataErrorsFromTextFile( fSettings.GetErrorInput() ); ScaleDataErrors(1E-42); SetCovarFromDiagonal(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** 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_CCQE_XSec_2DTcos_nu.h b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.h index 7d65682..1e9625f 100644 --- a/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.h +++ b/src/MiniBooNE/MiniBooNE_CCQE_XSec_2DTcos_nu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_CCQE_XSEC_2DTcos_NU_H_SEEN #define MINIBOONE_CCQE_XSEC_2DTcos_NU_H_SEEN #include "Measurement2D.h" //******************************************************************** class MiniBooNE_CCQE_XSec_2DTcos_nu : public Measurement2D { //******************************************************************** public: MiniBooNE_CCQE_XSec_2DTcos_nu(nuiskey samplekey); virtual ~MiniBooNE_CCQE_XSec_2DTcos_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: double Ekmu, costheta; bool bad_particle, ccqelike; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.cxx b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.cxx index 12b3d03..2357a71 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.cxx +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.cxx @@ -1,103 +1,103 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h" //******************************************************************** MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu::MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#pi^{0}}"); fSettings.SetYTitle("d#sigma/dcos#theta_{#pi^{0}} (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 5.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu"); nunubar_mode = fSettings.Found("name", "rhc"); if (!nunubar_mode) { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nubarcosthetapi0xsec_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nubarcosthetapi0xsecerrormatrix.txt" ); fSettings.DefineAllowedSpecies("numub"); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnubarmodecosthetapi0xsec_edit.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnubarmodecosthetapi0xsecerrormatrix.txt"); fSettings.DefineAllowedSpecies("numu,numub"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromTextFile( fSettings.GetCovarInput() ); ScaleCovar(1.E-5); StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu::FillEventVariables(FitEvent *event) { // (CP) require pi0 in final state (this makes some assumptions about how the // generator treats the pi0 after it is produced in the nucleus. // MB required 2 photons to make a pion signal, so check for those later if (event->NumFSParticle(111) == 0 ) { return; } if (abs(event->NumFSParticle(13)) == 1 || abs(event->NumFSParticle(11)) == 1 || abs(event->NumFSParticle(15)) == 1 || abs(event->NumFSParticle(17)) == 1) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double CosPi0 = cos(FitUtils::th(Pnu, Ppi0)); fXVar = CosPi0; return; }; //******************************************************************** bool MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu::isSignal(FitEvent *event) { //******************************************************************** if (nunubar_mode) { return (SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax) || SignalDef::isNC1pi(event, -14, 111, EnuMin, EnuMax)); } else { return SignalDef::isNC1pi(event, -14, 111, EnuMin, EnuMax); } } diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h index a7267d7..12d52ef 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_NC1PI0_XSEC_1DCOSPI0_NUBAR_H_SEEN #define MINIBOONE_NC1PI0_XSEC_1DCOSPI0_NUBAR_H_SEEN #include "Measurement1D.h" class MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu : public Measurement1D { public: MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu(nuiskey samplekey); virtual ~MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: /* As MB provides data for the nu/antinu siganl of nu/antinu running mode, as well as the combined nu+antinu signal for each mode, set these bools in the .cxx to select which signal to use from which mode*/ bool nunubar_mode; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.cxx b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.cxx index ac1680d..3d7e2a4 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.cxx @@ -1,105 +1,105 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h" //******************************************************************** MiniBooNE_NC1pi0_XSec_1Dcospi0_nu::MiniBooNE_NC1pi0_XSec_1Dcospi0_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_NC1pi0_XSec_1Dcospi0_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#pi^{0}}"); fSettings.SetYTitle("d#sigma/dcos#theta_{#pi^{0}} (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 5.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_NC1pi0_XSec_1Dcospi0_nu"); nunubarmode = fSettings.Found("name", "fhc"); if (!nunubarmode) { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nucosthetapi0xsec_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nucosthetapi0xsecerrormatrix.txt" ); fSettings.DefineAllowedSpecies("numu"); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnumodecosthetapi0xsec_edit.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnumodecosthetapi0xsecerrormatrix.txt"); fSettings.DefineAllowedSpecies("numu,numub"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromTextFile( fSettings.GetCovarInput() ); ScaleCovar(1.E-5); StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MiniBooNE_NC1pi0_XSec_1Dcospi0_nu::FillEventVariables(FitEvent *event) { // (CP) require pi0 in final state (this makes some assumptions about how the // generator treats the pi0 after it is produced in the nucleus. // MB required 2 photons to make a pion signal, so check for those later if (event->NumFSParticle(111) == 0 ) { return; } if (abs(event->NumFSParticle(13)) == 1 || abs(event->NumFSParticle(11)) == 1 || abs(event->NumFSParticle(15)) == 1 || abs(event->NumFSParticle(17)) == 1) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double CosPi0 = cos(FitUtils::th(Pnu, Ppi0)); fXVar = CosPi0; return; }; //******************************************************************** bool MiniBooNE_NC1pi0_XSec_1Dcospi0_nu::isSignal(FitEvent *event) { //******************************************************************** if (nunubarmode){ return (SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax) || SignalDef::isNC1pi(event, -14, 111, EnuMin, EnuMax)); } else { return SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax); } } diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h index 4e75239..974dc95 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dcospi0_nu.h @@ -1,42 +1,42 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_NC1PI0_XSEC_1DCOSPI0_NU_H_SEEN #define MINIBOONE_NC1PI0_XSEC_1DCOSPI0_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_NC1pi0_XSec_1Dcospi0_nu : public Measurement1D { public: MiniBooNE_NC1pi0_XSec_1Dcospi0_nu(nuiskey samplekey); virtual ~MiniBooNE_NC1pi0_XSec_1Dcospi0_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: /* As MB provides data for the nu/nubar siganl of nu/nubar running mode, as well as the combined nu+nubar signal for each mode, use these bools to select which signal to use from which mode*/ bool nunubarmode; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.cxx b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.cxx index fc376b6..fa9c87f 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.cxx +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.cxx @@ -1,104 +1,104 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h" //******************************************************************** MiniBooNE_NC1pi0_XSec_1Dppi0_antinu::MiniBooNE_NC1pi0_XSec_1Dppi0_antinu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_NC1pi0_XSec_1Dppi0_antinu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi^{0}} (GeV/c)"); fSettings.SetYTitle("d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 5.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_NC1pi0_XSec_1Dppi0_antinu"); nunubarmode = fSettings.Found("name", "rhc"); if (!nunubarmode) { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nubarppi0xsec_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nubarppi0xsecerrormatrix.txt" ); fSettings.DefineAllowedSpecies("numu"); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnubarmodeppi0xsec_edit.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnubarmodeppi0xsecerrormatrix.txt"); fSettings.DefineAllowedSpecies("numu,numub"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromTextFile( fSettings.GetCovarInput() ); ScaleCovar(1.E-5); StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MiniBooNE_NC1pi0_XSec_1Dppi0_antinu::FillEventVariables(FitEvent *event) { // (CP) require pi0 in final state (this makes some assumptions about how the // generator treats the pi0 after it is produced in the nucleus. // MB required 2 photons to make a pion signal, so check for those later if (event->NumFSParticle(111) == 0) { return; } if (abs(event->NumFSParticle(13)) == 1 || abs(event->NumFSParticle(11)) == 1 || abs(event->NumFSParticle(15)) == 1 || abs(event->NumFSParticle(17)) == 1) return; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double p_pi0 = FitUtils::p(Ppi0); fXVar = p_pi0; return; }; //******************************************************************** bool MiniBooNE_NC1pi0_XSec_1Dppi0_antinu::isSignal(FitEvent *event) { //******************************************************************** if (nunubarmode){ return (SignalDef::isNC1pi(event, -14, 111, EnuMin, EnuMax) || SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax) ); } else { return SignalDef::isNC1pi(event, -14, 111, EnuMin, EnuMax); } } diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h index ee6f982..ffd4e6e 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_antinu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_NC1PI0_XSEC_1DPPI0_NUBAR_H_SEEN #define MINIBOONE_NC1PI0_XSEC_1DPPI0_NUBAR_H_SEEN #include "Measurement1D.h" class MiniBooNE_NC1pi0_XSec_1Dppi0_antinu : public Measurement1D { public: MiniBooNE_NC1pi0_XSec_1Dppi0_antinu(nuiskey samplekey); virtual ~MiniBooNE_NC1pi0_XSec_1Dppi0_antinu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: /* As MB provides data for the nu/nubar siganl of nu/nubar running mode, as well as the combined nu+nubar signal for each mode, set these bools in the .cxx to select which signal to use from which mode */ bool nunubarmode; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.cxx index 85b8a7b..e2bdef1 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.cxx @@ -1,104 +1,104 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h" //******************************************************************** MiniBooNE_NC1pi0_XSec_1Dppi0_nu::MiniBooNE_NC1pi0_XSec_1Dppi0_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_NC1pi0_XSec_1Dppi0_nu sample. \n" \ "Target: CH \n" \ "Flux: MiniBooNE Forward Horn Current nue + nuebar \n" \ "Signal: Any event with 1 muon, any nucleons, and no other FS particles \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#pi^{0}} (GeV/c)"); fSettings.SetYTitle("d#sigma/dp_{#pi^{0}} (cm^{2}/(GeV/c)/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 5.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("MiniBooNE_NC1pi0_XSec_1Dppi0_nu"); nunubar_mode_nu = fSettings.Found("name", "fhc"); if (!nunubar_mode_nu) { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nuppi0xsec_edit.txt" ); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/nuppi0xsecerrormatrix.txt" ); fSettings.DefineAllowedSpecies("numu"); } else { fSettings.SetDataInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnumodeppi0xsec_edit.txt"); fSettings.SetCovarInput( FitPar::GetDataBase() + "MiniBooNE/NC1pi0/combinedsignnumodeppi0xsecerrormatrix.txt"); fSettings.DefineAllowedSpecies("numu,numub"); } FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromTextFile( fSettings.GetDataInput() ); SetCovarFromTextFile( fSettings.GetCovarInput() ); ScaleCovar(1.E-5); StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, 1E-38); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void MiniBooNE_NC1pi0_XSec_1Dppi0_nu::FillEventVariables(FitEvent *event) { // (CP) require pi0 in final state (this makes some assumptions about how the // generator treats the pi0 after it is produced in the nucleus. // MB required 2 photons to make a pion signal, so check for those later if (event->NumFSParticle(111) == 0) { return; } if (abs(event->NumFSParticle(13)) == 1 || abs(event->NumFSParticle(11)) == 1 || abs(event->NumFSParticle(15)) == 1 || abs(event->NumFSParticle(17)) == 1) return; TLorentzVector Ppi0 = event->GetHMFSParticle(111)->fP; double p_pi0 = FitUtils::p(Ppi0); fXVar = p_pi0; return; }; //******************************************************************** bool MiniBooNE_NC1pi0_XSec_1Dppi0_nu::isSignal(FitEvent *event) { //******************************************************************** if (nunubar_mode_nu){ return (SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax) || SignalDef::isNC1pi(event, -14, 111, EnuMin, EnuMax)); } else { return SignalDef::isNC1pi(event, 14, 111, EnuMin, EnuMax); } } diff --git a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h index 112e278..67c9e9f 100644 --- a/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h +++ b/src/MiniBooNE/MiniBooNE_NC1pi0_XSec_1Dppi0_nu.h @@ -1,41 +1,41 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_NC1PI0_XSEC_1DPPI0_NU_H_SEEN #define MINIBOONE_NC1PI0_XSEC_1DPPI0_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_NC1pi0_XSec_1Dppi0_nu : public Measurement1D { public: MiniBooNE_NC1pi0_XSec_1Dppi0_nu(nuiskey samplekey); virtual ~MiniBooNE_NC1pi0_XSec_1Dppi0_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); private: /* As MB provides data for the nu/nubar siganl of nu/nubar running mode, as well as the combined nu+nubar signal for each mode, set these bools in the .cxx to select which signal to use from which mode*/ bool nunubar_mode_nu; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx index 37d38bd..be6f4cf 100644 --- a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.cxx @@ -1,293 +1,295 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MiniBooNE_NCEL_XSec_Treco_nu.h" #include "TLorentzVector.h" //******************************************************************** MiniBooNE_NCEL_XSec_Treco_nu::MiniBooNE_NCEL_XSec_Treco_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "MiniBooNE_NCEL_XSec_Treco_nu sample. \n" "Target: CH \n" "Flux: MiniBooNE Numu Flux \n" "Signal: Any event with True NCEL modes \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("T_{reco} (MeV)"); fSettings.SetYTitle("Events/(12 MeV)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL,DIAG"); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetEnuRange(0.0, 10.0); double arr_treco[52] = { 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", arr_treco); SetCovarMatrix(FitPar::GetDataBase() + "/MiniBooNE/ncqe/ErrorMatrix.tab", 51); SetResponseMatrix(FitPar::GetDataBase() + "/MiniBooNE/ncqe/response_mat.txt", 51, arr_treco); SetFluxHistogram(FitPar::GetDataBase() + "/MiniBooNE/ncqe/flux.txt"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // 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. // UPDATE: nMolMB is the number of CH_2 molecules in the MB FV (500 cm radius // sphere) and 0.845 is the published density of the mineral oil. UPDATE // UPDATE: They didn't account for fiducial cut, so neither do we. double nMolMB = 6.023E+23 * 0.845 * 4.0 * M_PI * 610.6 * 610.6 * 610.6 / 3.0; double POT = 6.46e20; // Need to update scalefactor to reflect actual flux used fScaleFactor = (this->newFluxHist->Integral("") * POT * (GetEventHistogram()->Integral("width")) * 1E-38 * 14.08 / (fNEvents + 0.)) * nMolMB; fScaleFactor /= GetFluxHistogram()->Integral("width"); // Final setup --------------------------------------------------- FinaliseMeasurement(); + this->fPlotTitles = fSettings.GetFullTitles(); + // 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); }; void MiniBooNE_NCEL_XSec_Treco_nu::Write(std::string arg) { - newFluxHist->Write("MB_NCEL_newFlux"); - response_mat->Write("MB_NCEL_response matrix"); + // newFluxHist->Write("MB_NCEL_newFlux"); + response_mat->Write("MB_NCEL_response_matrix"); Measurement1D::Write(arg); return; } 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; } void 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; }; void MiniBooNE_NCEL_XSec_Treco_nu::SetFluxHistogram(std::string dataFile) { this->newFluxHist = PlotUtils::GetTH1DFromFile( dataFile.c_str(), (this->fName + "Real Flux Hist"), "idgaf"); return; } // 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 // // Make a counter to track the line number int row = 0; std::string line; std::ifstream covar(covarFile.c_str(), std::ifstream::in); this->covar = new TMatrixDSym(dim); if (covar.is_open()) NUIS_LOG(DEB, "Reading covariance matrix from file: " << covarFile); while (std::getline(covar >> std::ws, line, '\n')) { std::istringstream stream(line); 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, double *arr_treco) { std::string line; std::ifstream input(inputFile.c_str(), std::ifstream::in); if (input.is_open()) { NUIS_LOG(DEB, "Reading data from file: " << inputFile); } this->fDataHist = new TH1D((this->fName + "_data").c_str(), (this->fName + this->fPlotTitles).c_str(), 51, arr_treco); 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(), 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; 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; 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, double *arr_treco) { // Make a counter to track the line number int xBin = 0; std::string line; std::ifstream response(responseFile.c_str(), std::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, arr_treco); if (response.is_open()) { NUIS_LOG(DEB, "Reading in the response matrix from file: " << responseFile); } while (std::getline(response, line, '\n')) { std::istringstream stream(line); 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_NCEL_XSec_Treco_nu.h b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.h index 7ca1fec..f388353 100644 --- a/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.h +++ b/src/MiniBooNE/MiniBooNE_NCEL_XSec_Treco_nu.h @@ -1,58 +1,58 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_NCEL_XSEC_TRECO_NU_H_SEEN #define MINIBOONE_NCEL_XSEC_RECO_NU_H_SEEN #include "Measurement1D.h" //******************************************************************** class MiniBooNE_NCEL_XSec_Treco_nu : public Measurement1D { //******************************************************************** public: void Write(std::string arg); MiniBooNE_NCEL_XSec_Treco_nu(nuiskey samplekey); virtual ~MiniBooNE_NCEL_XSec_Treco_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void ScaleEvents(); void SetDataValues(std::string inputFile, double* arr_treco); private: void SetCovarMatrix(std::string covarFile, int dim); void SetResponseMatrix(std::string responseFile, int dim, double* arr_treco); void SetFluxHistogram(std::string dataFile); TH1D *newFluxHist; TH1D *BKGD_other; TH1D *BKGD_irrid; TH2D *response_mat; }; #endif diff --git a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx index 3d18838..809d68a 100644 --- a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx +++ b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx @@ -1,188 +1,146 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #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 = - // (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) { NUIS_LOG(SAM, this->fName << "Setting data for " << this->fName); NUIS_LOG(SAM, this->fName << "From: " << dataFile); NUIS_LOG(SAM, this->fName << "Reading error from covariance"); 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) { NUIS_LOG(SAM, this->fName << "==============="); NUIS_LOG(SAM, this->fName << "Reading covariance: " << this->fName); NUIS_LOG(SAM, this->fName << "From: " << covarFile); // 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/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.h b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.h index 9c279a6..e15c077 100644 --- a/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.h +++ b/src/MiniBooNE/MiniBooNE_NCpi0_XSec_1Dppi0_nu.h @@ -1,44 +1,44 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIBOONE_NCPI0_XSEC_1DPPI0_NU_H_SEEN #define MINIBOONE_NCPI0_XSEC_1DPPI0_NU_H_SEEN #include "Measurement1D.h" class MiniBooNE_NCpi0_XSec_1Dppi0_nu : public Measurement1D { public: MiniBooNE_NCpi0_XSec_1Dppi0_nu(std::string inputfile, FitWeight *rw, std::string type, std::string fakeDataFile, Double_t *anuBins = NULL); virtual ~MiniBooNE_NCpi0_XSec_1Dppi0_nu() {}; void FillEventVariables(FitEvent* event); bool isSignal(FitEvent* event); bool isComb; void SetDataValues(std::string dataFile); void SetCovarMatrix(std::string covarFile, int dim); private: TMatrixDSym *tempCovar; int pi0Cnt; bool bad_particle; }; #endif diff --git a/src/MiniBooNE/SAMPLEREADME b/src/MiniBooNE/SAMPLEREADME deleted file mode 100644 index ea6f9be..0000000 --- a/src/MiniBooNE/SAMPLEREADME +++ /dev/null @@ -1,9 +0,0 @@ -./MiniBooNE_CCpi0_XSec_1DQ2_nu.cxx -./MiniBooNE_CCpip_XSec_1DQ2_nu.cxx -./MiniBooNE_CCpip_XSec_1DTpi_nu.cxx -./MiniBooNE_CCQE_XSec_1DQ2_antinu.cxx -./MiniBooNE_CCQE_XSec_1DQ2_nu.cxx -./MiniBooNE_CCQE_XSec_2DTcos_antinu.cxx -./MiniBooNE_CCQE_XSec_2DTcos_nu.cxx -./MiniBooNE_NCEL_XSec_Treco_nu.cxx -./MiniBooNE_NCpi0_XSec_1Dppi0_nu.cxx diff --git a/src/MiniBooNE/SampleSettings.cxx b/src/MiniBooNE/SampleSettings.cxx deleted file mode 100644 index 639d5fe..0000000 --- a/src/MiniBooNE/SampleSettings.cxx +++ /dev/null @@ -1,99 +0,0 @@ -#include "SampleSettings.h" - -SampleSettings::SampleSettings(){ -}; - -SampleSettings::SampleSettings(nuiskey key){ - fKeyValues = key; - if (!key.Has("type")) key.AddS("type","DEFAULT"); -} - -std::string SampleSettings::GetName(){ - return GetS("name"); -} - -void SampleSettings::SetS(std::string name, std::string val){ - fKeyValues.SetS(name, val); -}; - - -void SampleSettings::SetXTitle(std::string name){ - SetDefault("xtitle",name); -}; - -void SampleSettings::SetYTitle(std::string name){ - SetDefault("ytitle",name); -}; - -void SampleSettings::SetAllowedTypes(std::string allowed, std::string defaulttype){ - SetDefault("default_types",allowed); - SetDefault("allowed_types",defaulttype); -}; - -void SampleSettings::SetEnuRangeFromFlux(TH1D* fluxhist){ - double enu_min = fluxhist->GetXaxis()->GetXmin(); - double enu_max = fluxhist->GetXaxis()->GetXmax(); - SetEnuRange(enu_min,enu_max); -}; - -void SampleSettings::SetEnuRange(double min, double max){ - SetDefault("enu_min",min); - SetDefault("enu_max",max); -}; - -void SampleSettings::DefineAllowedTargets(std::string targ){ - // fAllowedTargets = TargetUtils::ParseTargetsToIntVect(targ); -}; - - -void SampleSettings::FoundFill(std::string name, std::string substr, bool& cont, bool def){ - std::string compstring = fKeyValues.GetS(name); - if (compstring.find(substr) != std::string::npos){ - cont = def; - } -}; - - -void SampleSettings::SetTitle(std::string val){ - SetDefault("title",val); -}; - -void SampleSettings::SetDataInput(std::string val){ - SetDefault("data",val); -}; - -void SampleSettings::SetCovarInput(std::string val){ - SetDefault("covar",val); -}; - -void SampleSettings::SetDefault(std::string name, std::string val){ - if (!fKeyValues.Has(name)) fKeyValues.AddS(name, val); -}; - -void SampleSettings::SetDefault(std::string name, double val ){ - if (!fKeyValues.Has(name)) fKeyValues.AddD(name, val); -}; - -void SampleSettings::SetHasExtraHistograms(bool opt){ - fHasExtraHistograms = opt; -}; - -void SampleSettings::DefineAllowedSpecies(std::string species){ - fAllowedTargets = BeamUtils::ParseSpeciesToIntVect(species); -}; - -std::string SampleSettings::Title(){ - return GetS("title"); -} - -std::string SampleSettings::GetDataInput(){ - return GetS("data"); -}; - -std::string SampleSettings::PlotTitles(){ - return ";" + GetS("xtitle") + ";" + GetS("ytitle"); -}; - -std::string SampleSettings::GetS(std::string name){ - return fKeyValues.GetS(name); -} diff --git a/src/MiniBooNE/SampleSettings.h b/src/MiniBooNE/SampleSettings.h deleted file mode 100644 index 80b9fea..0000000 --- a/src/MiniBooNE/SampleSettings.h +++ /dev/null @@ -1,46 +0,0 @@ -#ifndef SAMPLESETTINGS_H -#define SAMPLESETTINGS_H -#include "NuisConfig.h" -#include "NuisKey.h" -#include "TH1D.h" -#include "BeamUtils.h" -class SampleSettings { -public: - SampleSettings(); - SampleSettings(nuiskey key); - - inline std::string Name(){return GetName();}; - std::string GetName(); - void SetS(std::string name, std::string val); - void SetXTitle(std::string name); - void SetYTitle(std::string name); - void SetAllowedTypes(std::string allowed, std::string defaulttype="FIX"); - void SetEnuRangeFromFlux(TH1D* fluxhist); - void SetEnuRange(double min, double max); - std::string Title(); - void DefineAllowedTargets(std::string targ); - - void FoundFill(std::string name, std::string substr, bool& cont, bool def); - void SetTitle(std::string val); - void SetDataInput(std::string val); - void SetCovarInput(std::string val); - - void SetDefault(std::string name, std::string val); - void SetDefault(std::string name, double val); - void SetHasExtraHistograms(bool opt = true); - void DefineAllowedSpecies(std::string species); - - bool Has(std::string name){return fKeyValues.Has(name);}; - - std::string GetDataInput(); - std::string PlotTitles(); - std::string GetS(std::string name); - - - std::vector fAllowedTargets; - std::vector fAllowedSpecies; - nuiskey fKeyValues; - bool fHasExtraHistograms; -}; - -#endif diff --git a/src/Reweight/CMakeLists.txt b/src/Reweight/CMakeLists.txt index 1fe47ae..579fb79 100644 --- a/src/Reweight/CMakeLists.txt +++ b/src/Reweight/CMakeLists.txt @@ -1,96 +1,96 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES GlobalDialList.cxx FitWeight.cxx WeightEngineBase.cxx NEUTWeightEngine.cxx NuWroWeightEngine.cxx GENIEWeightEngine.cxx WeightUtils.cxx SampleNormEngine.cxx LikelihoodWeightEngine.cxx SplineWeightEngine.cxx NUISANCESyst.cxx T2KWeightEngine.cxx NUISANCEWeightEngine.cxx NUISANCEWeightCalcs.cxx NIWGWeightEngine.cxx OscWeightEngine.cxx MINERvAWeightCalcs.cxx weightRPA.h ) if(USE_NOvARwgt) LIST(APPEND IMPLFILES NOvARwgtEngine.cxx) endif() if(USE_NUSYST) LIST(APPEND IMPLFILES nusystematicsWeightEngine.cxx) endif() set(HEADERFILES GlobalDialList.h FitWeight.h WeightEngineBase.h NEUTWeightEngine.h NuWroWeightEngine.h GENIEWeightEngine.h WeightUtils.h SampleNormEngine.h LikelihoodWeightEngine.h SplineWeightEngine.h NUISANCESyst.h T2KWeightEngine.h NUISANCEWeightEngine.h NUISANCEWeightCalcs.h NIWGWeightEngine.h OscWeightEngine.h MINERvAWeightCalcs.h weightRPA.h BeRPA.h ) if(USE_NOvARwgt) LIST(APPEND HEADERFILES NOvARwgtEngine.h) endif() set(LIBNAME Reweight) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION - "${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}") + "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Reweight) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Reweight/FitWeight.cxx b/src/Reweight/FitWeight.cxx index 79c1504..be3b57d 100644 --- a/src/Reweight/FitWeight.cxx +++ b/src/Reweight/FitWeight.cxx @@ -1,305 +1,305 @@ #include "FitWeight.h" #include "GENIEWeightEngine.h" #include "LikelihoodWeightEngine.h" #include "ModeNormEngine.h" #include "NEUTWeightEngine.h" #include "NIWGWeightEngine.h" #include "NUISANCEWeightEngine.h" #include "NuWroWeightEngine.h" #include "OscWeightEngine.h" #include "SampleNormEngine.h" #include "SplineWeightEngine.h" #include "T2KWeightEngine.h" #ifdef __NOVA_ENABLED__ #include "NOvARwgtEngine.h" #endif #ifdef __NUSYST_ENABLED__ #include "nusystematicsWeightEngine.h" #endif void FitWeight::AddRWEngine(int type) { NUIS_LOG(FIT, "Adding reweight engine " << type); switch (type) { case kNEUT: fAllRW[type] = new NEUTWeightEngine("neutrw"); break; case kNUWRO: fAllRW[type] = new NuWroWeightEngine("nuwrorw"); break; case kGENIE: fAllRW[type] = new GENIEWeightEngine("genierw"); break; case kNORM: fAllRW[type] = new SampleNormEngine("normrw"); break; case kLIKEWEIGHT: fAllRW[type] = new LikelihoodWeightEngine("likerw"); break; case kT2K: fAllRW[type] = new T2KWeightEngine("t2krw"); break; case kCUSTOM: fAllRW[type] = new NUISANCEWeightEngine("nuisrw"); break; case kSPLINEPARAMETER: fAllRW[type] = new SplineWeightEngine("splinerw"); break; case kNIWG: fAllRW[type] = new NIWGWeightEngine("niwgrw"); break; case kOSCILLATION: fAllRW[type] = new OscWeightEngine(); break; case kMODENORM: fAllRW[type] = new ModeNormEngine(); break; #ifdef __NOVA_ENABLED__ case kNOvARWGT: fAllRW[type] = new NOvARwgtEngine(); break; #endif #ifdef __NUSYST_ENABLED__ case kNuSystematics: fAllRW[type] = new nusystematicsWeightEngine(); break; #endif default: NUIS_ABORT("CANNOT ADD RW Engine for unknown dial type: " << type); break; } } WeightEngineBase *FitWeight::GetRWEngine(int type) { if (HasRWEngine(type)) { return fAllRW[type]; } NUIS_ABORT("CANNOT get RW Engine for dial type: " << type); } bool FitWeight::HasRWEngine(int type) { switch (type) { case kNEUT: case kNUWRO: case kGENIE: case kNORM: case kLIKEWEIGHT: case kT2K: case kCUSTOM: case kSPLINEPARAMETER: case kNIWG: case kOSCILLATION: #ifdef __NOVA_ENABLED__ case kNOvARWGT: #endif #ifdef __NUSYST_ENABLED__ case kNuSystematics: #endif { return fAllRW.count(type); } default: { NUIS_ABORT("CANNOT get RW Engine for dial type: " << type); } } } void FitWeight::IncludeDial(std::string name, std::string type, double val) { // Should register the dial here. int typeenum = Reweight::ConvDialType(type); IncludeDial(name, typeenum, val); } void FitWeight::IncludeDial(std::string name, int dialtype, double val) { // Get the dial enum int nuisenum = Reweight::ConvDial(name, dialtype); if (nuisenum == -1) { NUIS_ERR(FTL, "Could not include dial " << name); NUIS_ERR(FTL, "With dialtype: " << dialtype); NUIS_ERR(FTL, "With value: " << val); NUIS_ABORT("With nuisenum: " << nuisenum); } // Setup RW Engine Pointer if (fAllRW.find(dialtype) == fAllRW.end()) { AddRWEngine(dialtype); } WeightEngineBase *rw = fAllRW[dialtype]; // Include the dial rw->IncludeDial(name, val); // Set Dial Value if (val != -9999.9) { rw->SetDialValue(name, val); } // Sort Maps fAllEnums[name] = nuisenum; fAllValues[nuisenum] = val; // Sort Lists fNameList.push_back(name); fEnumList.push_back(nuisenum); fValueList.push_back(val); } void FitWeight::Reconfigure(bool silent) { // Reconfigure all added RW engines for (std::map::iterator iter = fAllRW.begin(); iter != fAllRW.end(); iter++) { (*iter).second->Reconfigure(silent); } } void FitWeight::SetDialValue(std::string name, double val) { // Add extra check, if name not found look for one with name in it. int nuisenum = fAllEnums[name]; SetDialValue(nuisenum, val); } // Allow for name aswell using GlobalList to determine sample name. void FitWeight::SetDialValue(int nuisenum, double val) { // Conv dial type int dialtype = Reweight::GetDialType(nuisenum); if (fAllRW.find(dialtype) == fAllRW.end()) { NUIS_ERR(FTL, "Can't find RW engine for parameter " << fNameList[dialtype]); NUIS_ERR(FTL, "With dialtype " << dialtype << ", " << Reweight::RemoveDialType(nuisenum)); NUIS_ABORT("Are you sure you enabled the right engines?"); } // Get RW Engine for this dial fAllRW[dialtype]->SetDialValue(nuisenum, val); fAllValues[nuisenum] = val; // Update ValueList for (size_t i = 0; i < fEnumList.size(); i++) { if (fEnumList[i] == nuisenum) { fValueList[i] = val; } } } void FitWeight::SetAllDials(const double *x, int n) { for (size_t i = 0; i < (UInt_t)n; i++) { int rwenum = fEnumList[i]; SetDialValue(rwenum, x[i]); } Reconfigure(); } double FitWeight::GetDialValue(std::string name) { // Add extra check, if name not found look for one with name in it. int nuisenum = fAllEnums[name]; return GetDialValue(nuisenum); } double FitWeight::GetDialValue(int nuisenum) { return fAllValues[nuisenum]; } int FitWeight::GetDialPos(std::string name) { int rwenum = fAllEnums[name]; return GetDialPos(rwenum); } int FitWeight::GetDialPos(int nuisenum) { for (size_t i = 0; i < fEnumList.size(); i++) { if (fEnumList[i] == nuisenum) { return i; } } NUIS_ABORT("No Dial Found! (enum = " << nuisenum << ") "); } bool FitWeight::DialIncluded(std::string name) { return (fAllEnums.find(name) != fAllEnums.end()); } bool FitWeight::DialIncluded(int rwenum) { return (fAllValues.find(rwenum) != fAllValues.end()); } double FitWeight::CalcWeight(BaseFitEvt *evt) { double rwweight = 1.0; for (std::map::iterator iter = fAllRW.begin(); iter != fAllRW.end(); iter++) { double w = (*iter).second->CalcWeight(evt); rwweight *= w; } return rwweight; } void FitWeight::UpdateWeightEngine(const double *x) { size_t count = 0; for (std::vector::iterator iter = fEnumList.begin(); iter != fEnumList.end(); iter++) { SetDialValue((*iter), x[count]); count++; } } void FitWeight::GetAllDials(double *x, int n) { for (int i = 0; i < n; i++) { x[i] = GetDialValue(fEnumList[i]); } } // bool FitWeight::NeedsEventReWeight(const double* x) { // bool haschange = false; // size_t count = 0; // // Compare old to new and decide if RW needed. // for (std::vector::iterator iter = fEnumList.begin(); // iter != fEnumList.end(); iter++) { // int nuisenum = (*iter); // int type = (nuisenum / 1000) - (nuisenum % 1000); // // Compare old to new // double oldval = GetDialValue(nuisenum); // double newval = x[count]; // if (oldval != newval) { // if (fAllRW[type]->NeedsEventReWeight()) { // haschange = true; // } // } // count++; // } // return haschange; // } double FitWeight::GetSampleNorm(std::string name) { if (name.empty()) return 1.0; // Find norm dial if (fAllEnums.find(name + "_norm") != fAllEnums.end()) { if (fAllValues.find(fAllEnums[name + "_norm"]) != fAllValues.end()) { return fAllValues[fAllEnums[name + "_norm"]]; } else { return 1.0; } } else { return 1.0; } } void FitWeight::Print() { NUIS_LOG(REC, "Fit Weight State: "); for (size_t i = 0; i < fNameList.size(); i++) { NUIS_LOG(REC, - " -> Par " << i << ". " << fNameList[i] << " " << fValueList[i]); + "|-> Par " << i << ". " << fNameList[i] << " " << fValueList[i]); } } diff --git a/src/Reweight/NEUTWeightEngine.cxx b/src/Reweight/NEUTWeightEngine.cxx index 73b0b4d..66aed33 100644 --- a/src/Reweight/NEUTWeightEngine.cxx +++ b/src/Reweight/NEUTWeightEngine.cxx @@ -1,196 +1,208 @@ #include "NEUTWeightEngine.h" NEUTWeightEngine::NEUTWeightEngine(std::string name) { #if defined(__NEUT_ENABLED__) and !defined(__NO_REWEIGHT__) - // For newer NEUT we need to set up our defaults -#if __NEUT_VERSION__ >= 541 - neut::CommonBlockIFace::Initialize(std::string(std::getenv("NUISANCE"))+"/data/neut/neut_minimal_6t.card"); +#if defined(__NEUT_VERSION__) && (__NEUT_VERSION__ >= 541) + std::string neut_card = FitPar::Config().GetParS("NEUT_CARD"); + if (!neut_card.size()) { + NUIS_ABORT( + "[ERROR]: When using NEUTReWeight must set NEUT_CARD config option."); + } + // No need to vomit the contents of the card file all over my screen + StopTalking(); + neut::CommonBlockIFace::Initialize(neut_card); + StartTalking(); #endif // Setup the NEUT Reweight engien fCalcName = name; NUIS_LOG(FIT, "Setting up NEUT RW : " << fCalcName); // Create RW Engine suppressing cout StopTalking(); fNeutRW = new neut::rew::NReWeight(); TDirectory *olddir = gDirectory; // get list of vetoed calc engines (just for debug really) std::string rw_engine_list = FitPar::Config().GetParS("FitWeight_fNeutRW_veto"); bool xsec_ccqe = rw_engine_list.find("xsec_ccqe") == std::string::npos; bool xsec_res = rw_engine_list.find("xsec_res") == std::string::npos; // Activate each calc engine if (xsec_ccqe) fNeutRW->AdoptWghtCalc("xsec_ccqe", new neut::rew::NReWeightNuXSecCCQE); if (xsec_res) fNeutRW->AdoptWghtCalc("xsec_res", new neut::rew::NReWeightNuXSecRES); // Dials removed in NEUT 5.4.1 #if __NEUT_VERSION__ < 541 bool xsec_ccres = rw_engine_list.find("xsec_ccres") == std::string::npos; bool xsec_coh = rw_engine_list.find("xsec_coh") == std::string::npos; bool xsec_dis = rw_engine_list.find("xsec_dis") == std::string::npos; bool xsec_ncel = rw_engine_list.find("xsec_ncel") == std::string::npos; bool xsec_nc = rw_engine_list.find("xsec_nc") == std::string::npos; bool xsec_ncres = rw_engine_list.find("xsec_ncres") == std::string::npos; bool nucl_casc = rw_engine_list.find("nucl_casc") == std::string::npos; bool nucl_piless = rw_engine_list.find("nucl_piless") == std::string::npos; if (nucl_casc) fNeutRW->AdoptWghtCalc("nucl_casc", new neut::rew::NReWeightCasc); if (xsec_coh) fNeutRW->AdoptWghtCalc("xsec_coh", new neut::rew::NReWeightNuXSecCOH); if (xsec_nc) fNeutRW->AdoptWghtCalc("xsec_nc", new neut::rew::NReWeightNuXSecNC); if (nucl_piless) fNeutRW->AdoptWghtCalc("nucl_piless", new neut::rew::NReWeightNuclPiless); if (xsec_ncres) fNeutRW->AdoptWghtCalc("xsec_ncres", new neut::rew::NReWeightNuXSecNCRES); if (xsec_ccres) fNeutRW->AdoptWghtCalc("xsec_ccres", new neut::rew::NReWeightNuXSecCCRES); if (xsec_ncel) fNeutRW->AdoptWghtCalc("xsec_ncel", new neut::rew::NReWeightNuXSecNCEL); if (xsec_dis) fNeutRW->AdoptWghtCalc("xsec_dis", new neut::rew::NReWeightNuXSecDIS); #endif fNeutRW->Reconfigure(); olddir->cd(); // Set Abs Twk Config fIsAbsTwk = (FitPar::Config().GetParB("setabstwk")); // allow cout again StartTalking(); #else NUIS_ABORT("NEUT RW NOT ENABLED!"); #endif }; void NEUTWeightEngine::IncludeDial(std::string name, double startval) { #if defined(__NEUT_ENABLED__) and !defined(__NO_REWEIGHT__) // Get First enum int nuisenum = Reweight::ConvDial(name, kNEUT); // Setup Maps fEnumIndex[nuisenum]; // = std::vector(0); fNameIndex[name]; // = std::vector(0); // Split by commas std::vector allnames = GeneralUtils::ParseToStr(name, ","); for (uint i = 0; i < allnames.size(); i++) { std::string singlename = allnames[i]; // Get Syst #if __NEUT_VERSION__ < 541 neut::rew::NSyst_t gensyst = NSyst::FromString(singlename); #else neut::rew::NSyst_t gensyst = neut::rew::NSyst::FromString(singlename); #endif // Fill Maps int index = fValues.size(); fValues.push_back(0.0); fNEUTSysts.push_back(gensyst); // Initialize dial NUIS_LOG(FIT, "Registering " << singlename << " dial."); fNeutRW->Systematics().Init(fNEUTSysts[index]); // If Absolute if (fIsAbsTwk) { #if __NEUT_VERSION__ < 541 NSystUncertainty::Instance()->SetUncertainty(fNEUTSysts[index], 1.0, 1.0); #else neut::rew::NSystUncertainty::Instance()->SetUncertainty(fNEUTSysts[index], 1.0, 1.0); #endif } // Setup index fEnumIndex[nuisenum].push_back(index); fNameIndex[name].push_back(index); } // Set Value if given if (startval != _UNDEF_DIAL_VALUE_) { SetDialValue(nuisenum, startval); } #endif } void NEUTWeightEngine::SetDialValue(int nuisenum, double val) { #if defined(__NEUT_ENABLED__) and !defined(__NO_REWEIGHT__) std::vector indices = fEnumIndex[nuisenum]; for (uint i = 0; i < indices.size(); i++) { fValues[indices[i]] = val; NUIS_LOG(FIT, "Setting Dial Value for " << nuisenum << " " << i << " " << indices[i] << " " << fValues[indices[i]] << " Enum: " << fNEUTSysts[indices[i]]); fNeutRW->Systematics().Set(fNEUTSysts[indices[i]], val); } #endif } void NEUTWeightEngine::SetDialValue(std::string name, double val) { #if defined(__NEUT_ENABLED__) and !defined(__NO_REWEIGHT__) std::vector indices = fNameIndex[name]; for (uint i = 0; i < indices.size(); i++) { fValues[indices[i]] = val; NUIS_LOG(FIT, "Setting Dial Value for " << name << " = " << i << " " << indices[i] << " " << fValues[indices[i]] << " Enum: " << fNEUTSysts[indices[i]]); fNeutRW->Systematics().Set(fNEUTSysts[indices[i]], val); } #endif } void NEUTWeightEngine::Reconfigure(bool silent) { #if defined(__NEUT_ENABLED__) and !defined(__NO_REWEIGHT__) // Hush now... if (silent) StopTalking(); // Reconf fNeutRW->Reconfigure(); // if (LOG_LEVEL(DEB)){ fNeutRW->Print(); // } // Shout again if (silent) StartTalking(); #endif } double NEUTWeightEngine::CalcWeight(BaseFitEvt *evt) { double rw_weight = 1.0; #if defined(__NEUT_ENABLED__) and !defined(__NO_REWEIGHT__) // Skip Non NEUT if (evt->fType != kNEUT) return 1.0; // Hush now StopTalking(); // Fill NEUT Common blocks NEUTUtils::FillNeutCommons(evt->fNeutVect); // Call Weight calculation rw_weight = fNeutRW->CalcWeight(); // Speak Now StartTalking(); #endif + if (!std::isnormal(rw_weight)){ + NUIS_ERR(WRN, "NEUT returned weight: " << rw_weight); + rw_weight = 0; + } + // Return rw_weight return rw_weight; } diff --git a/src/Reweight/OscWeightEngine.cxx b/src/Reweight/OscWeightEngine.cxx index bf9331f..1224e02 100644 --- a/src/Reweight/OscWeightEngine.cxx +++ b/src/Reweight/OscWeightEngine.cxx @@ -1,331 +1,331 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ //#define DEBUG_OSC_WE #include "OscWeightEngine.h" #include enum nuTypes { kNuebarType = -1, kNumubarType = -2, kNutaubarType = -3, kNueType = 1, kNumuType = 2, kNutauType = 3, }; nuTypes GetNuType(int pdg) { switch (pdg) { case 16: return kNutauType; case 14: return kNumuType; case 12: return kNueType; case -16: return kNutaubarType; case -14: return kNumubarType; case -12: return kNuebarType; default: { NUIS_ABORT("Attempting to convert \"neutrino pdg\": " << pdg); } } } OscWeightEngine::OscWeightEngine() : #ifdef __PROB3PP_ENABLED__ bp(), #endif theta12(0.825), theta13(0.10), theta23(1.0), dm12(7.9e-5), dm23(2.5e-3), dcp(0.0), LengthParam(0xdeadbeef), TargetNuType(0), ForceFromNuPDG(0) { Config(); } void OscWeightEngine::Config() { std::vector OscParam = Config::QueryKeys("OscParam"); if (OscParam.size() < 1) { NUIS_ERR(WRN, "Oscillation parameters specified but no OscParam element " "configuring the experimental characteristics found.\nExpect at " "least . Pausing for " "10..."); sleep(10); return; } if (OscParam[0].Has("baseline_km")) { LengthParamIsZenith = false; LengthParam = OscParam[0].GetD("baseline_km"); constant_density = OscParam[0].Has("matter_density") ? OscParam[0].GetD("matter_density") : 0xdeadbeef; } else if (OscParam[0].Has("detection_zenith_deg")) { LengthParamIsZenith = true; static const double deg2rad = asin(1) / 90.0; LengthParam = cos(OscParam[0].GetD("detection_zenith_deg") * deg2rad); } else { NUIS_ERR(WRN, "It appeared that you wanted to set up an oscillation weight " "branch, but it was not correctly configured. You need to specify " "either: detection_zenith_deg or baseline_km attributes on the " "OscParam element, and if baseline_km is specified, you can " "optionally also set matter_density for oscillations through a " "constant matter density. Pausing for 10..."); sleep(10); return; } dm23 = OscParam[0].Has("dm23") ? OscParam[0].GetD("dm23") : dm23; theta23 = OscParam[0].Has("sinsq_theta23") ? OscParam[0].GetD("sinsq_theta23") : theta23; theta13 = OscParam[0].Has("sinsq_theta13") ? OscParam[0].GetD("sinsq_theta13") : theta13; dm12 = OscParam[0].Has("dm12") ? OscParam[0].GetD("dm12") : dm12; theta12 = OscParam[0].Has("sinsq_theta12") ? OscParam[0].GetD("sinsq_theta12") : theta12; dcp = OscParam[0].Has("dcp") ? OscParam[0].GetD("dcp") : dcp; TargetNuType = OscParam[0].Has("TargetNuPDG") ? GetNuType(OscParam[0].GetI("TargetNuPDG")) : 0; ForceFromNuPDG = OscParam[0].Has("ForceFromNuPDG") ? GetNuType(OscParam[0].GetI("ForceFromNuPDG")) : 0; NUIS_LOG(FIT, "Configured oscillation weighter:"); if (LengthParamIsZenith) { NUIS_LOG(FIT, "Earth density profile with detection cos(zenith) = " << LengthParam); } else { if (constant_density != 0xdeadbeef) { NUIS_LOG(FIT, "Constant density with experimental baseline = " << LengthParam); } else { NUIS_LOG(FIT, "Vacuum oscillations with experimental baseline = " << LengthParam); } } params[0] = dm23; params[1] = theta23; params[2] = theta13; params[3] = dm12; params[4] = theta12; params[5] = dcp; NUIS_LOG(FIT, "\tdm23 : " << params[0]); NUIS_LOG(FIT, "\tsinsq_theta23: " << params[1]); NUIS_LOG(FIT, "\tsinsq_theta13: " << params[2]); NUIS_LOG(FIT, "\tdm12 : " << params[3]); NUIS_LOG(FIT, "\tsinsq_theta12: " << params[4]); NUIS_LOG(FIT, "\tdcp : " << params[5]); if (TargetNuType) { NUIS_LOG(FIT, "\tTargetNuType: " << TargetNuType); } if (ForceFromNuPDG) { NUIS_LOG(FIT, "\tForceFromNuPDG: " << ForceFromNuPDG); } #ifdef __PROB3PP_ENABLED__ bp.SetMNS(params[theta12_idx], params[theta13_idx], params[theta23_idx], params[dm12_idx], params[dm23_idx], params[dcp_idx], 1, true, 2); bp.DefinePath(LengthParam, 0); if (LengthParamIsZenith) { NUIS_LOG(FIT, "\tBaseline : " << (bp.GetBaseline() / 100.0) << " km."); } #endif } void OscWeightEngine::IncludeDial(std::string name, double startval) { #ifdef DEBUG_OSC_WE std::cout << "IncludeDial: " << name << " at " << startval << std::endl; #endif int dial = SystEnumFromString(name); if (!dial) { NUIS_ABORT("OscWeightEngine passed dial: " << name << " that it does not understand."); } params[dial - 1] = startval; } void OscWeightEngine::SetDialValue(int nuisenum, double val) { #ifdef DEBUG_OSC_WE std::cout << "SetDial: " << (nuisenum % 1000) << " at " << val << std::endl; #endif fHasChanged = (params[(nuisenum % 1000) - 1] - val) > std::numeric_limits::epsilon(); params[(nuisenum % 1000) - 1] = val; } void OscWeightEngine::SetDialValue(std::string name, double val) { #ifdef DEBUG_OSC_WE std::cout << "SetDial: " << name << " at " << val << std::endl; #endif int dial = SystEnumFromString(name); if (!dial) { NUIS_ABORT("OscWeightEngine passed dial: " << name << " that it does not understand."); } fHasChanged = (params[dial - 1] - val) > std::numeric_limits::epsilon(); params[dial - 1] = val; } bool OscWeightEngine::IsDialIncluded(std::string name) { return SystEnumFromString(name); } bool OscWeightEngine::IsDialIncluded(int nuisenum) { return ((nuisenum % 1000) > 0) && ((nuisenum % 1000) < 6); } double OscWeightEngine::GetDialValue(std::string name) { int dial = SystEnumFromString(name); if (!dial) { NUIS_ABORT("OscWeightEngine passed dial: " << name << " that it does not understand."); } return params[dial - 1]; } double OscWeightEngine::GetDialValue(int nuisenum) { if (!(nuisenum % 1000) || (nuisenum % 1000) > 6) { NUIS_ABORT("OscWeightEngine passed dial enum: " << (nuisenum % 1000) << " that it does not understand, expected [1,6]."); } return params[(nuisenum % 1000) - 1]; } void OscWeightEngine::Reconfigure(bool silent) { fHasChanged = false; }; bool OscWeightEngine::NeedsEventReWeight() { if (fHasChanged) { return true; } return false; } double OscWeightEngine::CalcWeight(BaseFitEvt* evt) { static bool Warned = false; if (evt->probe_E == 0xdeadbeef) { if (!Warned) { NUIS_ERR(WRN, "Oscillation weights asked for but using 'litemode' or " "unsupported generator input. Pasuing for 10..."); sleep(10); Warned = true; } return 1; } return CalcWeight(evt->probe_E * 1E-3, evt->probe_pdg); } double OscWeightEngine::CalcWeight(double ENu, int PDGNu, int TargetPDGNu) { if (LengthParam == 0xdeadbeef) { // not configured. return 1; } #ifdef __PROB3PP_ENABLED__ int NuType = (ForceFromNuPDG != 0) ? ForceFromNuPDG : GetNuType(PDGNu); bp.SetMNS(params[theta12_idx], params[theta13_idx], params[theta23_idx], params[dm12_idx], params[dm23_idx], params[dcp_idx], ENu, true, NuType); int pmt = 0; double prob_weight = 1; TargetPDGNu = (TargetPDGNu == -1) ? (TargetNuType ? TargetNuType : NuType) : GetNuType(TargetPDGNu); if (LengthParamIsZenith) { // Use earth density bp.DefinePath(LengthParam, 0); bp.propagate(NuType); pmt = 0; prob_weight = bp.GetProb(NuType, TargetPDGNu); } else { if (constant_density != 0xdeadbeef) { bp.propagateLinear(NuType, LengthParam, constant_density); pmt = 1; prob_weight = bp.GetProb(NuType, TargetPDGNu); } else { pmt = 2; prob_weight = bp.GetVacuumProb(NuType, TargetPDGNu, ENu * 1E-3, LengthParam); } } #ifdef DEBUG_OSC_WE if (prob_weight != prob_weight) { NUIS_ABORT("Calculated bad prob weight: " << prob_weight << "(Osc Type: " << pmt << " -- " << NuType << " -> " << TargetPDGNu << ")"); } if (prob_weight > 1) { NUIS_ABORT("Calculated bad prob weight: " << prob_weight << "(Osc Type: " << pmt << " -- " << NuType << " -> " << TargetPDGNu << ")"); } std::cout << NuType << " -> " << TargetPDGNu << ": " << ENu << " = " << prob_weight << "%%." << std::endl; #endif return prob_weight; #else return 1; #endif } int OscWeightEngine::SystEnumFromString(std::string const& name) { if (name == "dm23") { return 1; } else if (name == "sinsq_theta23") { return 2; } else if (name == "sinsq_theta13") { return 3; } else if (name == "dm12") { return 4; } else if (name == "sinsq_theta12") { return 5; } else if (name == "dcp") { return 6; } else { return 0; } } void OscWeightEngine::Print() { std::cout << "OscWeightEngine: " << std::endl; std::cout << "\t theta12: " << params[theta12_idx] << std::endl; std::cout << "\t theta13: " << params[theta13_idx] << std::endl; std::cout << "\t theta23: " << params[theta23_idx] << std::endl; std::cout << "\t dm12: " << params[dm12_idx] << std::endl; std::cout << "\t dm23: " << params[dm23_idx] << std::endl; std::cout << "\t dcp: " << params[dcp_idx] << std::endl; } diff --git a/src/Reweight/OscWeightEngine.h b/src/Reweight/OscWeightEngine.h index 774fb99..5827248 100644 --- a/src/Reweight/OscWeightEngine.h +++ b/src/Reweight/OscWeightEngine.h @@ -1,144 +1,144 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitLogger.h" #include "FitEvent.h" #include "PhysConst.h" #include "WeightEngineBase.h" #ifdef __PROB3PP_ENABLED__ #include "BargerPropagator.h" #endif #include #ifdef __PROB3PP_ENABLED__ class BG : public BargerPropagator { public: BG() : BargerPropagator(){}; double GetBaseline() { return Earth->get_Pathlength(); } }; #endif class OscWeightEngine : public WeightEngineBase { enum params { dm23_idx = 0, theta23_idx, theta13_idx, dm12_idx, theta12_idx, dcp_idx, }; #ifdef __PROB3PP_ENABLED__ BG bp; #endif //******************************* Osc params ****************************** double theta12; double theta13; double theta23; /// The 1-2 mass squared splitting (small) [eV] double dm12; /// The 2-3 mass squared splitting (large) [eV] double dm23; /// The PMNS CP-violating phase double dcp; ///\brief The constant matter density used for simple given baseline /// oscillation [g/cm^3] double constant_density; /// Whether LengthParam corresponds to a Zenith or a baseline. /// /// If we just want to calculate the osc. prob. with a constant matter density /// then this should be false and constant_density should be set /// (or 0 for vacuum prob). bool LengthParamIsZenith; /// Either a path length or a post oscillation zenith angle /// /// N.B. For a beamline that has a dip angle of X degrees, the post /// oscillation zenith angle will be 90+X degrees. double LengthParam; /// Holds current value of oscillation parameters. double params[6]; /// The oscillation target type /// /// If unspecified in the element, it will default to /// disappearance probability. int TargetNuType; /// The initial neutrino species /// /// If unspecified in the element, it will be determined by /// the incoming events. int ForceFromNuPDG; public: OscWeightEngine(); /// Configures oscillation parameters from input xml file. /// /// Osc parameters configured from OscParam XML element as: /// /// /// /// If matter_density and baseline are present, then oscillation probability /// is calculated for a constant matter density. /// If detection_zenith_deg is present, then the baseline and density are /// calculated from the density profile and radius of the earth. /// If none are present, a vacuum oscillation is calculated. /// If TargetNuPDG is unspecified, oscillation will default to /// disappearance probability. void Config(); // Functions requiring Override void IncludeDial(std::string name, double startval); void SetDialValue(int nuisenum, double val); void SetDialValue(std::string name, double val); bool IsDialIncluded(std::string name); bool IsDialIncluded(int nuisenum); double GetDialValue(std::string name); double GetDialValue(int nuisenum); void Reconfigure(bool silent); bool NeedsEventReWeight(); double CalcWeight(BaseFitEvt* evt); /// ENu [GeV] double CalcWeight(double ENu, int PDGNu, int TargetPDGNu = -1); static int SystEnumFromString(std::string const& name); void Print(); }; diff --git a/src/Reweight/T2KWeightEngine.cxx b/src/Reweight/T2KWeightEngine.cxx index 938958d..8f957d6 100644 --- a/src/Reweight/T2KWeightEngine.cxx +++ b/src/Reweight/T2KWeightEngine.cxx @@ -1,153 +1,158 @@ #include "T2KWeightEngine.h" #ifdef __T2KREW_ENABLED__ #include "T2KNeutUtils.h" #endif T2KWeightEngine::T2KWeightEngine(std::string name) { #ifdef __T2KREW_ENABLED__ #if defined(__NEUT_VERSION__) && (__NEUT_VERSION__ >= 541) std::string neut_card = FitPar::Config().GetParS("NEUT_CARD"); if (!neut_card.size()) { NUIS_ABORT( "[ERROR]: When using T2KReWeight must set NEUT_CARD config option."); } // No need to vomit the contents of the card file all over my screen StopTalking(); t2krew::T2KNeutUtils::SetCardFile(neut_card); StartTalking(); #endif // Setup the NEUT Reweight engien fCalcName = name; - NUIS_LOG(FIT, "Setting up T2K RW : " << fCalcName); + NUIS_LOG(FIT, "Setting up T2K RW: " << fCalcName); // Create RW Engine suppressing cout StopTalking(); // Create Main RW Engine fT2KRW = new t2krew::T2KReWeight(); // Setup Sub RW Engines (Only activated for neut and niwg) fT2KNeutRW = new t2krew::T2KNeutReWeight(); fT2KNIWGRW = new t2krew::T2KNIWGReWeight(); fT2KRW->AdoptWghtEngine("fNeutRW", fT2KNeutRW); fT2KRW->AdoptWghtEngine("fNIWGRW", fT2KNIWGRW); fT2KRW->Reconfigure(); // allow cout again StartTalking(); // Set Abs Twk Config fIsAbsTwk = (FitPar::Config().GetParB("setabstwk")); #else NUIS_ABORT("T2K RW NOT ENABLED"); #endif }; void T2KWeightEngine::IncludeDial(std::string name, double startval) { #ifdef __T2KREW_ENABLED__ // Get First enum int nuisenum = Reweight::ConvDial(name, kT2K); // Setup Maps fEnumIndex[nuisenum]; // = std::vector(0); fNameIndex[name]; // = std::vector(0); // Split by commas std::vector allnames = GeneralUtils::ParseToStr(name, ","); for (uint i = 0; i < allnames.size(); i++) { std::string singlename = allnames[i]; // Get RW t2krew::T2KSyst_t gensyst = t2krew::T2KSyst::FromString(name); // Fill Maps int index = fValues.size(); fValues.push_back(0.0); fT2KSysts.push_back(gensyst); // Initialize dial - std::cout << "Registering " << singlename << " from " << name << std::endl; + NUIS_LOG(REC, "Registering " << singlename << " from " << name); fT2KRW->Systematics().Include(gensyst); // If Absolute if (fIsAbsTwk) { fT2KRW->Systematics().SetAbsTwk(gensyst); } // Setup index fEnumIndex[nuisenum].push_back(index); fNameIndex[name].push_back(index); } // Set Value if given if (startval != _UNDEF_DIAL_VALUE_) { SetDialValue(nuisenum, startval); } #endif } void T2KWeightEngine::SetDialValue(int nuisenum, double val) { #ifdef __T2KREW_ENABLED__ std::vector indices = fEnumIndex[nuisenum]; for (uint i = 0; i < indices.size(); i++) { fValues[indices[i]] = val; fT2KRW->Systematics().SetTwkDial(fT2KSysts[indices[i]], val); } #endif } void T2KWeightEngine::SetDialValue(std::string name, double val) { #ifdef __T2KREW_ENABLED__ std::vector indices = fNameIndex[name]; for (uint i = 0; i < indices.size(); i++) { fValues[indices[i]] = val; fT2KRW->Systematics().SetTwkDial(fT2KSysts[indices[i]], val); } #endif } void T2KWeightEngine::Reconfigure(bool silent) { #ifdef __T2KREW_ENABLED__ // Hush now... if (silent) StopTalking(); // Reconf StopTalking(); fT2KRW->Reconfigure(); StartTalking(); // Shout again if (silent) StartTalking(); #endif } double T2KWeightEngine::CalcWeight(BaseFitEvt *evt) { double rw_weight = 1.0; #ifdef __T2KREW_ENABLED__ - // Skip Non GENIE + // Skip Non-NEUT if (evt->fType != kNEUT){ return 1.0; } // Hush now StopTalking(); // Get Weight For NEUT rw_weight = fT2KRW->CalcWeight(evt->fNeutVect); // Speak Now StartTalking(); #endif + if (!std::isnormal(rw_weight)){ + NUIS_ERR(WRN, "NEUT returned weight: " << rw_weight); + rw_weight = 0; + } + // Return rw_weight return rw_weight; } diff --git a/src/Reweight/nusystematicsWeightEngine.cxx b/src/Reweight/nusystematicsWeightEngine.cxx index 8cba88a..a81a5cf 100644 --- a/src/Reweight/nusystematicsWeightEngine.cxx +++ b/src/Reweight/nusystematicsWeightEngine.cxx @@ -1,173 +1,173 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "nusystematicsWeightEngine.h" #include #include nusystematicsWeightEngine::nusystematicsWeightEngine() { fUseCV = false; Config(); } void nusystematicsWeightEngine::Config() { std::vector DuneRwtParam = Config::QueryKeys("DUNERwt"); if (DuneRwtParam.size() < 1) { NUIS_ABORT( "Instantiaged nusystematicsWeightEngine but without specifying a " "DUNERwt element that leads the way to the configuration."); } std::string fhicl_name = DuneRwtParam.front().GetS("ConfigFHiCL"); DUNErwt.LoadConfiguration(fhicl_name); } systtools::paramId_t const kNuSystCVResponse = 999; int nusystematicsWeightEngine::ConvDial(std::string name) { if (name == "NuSystCVResponse") { return kNuSystCVResponse; } if (!DUNErwt.HaveHeader(name)) { NUIS_ABORT("nusystematicsWeightEngine passed dial: " << name << " that it does not understand."); } return DUNErwt.GetHeaderId(name); } void nusystematicsWeightEngine::IncludeDial(std::string name, double startval) { systtools::paramId_t DuneRwtEnum(ConvDial(name)); if (DuneRwtEnum == kNuSystCVResponse) { fUseCV = true; } EnabledParams.push_back({DuneRwtEnum, startval}); } void nusystematicsWeightEngine::SetDialValue(int nuisenum, double val) { systtools::paramId_t DuneRwtEnum = (nuisenum % 1000); if (DuneRwtEnum == kNuSystCVResponse) { return; } systtools::ParamValue &pval = GetParamElementFromContainer(EnabledParams, DuneRwtEnum); fHasChanged = (pval.val - val) > std::numeric_limits::epsilon(); pval.val = val; } void nusystematicsWeightEngine::SetDialValue(std::string name, double val) { if (!IsDialIncluded(name)) { NUIS_ABORT("nusystematicsWeightEngine passed dial: " << name << " that is not enabled."); } systtools::paramId_t DuneRwtEnum(ConvDial(name)); if (DuneRwtEnum == kNuSystCVResponse) { return; } systtools::ParamValue &pval = GetParamElementFromContainer(EnabledParams, DuneRwtEnum); fHasChanged = (pval.val - val) > std::numeric_limits::epsilon(); pval.val = val; } bool nusystematicsWeightEngine::IsDialIncluded(std::string name) { return IsDialIncluded(ConvDial(name)); } bool nusystematicsWeightEngine::IsDialIncluded(int nuisenum) { systtools::paramId_t DuneRwtEnum = (nuisenum % 1000); if (DuneRwtEnum == kNuSystCVResponse) { return fUseCV; } return systtools::ContainterHasParam(EnabledParams, DuneRwtEnum); } double nusystematicsWeightEngine::GetDialValue(std::string name) { if (!IsDialIncluded(name)) { NUIS_ABORT("nusystematicsWeightEngine passed dial: " << name << " that is not enabled."); } systtools::ParamValue &pval = GetParamElementFromContainer(EnabledParams, ConvDial(name)); return pval.val; } double nusystematicsWeightEngine::GetDialValue(int nuisenum) { if (!IsDialIncluded(nuisenum)) { NUIS_ABORT("nusystematicsWeightEngine passed dial: " << nuisenum << " that is not enabled."); } systtools::paramId_t DuneRwtEnum = (nuisenum % 1000); if (DuneRwtEnum == kNuSystCVResponse) { return 1; } systtools::ParamValue &pval = GetParamElementFromContainer(EnabledParams, DuneRwtEnum); return pval.val; } void nusystematicsWeightEngine::Reconfigure(bool silent) { fHasChanged = false; }; bool nusystematicsWeightEngine::NeedsEventReWeight() { if (fHasChanged) { return true; } return false; } double nusystematicsWeightEngine::CalcWeight(BaseFitEvt *evt) { systtools::event_unit_response_w_cv_t responses = DUNErwt.GetEventVariationAndCVResponse(*evt->genie_event->event); double weight = 1; for (auto const &resp : responses) { if (!DUNErwt.IsWeightResponse(resp.pid)) { continue; } if (fUseCV) { weight *= resp.CV_response; } else { // This is very inefficient for fitting, as it recalculates the // spline every time. systtools::ParamValue const &pval = GetParamElementFromContainer(EnabledParams, resp.pid); weight *= (resp.CV_response * DUNErwt.GetParameterResponse(resp.pid, pval.val, systtools::event_unit_response_t{ {resp.pid, resp.responses}})); } } return weight; } void nusystematicsWeightEngine::Print() { std::cout << "nusystematicsWeightEngine: " << std::endl; } diff --git a/src/Reweight/nusystematicsWeightEngine.h b/src/Reweight/nusystematicsWeightEngine.h index 319f813..93d19af 100644 --- a/src/Reweight/nusystematicsWeightEngine.h +++ b/src/Reweight/nusystematicsWeightEngine.h @@ -1,66 +1,66 @@ #ifndef nusystWeightEngine_SEEN #define nusystWeightEngine_SEEN -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "WeightEngineBase.h" #include "systematicstools/interface/types.hh" #include "nusystematics/artless/response_helper.hh" #include class nusystematicsWeightEngine : public WeightEngineBase { public: nusystematicsWeightEngine(); nusyst::response_helper DUNErwt; systtools::param_value_list_t EnabledParams; void Config(); int ConvDial(std::string name); // Functions requiring Override void IncludeDial(std::string name, double startval); void SetDialValue(int nuisenum, double val); void SetDialValue(std::string name, double val); bool IsDialIncluded(std::string name); bool IsDialIncluded(int nuisenum); double GetDialValue(std::string name); double GetDialValue(int nuisenum); void Reconfigure(bool silent); bool NeedsEventReWeight(); double CalcWeight(BaseFitEvt* evt); void Print(); bool fUseCV; }; #endif diff --git a/src/Routines/._CMakeLists.txt~ b/src/Routines/._CMakeLists.txt~ deleted file mode 100644 index 89a44f4..0000000 Binary files a/src/Routines/._CMakeLists.txt~ and /dev/null differ diff --git a/src/Routines/BayesianRoutines.cxx b/src/Routines/BayesianRoutines.cxx index 50d951c..dc1953c 100755 --- a/src/Routines/BayesianRoutines.cxx +++ b/src/Routines/BayesianRoutines.cxx @@ -1,518 +1,518 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BayesianRoutines.h" void BayesianRoutines::Init() { fInputFile = ""; fInputRootFile = NULL; fOutputFile = ""; fOutputRootFile = NULL; fStrategy = "BayesianThrows"; fRoutines.clear(); fRoutines.push_back("BayesianThrows"); fCardFile = ""; fFakeDataInput = ""; fSampleFCN = NULL; fAllowedRoutines = ("f"); }; BayesianRoutines::~BayesianRoutines(){}; BayesianRoutines::BayesianRoutines(int argc, char *argv[]) { // Initialise Defaults Init(); nuisconfig configuration = Config::Get(); // Default containers std::string cardfile = ""; std::string maxevents = "-1"; int errorcount = 0; int verbocount = 0; std::vector xmlcmds; std::vector configargs; fNThrows = 250; fStartThrows = 0; fThrowString = ""; // Make easier to handle arguments. std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); ParserUtils::ParseArgument(args, "-c", fCardFile, true); ParserUtils::ParseArgument(args, "-o", fOutputFile, false, false); ParserUtils::ParseArgument(args, "-n", maxevents, false, false); ParserUtils::ParseArgument(args, "-f", fStrategy, false, false); ParserUtils::ParseArgument(args, "-t", fNThrows, false, false); ParserUtils::ParseArgument(args, "-i", xmlcmds); ParserUtils::ParseArgument(args, "-q", configargs); ParserUtils::ParseCounter(args, "e", errorcount); ParserUtils::ParseCounter(args, "v", verbocount); ParserUtils::CheckBadArguments(args); // Add extra defaults if none given if (fCardFile.empty() and xmlcmds.empty()) { NUIS_ABORT("No input supplied!"); } if (fOutputFile.empty() and !fCardFile.empty()) { fOutputFile = fCardFile + ".root"; NUIS_ERR(WRN, "No output supplied so saving it to: " << fOutputFile); } else if (fOutputFile.empty()) { NUIS_ABORT("No output file or cardfile supplied!"); } // Configuration Setup ============================= // Check no comp key is available if (Config::Get().GetNodes("nuiscomp").empty()) { fCompKey = Config::Get().CreateNode("nuiscomp"); } else { fCompKey = Config::Get().GetNodes("nuiscomp")[0]; } if (!fCardFile.empty()) fCompKey.Set("cardfile", fCardFile); if (!fOutputFile.empty()) fCompKey.Set("outputfile", fOutputFile); if (!fStrategy.empty()) fCompKey.Set("strategy", fStrategy); // Load XML Cardfile configuration.LoadSettings(fCompKey.GetS("cardfile"), ""); // Add Config Args for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } if (maxevents.compare("-1")) { configuration.OverrideConfig("MAXEVENTS=" + maxevents); } // Finish configuration XML configuration.FinaliseSettings(fCompKey.GetS("outputfile") + ".xml"); // Add Error Verbo Lines verbocount += Config::GetParI("VERBOSITY"); errorcount += Config::GetParI("ERROR"); std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; SETVERBOSITY(verbocount); // Proper Setup if (fStrategy.find("ErrorBands") != std::string::npos || fStrategy.find("MergeErrors") != std::string::npos) { fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); } // fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), // "RECREATE"); SetupSystematicsFromXML(); SetupRWEngine(); SetupFCN(); return; }; void BayesianRoutines::SetupSystematicsFromXML() { NUIS_LOG(FIT, "Setting up nuismin"); // Setup Parameters ------------------------------------------ std::vector parkeys = Config::QueryKeys("parameter"); if (!parkeys.empty()) { NUIS_LOG(FIT, "Number of parameters : " << parkeys.size()); } for (size_t i = 0; i < parkeys.size(); i++) { nuiskey key = parkeys.at(i); // Check for type,name,nom if (!key.Has("type")) { NUIS_ABORT("No type given for parameter " << i); } else if (!key.Has("name")) { NUIS_ABORT("No name given for parameter " << i); } else if (!key.Has("nominal")) { NUIS_ABORT("No nominal given for parameter " << i); } // Get Inputs std::string partype = key.GetS("type"); std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); double parlow = parnom - 1; double parhigh = parnom + 1; double parstep = 1; // Override if state not given if (!key.Has("state")) { key.SetS("state", "FIX"); } std::string parstate = key.GetS("state"); // Extra limits if (key.Has("low")) { parlow = key.GetD("low"); parhigh = key.GetD("high"); parstep = key.GetD("step"); NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parlow << " < p < " << parhigh << " : " << parstate); } else { NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parstate); } // Run Parameter Conversion if needed if (parstate.find("ABS") != std::string::npos) { parnom = FitBase::RWAbsToSigma(partype, parname, parnom); parlow = FitBase::RWAbsToSigma(partype, parname, parlow); parhigh = FitBase::RWAbsToSigma(partype, parname, parhigh); parstep = FitBase::RWAbsToSigma(partype, parname, parstep); } else if (parstate.find("FRAC") != std::string::npos) { parnom = FitBase::RWFracToSigma(partype, parname, parnom); parlow = FitBase::RWFracToSigma(partype, parname, parlow); parhigh = FitBase::RWFracToSigma(partype, parname, parhigh); parstep = FitBase::RWFracToSigma(partype, parname, parstep); } // Push into vectors fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); ; fStartVals[parname] = parnom; fCurVals[parname] = parnom; fErrorVals[parname] = 0.0; fStateVals[parname] = parstate; bool fixstate = parstate.find("FIX") != std::string::npos; fFixVals[parname] = fixstate; fStartFixVals[parname] = fFixVals[parname]; fMinVals[parname] = parlow; fMaxVals[parname] = parhigh; fStepVals[parname] = parstep; } // Setup Samples ---------------------------------------------- std::vector samplekeys = Config::QueryKeys("sample"); if (!samplekeys.empty()) { NUIS_LOG(FIT, "Number of samples : " << samplekeys.size()); } else { NUIS_ERR(WRN, "NO SAMPLES LOADED"); } for (size_t i = 0; i < samplekeys.size(); i++) { nuiskey key = samplekeys.at(i); // Get Sample Options std::string samplename = key.GetS("name"); std::string samplefile = key.GetS("input"); std::string sampletype = key.Has("type") ? key.GetS("type") : "DEFAULT"; double samplenorm = key.Has("norm") ? key.GetD("norm") : 1.0; // Print out NUIS_LOG(FIT, "Read sample info " << i << " : " << samplename << std::endl << "\t\t input -> " << samplefile << std::endl << "\t\t state -> " << sampletype << std::endl << "\t\t norm -> " << samplenorm); // If FREE add to parameters otherwise continue if (sampletype.find("FREE") == std::string::npos) { continue; } // Form norm dial from samplename + sampletype + "_norm"; std::string normname = samplename + "_norm"; // Check normname not already present if (fTypeVals.find(normname) != fTypeVals.end()) { continue; } // Add new norm dial to list if its passed above checks fParams.push_back(normname); fTypeVals[normname] = kNORM; fStateVals[normname] = sampletype; fCurVals[normname] = samplenorm; fErrorVals[normname] = 0.0; fMinVals[normname] = 0.1; fMaxVals[normname] = 10.0; fStepVals[normname] = 0.5; bool state = sampletype.find("FREE") == std::string::npos; fFixVals[normname] = state; fStartFixVals[normname] = state; } // Setup Fake Parameters ----------------------------- std::vector fakekeys = Config::QueryKeys("fakeparameter"); if (!fakekeys.empty()) { NUIS_LOG(FIT, "Number of fake parameters : " << fakekeys.size()); } for (size_t i = 0; i < fakekeys.size(); i++) { nuiskey key = fakekeys.at(i); // Check for type,name,nom if (!key.Has("name")) { NUIS_ABORT("No name given for fakeparameter " << i); } else if (!key.Has("nom")) { NUIS_ABORT("No nominal given for fakeparameter " << i); } // Get Inputs std::string parname = key.GetS("name"); double parnom = key.GetD("nom"); // Push into vectors fFakeVals[parname] = parnom; } } /* Setup Functions */ //************************************* void BayesianRoutines::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 BayesianRoutines::SetupFCN() { //************************************* NUIS_LOG(FIT, "Making the jointFCN"); if (fSampleFCN) delete fSampleFCN; fSampleFCN = new JointFCN(fOutputRootFile); fInputThrows = fSampleFCN->GetPullList(); return; } /* Fitting Functions */ //************************************* void BayesianRoutines::UpdateRWEngine( std::map &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 BayesianRoutines::ThrowParameters() { //************************************* // 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(); } // Now update Parameters UpdateRWEngine(fThrownVals); // Update Pulls for (PullListConstIter iter = fInputThrows.begin(); iter != fInputThrows.end(); iter++) { ParamPull *pull = *iter; pull->Reconfigure(); } return; }; //************************************* void BayesianRoutines::Run() { //************************************* std::cout << "Running routines " << std::endl; fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); for (UInt_t i = 0; i < fRoutines.size(); i++) { std::string routine = fRoutines.at(i); NUIS_LOG(FIT, "Running Routine: " << routine); if (!routine.compare("BayesianThrows")) GenerateThrows(); else { NUIS_ABORT("UNKNOWN ROUTINE " << routine); } } return; } //************************************* void BayesianRoutines::GenerateThrows() { //************************************* // Create a new output file TFile *outfile = new TFile((fOutputFile + ".throws.root").c_str(), "RECREATE"); outfile->cd(); int nthrows = fNThrows; // Setting Seed // Matteo Mazzanti's Fix struct timeval mytime; gettimeofday(&mytime, NULL); Double_t seed = time(NULL) + int(getpid()) + (mytime.tv_sec * 1000.) + (mytime.tv_usec / 1000.); gRandom->SetSeed(seed); NUIS_LOG(FIT, "Using Seed : " << seed); NUIS_LOG(FIT, "nthrows = " << nthrows); // Run the Initial Reconfigure NUIS_LOG(FIT, "Making nominal prediction "); TDirectory *nominal = (TDirectory *)outfile->mkdir("nominal"); nominal->cd(); UpdateRWEngine(fStartVals); fSampleFCN->ReconfigureUsingManager(); fSampleFCN->Write(); // Create an iteration tree inside SampleFCN fSampleFCN->CreateIterationTree("error_iterations", FitBase::GetRW()); // Create a new iteration TTree TTree *LIKETREE = new TTree("likelihood", "likelihood"); std::vector likenames = fSampleFCN->GetAllNames(); std::vector likevals = fSampleFCN->GetAllLikelihoods(); std::vector likendof = fSampleFCN->GetAllNDOF(); double *LIKEVALS = new double[likevals.size()]; int *LIKENDOF = new int[likendof.size()]; for (size_t i = 0; i < likendof.size(); i++) { LIKETREE->Branch((likenames[i] + "_likelihood").c_str(), &LIKEVALS[i], (likenames[i] + "_likelihood/D").c_str()); LIKETREE->Branch((likenames[i] + "_ndof").c_str(), &LIKENDOF[i], (likenames[i] + "_ndof/I").c_str()); LIKENDOF[i] = likendof[i]; } likenames.clear(); likevals.clear(); likendof.clear(); double *PARAMVALS = new double[fParams.size()]; for (size_t i = 0; i < fParams.size(); i++) { LIKETREE->Branch(fParams[i].c_str(), &PARAMVALS[i], (fParams[i] + "/D").c_str()); } // Run Throws and save for (Int_t i = 0; i < nthrows; i++) { // Skip the start throw if (i == 0) continue; NUIS_LOG(FIT, "Throw " << i << " ================================"); // Throw Parameters ThrowParameters(); FitBase::GetRW()->Print(); // Get Parameter Values for (size_t i = 0; i < fParams.size(); i++) { PARAMVALS[i] = fThrownVals[fParams[i]]; } // Run Sample Prediction fSampleFCN->ReconfigureFastUsingManager(); // Get vector of likelihoods/ndof std::vector likevals = fSampleFCN->GetAllLikelihoods(); for (size_t i = 0; i < likevals.size(); i++) { LIKEVALS[i] = likevals[i]; } // Save to TTree LIKETREE->Fill(); // Save the FCN // if (fSavePredictions){ SaveSamplePredictions(); } NUIS_LOG(FIT, "END OF THROW ================================"); } // Finish up outfile->cd(); LIKETREE->Write(); outfile->Close(); delete LIKEVALS; delete LIKENDOF; delete PARAMVALS; } diff --git a/src/Routines/BayesianRoutines.h b/src/Routines/BayesianRoutines.h index 777e716..d57eef9 100755 --- a/src/Routines/BayesianRoutines.h +++ b/src/Routines/BayesianRoutines.h @@ -1,183 +1,183 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BAYESIAN_ROUTINES_H #define BAYESIAN_ROUTINES_H /*! * \addtogroup Minimizer * @{ */ #include "TH1.h" #include "TF1.h" #include "TMatrixD.h" #include "TVectorD.h" #include "TSystem.h" #include "TFile.h" #include "TProfile.h" #include #include #include #include #include #include #include "FitEvent.h" #include "JointFCN.h" #include "ParserUtils.h" enum minstate { kErrorStatus = -1, kGoodStatus, kFitError, kNoChange, kFitFinished, kFitUnfinished, kStateChange, }; //************************************* //! Collects all possible fit routines into a single class to avoid repeated code class BayesianRoutines{ //************************************* public: /* Constructor/Destructor */ //! Constructor reads in arguments given at the command line for the fit here. BayesianRoutines(int argc, char* argv[]); //! Default destructor ~BayesianRoutines(); //! Reset everything to default/NULL void Init(); /* Input Functions */ //! Splits the arguments ready for initial setup void ParseArgs(int argc, char* argv[]); //! Sorts out configuration and verbosity right at the very start. //! Calls readCard to set everything else up. void InitialSetup(); /* Setup Functions */ void SetupSystematicsFromXML(); //! Setups up our custom RW engine with all the parameters passed in the card file void SetupRWEngine(); //! Setups up the jointFCN. void SetupFCN(); /* Fitting Functions */ //! Main function to actually start iterating over the different required fit routines void Run(); //! Given a new map change the values that the RW engine is currently set to void UpdateRWEngine(std::map& updateVals); //! Given a single routine (see tutorial for options) run that fit routine now. int RunFitRoutine(std::string routine); //! Throw the current covariance of dial values we have, and fill the thrownVals and thrownNorms maps. //! If uniformly is true parameters will be thrown uniformly between their upper and lower limits. void ThrowParameters(); //! Run Throws void GenerateThrows(); protected: //! Our Custom ReWeight Object FitWeight* rw; std::string fOutputFile; std::string fInputFile; TFile* fInputRootFile; TFile* fOutputRootFile; //! Flag for whether the fit should be continued if an output file is already found. bool fitContinue; //! Minimizer Object for handling roots different minimizer methods JointFCN* fSampleFCN; int nfreepars; std::string fCardFile; std::string fStrategy; std::vector fRoutines; std::string fAllowedRoutines; std::string fFakeDataInput; // Input Dial Vals //! Vector of dial names std::vector fParams; std::map fStateVals; std::map fStartVals; std::map fCurVals; std::map fErrorVals; std::map fMinVals; std::map fMaxVals; std::map fStepVals; std::map fTypeVals; std::map fFixVals; std::map fStartFixVals; //! Vector of fake parameter names std::map fFakeVals; //! Map of thrown parameter names and values (After ThrowCovariance) std::map fThrownVals; std::list fInputThrows; //!< Pointers to pull terms std::vector fInputDials; //!< Vector of Input Histograms std::vector fInputCovar; //!< Vector of Input Covariances nuiskey fCompKey; std::vector fThrowList; std::string fThrowString; int fNThrows; int fStartThrows; }; /*! @} */ #endif diff --git a/src/Routines/CMakeLists.txt b/src/Routines/CMakeLists.txt index f55444f..9aeada1 100644 --- a/src/Routines/CMakeLists.txt +++ b/src/Routines/CMakeLists.txt @@ -1,68 +1,68 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES ComparisonRoutines.cxx SystematicRoutines.cxx SplineRoutines.cxx BayesianRoutines.cxx ) if(USE_MINIMIZER) set(IMPLFILES ${IMPLFILES};MinimizerRoutines.cxx) endif() set(HEADERFILES ComparisonRoutines.h SystematicRoutines.h BayesianRoutines.h SplineRoutines.h ) if(USE_MINIMIZER) set(HEADERFILES ${HEADERFILES};MinimizerRoutines.h) endif() set(LIBNAME Routines) 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(${EXP_INCLUDE_DIRECTORIES}) include_directories(${MINIMUM_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/FCN) include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Routines) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Routines/ComparisonRoutines.cxx b/src/Routines/ComparisonRoutines.cxx index f91778a..0b3236d 100755 --- a/src/Routines/ComparisonRoutines.cxx +++ b/src/Routines/ComparisonRoutines.cxx @@ -1,637 +1,658 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ComparisonRoutines.h" /* Constructor/Destructor */ //************************ void ComparisonRoutines::Init() { //************************ fOutputFile = ""; fOutputRootFile = NULL; fStrategy = "Compare"; fRoutines.clear(); fCardFile = ""; fFakeDataInput = ""; fSampleFCN = NULL; fAllowedRoutines = ("Compare"); }; //************************************* ComparisonRoutines::~ComparisonRoutines() { //************************************* delete fOutputRootFile; }; /* Input Functions */ //************************************* ComparisonRoutines::ComparisonRoutines(int argc, char *argv[]) { //************************************* // Initialise Defaults Init(); nuisconfig configuration = Config::Get(); // Default containers std::string cardfile = ""; std::string maxevents = "-1"; std::string skipevents = "0"; int errorcount = 0; int verbocount = 0; std::vector xmlcmds; std::vector configargs; // Make easier to handle arguments. std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); ParserUtils::ParseArgument(args, "-c", fCardFile, true); ParserUtils::ParseArgument(args, "-o", fOutputFile, false, false); ParserUtils::ParseArgument(args, "-n", maxevents, false, false); ParserUtils::ParseArgument(args, "-f", fStrategy, false, false); ParserUtils::ParseArgument(args, "-d", fFakeDataInput, false, false); ParserUtils::ParseArgument(args, "-i", xmlcmds); ParserUtils::ParseArgument(args, "-q", configargs); ParserUtils::ParseArgument(args, "-s", skipevents); ParserUtils::ParseCounter(args, "e", errorcount); ParserUtils::ParseCounter(args, "v", verbocount); ParserUtils::CheckBadArguments(args); // Add extra defaults if none given if (fCardFile.empty() and xmlcmds.empty()) { NUIS_ABORT("No input supplied!"); } if (fOutputFile.empty() and !fCardFile.empty()) { fOutputFile = fCardFile + ".root"; NUIS_ERR(WRN, "No output supplied so saving it to: " << fOutputFile); } else if (fOutputFile.empty()) { NUIS_ABORT("No output file or cardfile supplied!"); } // Configuration Setup ============================= // Check no comp key is available nuiskey fCompKey; if (Config::Get().GetNodes("nuiscomp").empty()) { fCompKey = Config::Get().CreateNode("nuiscomp"); } else { fCompKey = Config::Get().GetNodes("nuiscomp")[0]; } if (!fCardFile.empty()) fCompKey.Set("cardfile", fCardFile); if (!fOutputFile.empty()) fCompKey.Set("outputfile", fOutputFile); if (!fStrategy.empty()) fCompKey.Set("strategy", fStrategy); // Load XML Cardfile configuration.LoadSettings(fCompKey.GetS("cardfile"), ""); // Add Config Args for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } if (maxevents.compare("-1")) { configuration.OverrideConfig("MAXEVENTS=" + maxevents); } configuration.OverrideConfig("NSKIPEVENTS=" + skipevents); // Finish configuration XML configuration.FinaliseSettings(fCompKey.GetS("outputfile") + ".xml"); // Add Error Verbo Lines verbocount += Config::GetParI("VERBOSITY"); errorcount += Config::GetParI("ERROR"); bool trace = Config::GetParB("TRACE"); std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; SETVERBOSITY(verbocount); SETTRACE(trace); // Comparison Setup ======================================== // Proper Setup fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); SetupComparisonsFromXML(); SetupRWEngine(); SetupFCN(); return; }; //************************************* void ComparisonRoutines::SetupComparisonsFromXML() { //************************************* NUIS_LOG(FIT, "Setting up nuiscomp"); // Setup Parameters ------------------------------------------ std::vector parkeys = Config::QueryKeys("parameter"); if (!parkeys.empty()) { NUIS_LOG(FIT, "Number of parameters : " << parkeys.size()); } for (size_t i = 0; i < parkeys.size(); i++) { nuiskey key = parkeys.at(i); // Check for type,name,nom if (!key.Has("type")) { NUIS_ERR(FTL, "No type given for parameter " << i); NUIS_ABORT("type='PARAMETER_TYPE'"); } else if (!key.Has("name")) { NUIS_ERR(FTL, "No name given for parameter " << i); NUIS_ABORT("name='SAMPLE_NAME'"); } else if (!key.Has("nominal")) { NUIS_ERR(FTL, "No nominal given for parameter " << i); NUIS_ABORT("nominal='NOMINAL_VALUE'"); } // Get Inputs std::string partype = key.GetS("type"); std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); double parlow = parnom - 1; double parhigh = parnom + 1; double parstep = 1; // override if state not given if (!key.Has("state")) { key.SetS("state", "FIX"); } std::string parstate = key.GetS("state"); // Check for incomplete limtis int limdef = ((int)key.Has("low") + (int)key.Has("high") + (int)key.Has("step")); if (limdef > 0 and limdef < 3) { NUIS_ERR(FTL, "Incomplete limit set given for parameter : " << parname); NUIS_ABORT( "Requires: low='LOWER_LIMIT' high='UPPER_LIMIT' step='STEP_SIZE' "); } // Extra limits if (key.Has("low")) { parlow = key.GetD("low"); parhigh = key.GetD("high"); parstep = key.GetD("step"); NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parlow << " < p < " << parhigh << " : " << parstate); } else { NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parstate); } bool ismirr = false; if (key.Has("mirror_point")) { ismirr = true; mirror_param mir; mir.mirror_value = key.GetD("mirror_point"); mir.mirror_above = key.GetB("mirror_above"); fMirroredParams[parname] = mir; NUIS_LOG(FIT, "\t\t" << parname << " is mirrored at " << mir.mirror_value << " " << (mir.mirror_above ? "from above" : "from below")); } // Convert if required if (parstate.find("ABS") != std::string::npos) { if (ismirr) { NUIS_ABORT("Cannot mirror parameters with ABS state!"); } parnom = FitBase::RWAbsToSigma(partype, parname, parnom); parlow = FitBase::RWAbsToSigma(partype, parname, parlow); parhigh = FitBase::RWAbsToSigma(partype, parname, parhigh); parstep = FitBase::RWAbsToSigma(partype, parname, parstep); } else if (parstate.find("FRAC") != std::string::npos) { if (ismirr) { NUIS_ABORT("Cannot mirror parameters with FRAC state!"); } parnom = FitBase::RWFracToSigma(partype, parname, parnom); parlow = FitBase::RWFracToSigma(partype, parname, parlow); parhigh = FitBase::RWFracToSigma(partype, parname, parhigh); parstep = FitBase::RWFracToSigma(partype, parname, parstep); } // Push into vectors fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fCurVals[parname] = parnom; fStateVals[parname] = parstate; } // Setup Samples ---------------------------------------------- std::vector samplekeys = Config::QueryKeys("sample"); if (!samplekeys.empty()) { NUIS_LOG(FIT, "Number of samples : " << samplekeys.size()); } for (size_t i = 0; i < samplekeys.size(); i++) { nuiskey key = samplekeys.at(i); // Get Sample Options std::string samplename = key.GetS("name"); std::string samplefile = key.GetS("input"); - std::string sampletype = key.Has("type") ? key.GetS("type") : "DEFAULT"; - double samplenorm = key.Has("norm") ? key.GetD("norm") : 1.0; + // Handle the samplefile name + std::string mc_type; + std::vector sample_vect; + if (GeneralUtils::ParseToStr(samplefile, ":").size() > 1) { + mc_type = GeneralUtils::ParseToStr(samplefile, ":")[0]; + std::string input_samples = GeneralUtils::ParseToStr(samplefile, ":")[1]; + std::cout << "mc_type: " << mc_type << std::endl; + std::cout << "input_samples: " << input_samples << std::endl; + if (!input_samples.empty()) { + input_samples = GeneralUtils::ReplaceAll(input_samples, "(", ""); + input_samples = GeneralUtils::ReplaceAll(input_samples, ")", ""); + } + std::vector sample_vect = GeneralUtils::ParseToStr(input_samples, ";"); + } + // Print out NUIS_LOG(FIT, "Read Sample " << i << ". : " << samplename << " (" - << sampletype << ") [Norm=" << samplenorm - << "]" << std::endl - << "\t\t|-> input='" - << samplefile << "'"); + << sampletype << ") [Norm=" << samplenorm << "]"); + NUIS_LOG(FIT, " |-> Input MC type = "<< mc_type <<" with " << sample_vect.size() << " input files"); + for (uint j = 0; j < sample_vect.size(); ++j){ + NUIS_LOG(FIT, " |-> Input file #" << j << " = " << sample_vect[j]); + } // If FREE add to parameters otherwise continue if (sampletype.find("FREE") == std::string::npos) { if (samplenorm != 1.0) { NUIS_ERR(FTL, "You provided a sample normalisation but did not specify " - "that the sample is free"); + "that the sample is free"); NUIS_ABORT("Change so sample contains type=\"FREE\" and re-run"); } continue; } // Form norm dial from samplename + sampletype + "_norm"; std::string normname = samplename + "_norm"; // Check normname not already present if (fTypeVals.find("normname") != fTypeVals.end()) { continue; } // Add new norm dial to list if its passed above checks fParams.push_back(normname); fTypeVals[normname] = kNORM; fStateVals[normname] = sampletype; fCurVals[normname] = samplenorm; } // Setup Fake Parameters ----------------------------- std::vector fakekeys = Config::QueryKeys("fakeparameter"); if (!fakekeys.empty()) { NUIS_LOG(FIT, "Number of fake parameters : " << fakekeys.size()); } for (size_t i = 0; i < fakekeys.size(); i++) { nuiskey key = fakekeys.at(i); // Check for type,name,nom if (!key.Has("name")) { NUIS_ABORT("No name given for fakeparameter " << i); } else if (!key.Has("nominal")) { NUIS_ABORT("No nominal given for fakeparameter " << i); } // Get Inputs std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); // Push into vectors fFakeVals[parname] = parnom; } } //************************************* void ComparisonRoutines::SetupRWEngine() { //************************************* NUIS_LOG(FIT, "Setting up FitWeight Engine"); 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() { //************************************* NUIS_LOG(FIT, "Building the SampleFCN"); if (fSampleFCN) delete fSampleFCN; Config::Get().out = fOutputRootFile; fOutputRootFile->cd(); fSampleFCN = new JointFCN(fOutputRootFile); SetFakeData(); return; } //************************************* void ComparisonRoutines::SetFakeData() { //************************************* if (fFakeDataInput.empty()) return; if (fFakeDataInput.compare("MC") == 0) { NUIS_LOG(FIT, "Setting fake data from MC starting prediction."); UpdateRWEngine(fFakeVals); FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->SetFakeData("MC"); std::map CurVals_wmirr; for (size_t i = 0; i < fParams.size(); ++i) { std::string const &pname = fParams[i]; if (fMirroredParams.count(pname)) { if (!fMirroredParams[pname].mirror_above && (fCurVals[pname] < fMirroredParams[pname].mirror_value)) { double xabove = fMirroredParams[pname].mirror_value - fCurVals[pname]; CurVals_wmirr[pname] = fMirroredParams[pname].mirror_value + xabove; std::cout << "\t--Parameter " << pname << " mirrored from " - << fCurVals[pname] << " -> " << CurVals_wmirr[pname] - << std::endl; + << fCurVals[pname] << " -> " << CurVals_wmirr[pname] + << std::endl; } else if (fMirroredParams[pname].mirror_above && - (fCurVals[pname] >= fMirroredParams[pname].mirror_value)) { + (fCurVals[pname] >= fMirroredParams[pname].mirror_value)) { double xabove = fCurVals[pname] - fMirroredParams[pname].mirror_value; CurVals_wmirr[pname] = fMirroredParams[pname].mirror_value - xabove; std::cout << "\t--Parameter " << pname << " mirrored from " - << fCurVals[pname] << " -> " << CurVals_wmirr[pname] - << std::endl; + << fCurVals[pname] << " -> " << CurVals_wmirr[pname] + << std::endl; } else { CurVals_wmirr[pname] = fCurVals[pname]; } } else { CurVals_wmirr[pname] = fCurVals[pname]; } } UpdateRWEngine(CurVals_wmirr); NUIS_LOG(FIT, "Set all data to fake MC predictions."); } else { NUIS_LOG(FIT, "Setting fake data from: " << fFakeDataInput); fSampleFCN->SetFakeData(fFakeDataInput); } return; } /* - Fitting Functions + Fitting Functions */ //************************************* void ComparisonRoutines::UpdateRWEngine( std::map &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() { //************************************* NUIS_LOG(FIT, "Running ComparisonRoutines : " << fStrategy); if (FitPar::Config().GetParB("save_nominal")) { SaveNominal(); } // Parse given routines fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); if (fRoutines.empty()) { NUIS_ABORT("Trying to run ComparisonRoutines with no routines given!"); } for (UInt_t i = 0; i < fRoutines.size(); i++) { std::string routine = fRoutines.at(i); - NUIS_LOG(FIT, "Routine: " << routine); + // Mostly this is unnecessary information, so don't always print + if (fRoutines.size() > 1){ + NUIS_LOG(FIT, "Routine: " << routine); + } if (!routine.compare("Compare")) { std::map CurVals_wmirr; for (size_t i = 0; i < fParams.size(); ++i) { std::string const &pname = fParams[i]; if (fMirroredParams.count(pname)) { std::cout << "MA? " << fMirroredParams[pname].mirror_above - << ", OVal: " << fCurVals[pname] - << ", MPoint: " << fMirroredParams[pname].mirror_value - << std::endl; + << ", OVal: " << fCurVals[pname] + << ", MPoint: " << fMirroredParams[pname].mirror_value + << std::endl; if (!fMirroredParams[pname].mirror_above && (fCurVals[pname] < fMirroredParams[pname].mirror_value)) { double xabove = - fMirroredParams[pname].mirror_value - fCurVals[pname]; + fMirroredParams[pname].mirror_value - fCurVals[pname]; CurVals_wmirr[pname] = fMirroredParams[pname].mirror_value + xabove; std::cout << "\t--Parameter " << pname << " mirrored from " - << fCurVals[pname] << " -> " << CurVals_wmirr[pname] - << std::endl; + << fCurVals[pname] << " -> " << CurVals_wmirr[pname] + << std::endl; } else if (fMirroredParams[pname].mirror_above && - (fCurVals[pname] >= fMirroredParams[pname].mirror_value)) { + (fCurVals[pname] >= fMirroredParams[pname].mirror_value)) { double xabove = - fCurVals[pname] - fMirroredParams[pname].mirror_value; + fCurVals[pname] - fMirroredParams[pname].mirror_value; CurVals_wmirr[pname] = fMirroredParams[pname].mirror_value - xabove; std::cout << "\t--Parameter " << pname << " mirrored from " - << fCurVals[pname] << " -> " << CurVals_wmirr[pname] - << std::endl; + << fCurVals[pname] << " -> " << CurVals_wmirr[pname] + << std::endl; } else { CurVals_wmirr[pname] = fCurVals[pname]; } } else { CurVals_wmirr[pname] = fCurVals[pname]; } std::cout << "~~~~~~~" << pname << " : " << fCurVals[pname] << " -> " - << CurVals_wmirr[pname] << std::endl; + << CurVals_wmirr[pname] << std::endl; } UpdateRWEngine(CurVals_wmirr); GenerateComparison(); PrintState(); SaveCurrentState(); } } return; } //************************************* void ComparisonRoutines::GenerateComparison() { //************************************* NUIS_LOG(FIT, "Generating Comparison."); // Main Event Loop from event Manager fSampleFCN->ReconfigureAllEvents(); return; } //************************************* void ComparisonRoutines::PrintState() { //************************************* - NUIS_LOG(FIT, "------------"); // Count max size int maxcount = 0; for (UInt_t i = 0; i < fParams.size(); i++) { maxcount = max(int(fParams[i].size()), maxcount); } // Header - NUIS_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)"); + if (fParams.size()){ + NUIS_LOG(FIT, "------------"); + NUIS_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::map CurVals_wmirr; for (size_t i = 0; i < fParams.size(); ++i) { std::string const &pname = fParams[i]; if (fMirroredParams.count(pname)) { if (!fMirroredParams[pname].mirror_above && (fCurVals[pname] < fMirroredParams[pname].mirror_value)) { double xabove = fMirroredParams[pname].mirror_value - fCurVals[pname]; CurVals_wmirr[pname] = fMirroredParams[pname].mirror_value + xabove; std::cout << "\t--Parameter " << pname << " mirrored from " - << fCurVals[pname] << " -> " << CurVals_wmirr[pname] - << std::endl; + << fCurVals[pname] << " -> " << CurVals_wmirr[pname] + << std::endl; } else if (fMirroredParams[pname].mirror_above && - (fCurVals[pname] >= fMirroredParams[pname].mirror_value)) { + (fCurVals[pname] >= fMirroredParams[pname].mirror_value)) { double xabove = fCurVals[pname] - fMirroredParams[pname].mirror_value; CurVals_wmirr[pname] = fMirroredParams[pname].mirror_value - xabove; std::cout << "\t--Parameter " << pname << " mirrored from " - << fCurVals[pname] << " -> " << CurVals_wmirr[pname] - << std::endl; + << fCurVals[pname] << " -> " << CurVals_wmirr[pname] + << std::endl; } else { CurVals_wmirr[pname] = fCurVals[pname]; } } else { CurVals_wmirr[pname] = fCurVals[pname]; } } // 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)); + 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)); + 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::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; + curparstring << " " << setw(3) << left << i << " " << setw(maxcount) + << syst << " = " << setw(10) << Form("%.7lf", curval) << " +- " << setw(10) + << Form("%.7lf", curerr) << " " << setw(8) << curunits; + // << " " << setw(10); + // << convval << " +- " << setw(10) << converr << " " << setw(8) + // << convunits; NUIS_LOG(FIT, curparstring.str()); if (fMirroredParams.count(syst)) { NUIS_LOG(FIT, "\t\t--> Mirrored at " << fMirroredParams[syst].mirror_value - << " to effective value " - << CurVals_wmirr[syst]); + << " to effective value " + << CurVals_wmirr[syst]); } } NUIS_LOG(FIT, "------------"); double like = fSampleFCN->GetLikelihood(); + int ndof = fSampleFCN->GetNDOF(); NUIS_LOG(FIT, - std::left << std::setw(46) << "Likelihood for JointFCN: " << like); + std::left << std::setw(55) << "Likelihood for JointFCN" << ": " << like << "/" << ndof); NUIS_LOG(FIT, "------------"); } /* - Write Functions + Write Functions */ //************************************* void ComparisonRoutines::SaveCurrentState(std::string subdir) { //************************************* NUIS_LOG(FIT, "Saving current full FCN predictions"); // 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(); NUIS_LOG(FIT, "Saving Nominal Predictions (be cautious with this)"); FitBase::GetRW()->Reconfigure(); GenerateComparison(); SaveCurrentState("nominal"); }; diff --git a/src/Routines/ComparisonRoutines.h b/src/Routines/ComparisonRoutines.h index 50cd9bb..18db738 100755 --- a/src/Routines/ComparisonRoutines.h +++ b/src/Routines/ComparisonRoutines.h @@ -1,175 +1,175 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef COMPARISON_ROUTINES_H #define COMPARISON_ROUTINES_H /*! \addtogroup Routines @{ */ #include "TH1.h" #include "TF1.h" #include "TMatrixD.h" #include "TVectorD.h" #include "TSystem.h" #include "TFile.h" #include "TProfile.h" #include #include #include #include #include #include "FitEvent.h" #include "JointFCN.h" #include "GeneralUtils.h" #include "NuisConfig.h" #include "NuisKey.h" #include "FitLogger.h" #include "ParserUtils.h" enum minstate { kErrorStatus = -1, kGoodStatus, kFitError, kNoChange, kFitFinished, kFitUnfinished, kStateChange, }; //************************************* /// Collects all possible fit routines into a single class to avoid repeated code class ComparisonRoutines { //************************************* public: /* Constructor/Destructor */ /// Constructor reads in arguments given at the command line for the fit here. ComparisonRoutines(int argc, char* argv[]); /// Default destructor ~ComparisonRoutines(); /// Reset everything to default/NULL void Init(); /* Input Functions */ /// Queries configuration keys to setup Parameters/Samples/FakeParameters void SetupComparisonsFromXML(); /* Setup Functions */ /// Setups up our custom RW engine with all the parameters passed in the card file void SetupRWEngine(); /// Setups up the jointFCN. void SetupFCN(); /// Set the current data histograms in each sample to the fake data. void SetFakeData(); /* Fitting Functions */ /// Main function to actually start iterating over the different required fit routines void Run(); /// Creates a comparison from FCN void GenerateComparison(); /// Given a new map change the values that the RW engine is currently set to void UpdateRWEngine(std::map& updateVals); /// Print current value void PrintState(); /* Write Functions */ /// Save the sample plots for current MC /// dir if not empty forces plots to be saved in a subdirectory of outputfile void SaveCurrentState(std::string subdir=""); /// Save starting predictions into a separate folder void SaveNominal(); /* MISC Functions */ /// Get previous fit status from a file Int_t GetStatus(); protected: //! Our Custom ReWeight Object FitWeight* rw; std::string fOutputFile; ///< Output file name // std::string fInputFile; ///< Input file name // TFile* fInputRootFile; ///< TFile* fOutputRootFile; ///< Output ROOT TFile JointFCN* fSampleFCN; ///< Joint Samples Container that handles reconfigures. std::string fCardFile; ///< Input card/XML file. std::string fStrategy; ///< Comparison routine selection. std::vector fRoutines; ///< Split vector of comparison routine selection. std::string fAllowedRoutines; ///< Hard coded list of allowed routines. /// Fake data flag. Can be 'MC' to use 'fake_parameter' /// or 'path_to_file.root' to use previous NUISANCE MC predictions. std::string fFakeDataInput; // Input Dial Vals std::vector fParams; ///< Vector of dial names. std::map fStateVals; ///< Map of dial states std::map fCurVals; ///< Map of dial values std::map fTypeVals; ///< Map of dial type enums. struct mirror_param { double mirror_value; bool mirror_above; }; std::map fMirroredParams; // Fake Dial Vals std::map fFakeVals; ///< Map of fake data settings. // Configuration nuiskey fCompKey; ///< Configuration Key for this Comparison Instance }; /*! @} */ #endif diff --git a/src/Routines/MinimizerRoutines.cxx b/src/Routines/MinimizerRoutines.cxx index 2e74c85..148b6d3 100755 --- a/src/Routines/MinimizerRoutines.cxx +++ b/src/Routines/MinimizerRoutines.cxx @@ -1,1561 +1,1569 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "MinimizerRoutines.h" #include "Simple_MH_Sampler.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," "DataToys,MCMC"); }; //************************************* MinimizerRoutines::~MinimizerRoutines(){ //************************************* }; /* Input Functions */ //************************************* MinimizerRoutines::MinimizerRoutines() { //************************************* Init(); } //************************************* MinimizerRoutines::MinimizerRoutines(int argc, char *argv[]) { //************************************* // Initialise Defaults Init(); nuisconfig configuration = Config::Get(); // Default containers std::string cardfile = ""; std::string maxevents = "-1"; int errorcount = 0; int verbocount = 0; std::vector xmlcmds; std::vector configargs; // Make easier to handle arguments. std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); ParserUtils::ParseArgument(args, "-c", fCardFile, true); ParserUtils::ParseArgument(args, "-o", fOutputFile, false, false); ParserUtils::ParseArgument(args, "-n", maxevents, false, false); ParserUtils::ParseArgument(args, "-f", fStrategy, false, false); ParserUtils::ParseArgument(args, "-d", fFakeDataInput, false, false); ParserUtils::ParseArgument(args, "-i", xmlcmds); ParserUtils::ParseArgument(args, "-q", configargs); ParserUtils::ParseCounter(args, "e", errorcount); ParserUtils::ParseCounter(args, "v", verbocount); ParserUtils::CheckBadArguments(args); // Add extra defaults if none given if (fCardFile.empty() and xmlcmds.empty()) { NUIS_ABORT("No input supplied!"); } if (fOutputFile.empty() and !fCardFile.empty()) { fOutputFile = fCardFile + ".root"; NUIS_ERR(WRN, "No output supplied so saving it to: " << fOutputFile); } else if (fOutputFile.empty()) { NUIS_ABORT("No output file or cardfile supplied!"); } // Configuration Setup ============================= // Check no comp key is available nuiskey fCompKey; if (Config::Get().GetNodes("nuiscomp").empty()) { fCompKey = Config::Get().CreateNode("nuiscomp"); } else { fCompKey = Config::Get().GetNodes("nuiscomp")[0]; } if (!fCardFile.empty()) fCompKey.Set("cardfile", fCardFile); if (!fOutputFile.empty()) fCompKey.Set("outputfile", fOutputFile); if (!fStrategy.empty()) fCompKey.Set("strategy", fStrategy); // Load XML Cardfile configuration.LoadSettings(fCompKey.GetS("cardfile"), ""); // Add Config Args for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } if (maxevents.compare("-1")) { configuration.OverrideConfig("MAXEVENTS=" + maxevents); } // Finish configuration XML configuration.FinaliseSettings(fCompKey.GetS("outputfile") + ".xml"); // Sort out the printout verbocount += Config::GetParI("VERBOSITY"); errorcount += Config::GetParI("ERROR"); bool trace = Config::GetParB("TRACE"); std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; SETVERBOSITY(verbocount); SETTRACE(trace); // Minimizer Setup ======================================== fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); SetupMinimizerFromXML(); SetupCovariance(); SetupRWEngine(); SetupFCN(); return; }; //************************************* void MinimizerRoutines::SetupMinimizerFromXML() { //************************************* NUIS_LOG(FIT, "Setting up nuismin"); // Setup Parameters ------------------------------------------ std::vector parkeys = Config::QueryKeys("parameter"); if (!parkeys.empty()) { NUIS_LOG(FIT, "Number of parameters : " << parkeys.size()); } for (size_t i = 0; i < parkeys.size(); i++) { nuiskey key = parkeys.at(i); // Check for type,name,nom if (!key.Has("type")) { NUIS_ABORT("No type given for parameter " << i); } else if (!key.Has("name")) { NUIS_ABORT("No name given for parameter " << i); } else if (!key.Has("nominal")) { NUIS_ABORT("No nominal given for parameter " << i); } // Get Inputs std::string partype = key.GetS("type"); std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); double parlow = parnom - 1; double parhigh = parnom + 1; double parstep = 1; // Override state if none given if (!key.Has("state")) { key.SetS("state", "FIX"); } std::string parstate = key.GetS("state"); // Extra limits if (key.Has("low")) { parlow = key.GetD("low"); parhigh = key.GetD("high"); parstep = key.GetD("step"); NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parlow << " < p < " << parhigh << " : " << parstate); } else { NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parstate); } bool ismirr = false; if (key.Has("mirror_point")) { ismirr=true; mirror_param mir; mir.mirror_value = key.GetD("mirror_point"); mir.mirror_above = key.GetB("mirror_above"); fMirroredParams[parname] = mir; NUIS_LOG(FIT, "\t\t" << parname << " is mirrored at " << mir.mirror_value << " " << (mir.mirror_above ? "from above" : "from below")); } // Run Parameter Conversion if needed if (parstate.find("ABS") != std::string::npos) { if(ismirr){ NUIS_ABORT("Cannot mirror parameters with ABS state!"); } double opnom = parnom; double oparstep = parstep; parnom = FitBase::RWAbsToSigma(partype, parname, parnom); parlow = FitBase::RWAbsToSigma(partype, parname, parlow); parhigh = FitBase::RWAbsToSigma(partype, parname, parhigh); parstep = FitBase::RWAbsToSigma(partype, parname, opnom + parstep) - parnom; NUIS_LOG(FIT, "ParStep: " << parstep << " (" << oparstep << ")."); } else if (parstate.find("FRAC") != std::string::npos) { if(ismirr){ NUIS_ABORT("Cannot mirror parameters with FRAC state!"); } parnom = FitBase::RWFracToSigma(partype, parname, parnom); parlow = FitBase::RWFracToSigma(partype, parname, parlow); parhigh = FitBase::RWFracToSigma(partype, parname, parhigh); parstep = FitBase::RWFracToSigma(partype, parname, parstep); } // Push into vectors fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fStartVals[parname] = parnom; fCurVals[parname] = parnom; fErrorVals[parname] = 0.0; fStateVals[parname] = parstate; bool fixstate = parstate.find("FIX") != std::string::npos; fFixVals[parname] = fixstate; fStartFixVals[parname] = fFixVals[parname]; fMinVals[parname] = parlow; fMaxVals[parname] = parhigh; fStepVals[parname] = parstep; } // Setup Samples ---------------------------------------------- std::vector samplekeys = Config::QueryKeys("sample"); if (!samplekeys.empty()) { NUIS_LOG(FIT, "Number of samples : " << samplekeys.size()); } for (size_t i = 0; i < samplekeys.size(); i++) { nuiskey key = samplekeys.at(i); // Get Sample Options std::string samplename = key.GetS("name"); std::string samplefile = key.GetS("input"); - std::string sampletype = key.Has("type") ? key.GetS("type") : "DEFAULT"; - double samplenorm = key.Has("norm") ? key.GetD("norm") : 1.0; + // Handle the samplefile name + std::string mc_type = GeneralUtils::ParseToStr(samplefile, ":")[0]; + std::string input_samples = GeneralUtils::ParseToStr(samplefile, ":")[1]; + input_samples = GeneralUtils::ReplaceAll(input_samples, "(", ""); + input_samples = GeneralUtils::ReplaceAll(input_samples, ")", ""); + std::vector sample_vect = GeneralUtils::ParseToStr(input_samples, ";"); + // Print out - NUIS_LOG(FIT, "Read sample info " - << i << " : " << samplename << std::endl - << "\t\t|-> input -> " << samplefile << std::endl - << "\t\t|-> state -> " << sampletype << std::endl - << "\t\t|-> norm -> " << samplenorm); + NUIS_LOG(FIT, "Read sample " << i << ". : " << samplename << " (" + << sampletype << ") [Norm=" << samplenorm << "]"); + NUIS_LOG(FIT, " |-> Input MC type = "<< mc_type <<" with " << sample_vect.size() << " input files"); + for (uint j=0; j < sample_vect.size(); ++j){ + NUIS_LOG(FIT, " |-> Input file #" << j << " = " << sample_vect[j]); + } // If FREE add to parameters otherwise continue if (sampletype.find("FREE") == std::string::npos) { if (samplenorm != 1.0) { NUIS_ERR(FTL, "You provided a sample normalisation but did not specify " "that the sample is free"); NUIS_ABORT("Change so sample contains type=\"FREE\" and re-run"); } continue; } // Form norm dial from samplename + sampletype + "_norm"; std::string normname = samplename + "_norm"; // Check normname not already present if (fTypeVals.find(normname) != fTypeVals.end()) { continue; } // Add new norm dial to list if its passed above checks fParams.push_back(normname); fTypeVals[normname] = kNORM; fStateVals[normname] = sampletype; fStartVals[normname] = samplenorm; fCurVals[normname] = samplenorm; fErrorVals[normname] = 0.0; fMinVals[normname] = 0.1; fMaxVals[normname] = 10.0; fStepVals[normname] = 0.5; bool state = sampletype.find("FREE") == std::string::npos; fFixVals[normname] = state; fStartFixVals[normname] = state; } // Setup Fake Parameters ----------------------------- std::vector fakekeys = Config::QueryKeys("fakeparameter"); if (!fakekeys.empty()) { NUIS_LOG(FIT, "Number of fake parameters : " << fakekeys.size()); } for (size_t i = 0; i < fakekeys.size(); i++) { nuiskey key = fakekeys.at(i); // Check for type,name,nom if (!key.Has("name")) { NUIS_ABORT("No name given for fakeparameter " << i); } else if (!key.Has("nom")) { NUIS_ABORT("No nominal given for fakeparameter " << i); } // Get Inputs std::string parname = key.GetS("name"); double parnom = key.GetD("nom"); // Push into vectors fFakeVals[parname] = parnom; } } /* 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() { //************************************* NUIS_LOG(FIT, "Making the jointFCN"); if (fSampleFCN) delete fSampleFCN; // fSampleFCN = new JointFCN(fCardFile, fOutputRootFile); fSampleFCN = new JointFCN(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 = ""; bool UseMCMC = false; // 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 = ""; } else if (!routine.compare("MCMC")) { UseMCMC = true; } // make minimizer if (fMinimizer) delete fMinimizer; if (UseMCMC) { fMinimizer = new Simple_MH_Sampler(); } else { fMinimizer = ROOT::Math::Factory::CreateMinimizer(fitclass, fittype); } fMinimizer->SetMaxFunctionCalls(FitPar::Config().GetParI("MAXCALLS")); if (!routine.compare("Brute")) { fMinimizer->SetMaxFunctionCalls(fParams.size() * fParams.size() * 4); fMinimizer->SetMaxIterations(fParams.size() * fParams.size() * 4); } fMinimizer->SetMaxIterations(FitPar::Config().GetParI("MAXITERATIONS")); fMinimizer->SetTolerance(FitPar::Config().GetParD("TOLERANCE")); fMinimizer->SetStrategy(FitPar::Config().GetParI("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 (fMirroredParams.count(syst)) { fSampleFCN->SetVariableMirrored(ipar, fMirroredParams[syst].mirror_value, fMirroredParams[syst].mirror_above); } if (fixed) { fMinimizer->FixVariable(ipar); NUIS_LOG(FIT, "Fixed Param: " << syst); } else { NUIS_LOG(FIT, "Free Param: " << syst << " Start:" << vstart << " Range:" << vlow << " to " << vhigh << " Step:" << vstep); } ipar++; } fSampleFCN->SetNParams(ipar); NUIS_LOG(FIT, "Setup Minimizer: " << fMinimizer->NDim() << "(NDim) " << fMinimizer->NFree() << "(NFree)"); return; } //************************************* // Set fake data from user input void MinimizerRoutines::SetFakeData() { //************************************* // If the fake data input field (-d) isn't provided, return to caller if (fFakeDataInput.empty()) return; // If user specifies -d MC we set the data to the MC // User can also specify fake data parameters to reweight by doing // "fake_parameter" in input card file // "fake_parameter" gets read in ReadCard function (reads to fFakeVals) if (fFakeDataInput.compare("MC") == 0) { NUIS_LOG(FIT, "Setting fake data from MC starting prediction."); // fFakeVals get read in in ReadCard UpdateRWEngine(fFakeVals); // Reconfigure the reweight engine FitBase::GetRW()->Reconfigure(); // Reconfigure all the samples to the new reweight fSampleFCN->ReconfigureAllEvents(); // Feed on and set the fake-data in each measurement class fSampleFCN->SetFakeData("MC"); // Changed the reweight engine values back to the current values // So we start the fit at a different value than what we set the fake-data // to UpdateRWEngine(fCurVals); NUIS_LOG(FIT, "Set all data to fake MC predictions."); } else { fSampleFCN->SetFakeData(fFakeDataInput); } return; } /* Fitting Functions */ //************************************* void MinimizerRoutines::UpdateRWEngine( std::map &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() { //************************************* NUIS_LOG(FIT, "Running MinimizerRoutines : " << fStrategy); if (FitPar::Config().GetParB("save_nominal")) { SaveNominal(); } // Parse given routines fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); if (fRoutines.empty()) { NUIS_ABORT("Trying to run MinimizerRoutines with no routines given!"); } for (UInt_t i = 0; i < fRoutines.size(); i++) { std::string routine = fRoutines.at(i); int fitstate = kFitUnfinished; NUIS_LOG(FIT, "Running Routine: " << routine); // 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.find("DataToys") != std::string::npos) ThrowDataToys(); 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) { NUIS_LOG(FIT, "Ending fit routines loop."); 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") or !routine.compare("MCMC")) { if (fMinimizer->NFree() > 0) { - NUIS_LOG(FIT, fMinimizer->Minimize()); + fMinimizer->Minimize(); GetMinimizerState(); } } // other otptions else if (!routine.compare("Contour")) { CreateContours(); } return endfits; } //************************************* void MinimizerRoutines::PrintState() { //************************************* NUIS_LOG(FIT, "------------"); // Count max size int maxcount = 0; for (UInt_t i = 0; i < fParams.size(); i++) { maxcount = max(int(fParams[i].size()), maxcount); } // Header NUIS_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)"); + << " " << setw(8) << "(Units)"); + // << " " << setw(10) << "Conv. Val" + // << " +- " << setw(10) << "Conv. Err" + // << " " << setw(8) << "(Units)"); // 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::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; + curparstring << " " << setw(3) << left << i << " " << setw(maxcount) + << syst << " = " << setw(10) << Form("%.7lf", curval) << " +- " << setw(10) + << Form("%.7lf", curerr) << " " << setw(8) << curunits; + // << " " << setw(10) + // << convval << " +- " << setw(10) << converr << " " << setw(8) + // << convunits; NUIS_LOG(FIT, curparstring.str()); } NUIS_LOG(FIT, "------------"); double like = fSampleFCN->GetLikelihood(); + int ndof = fSampleFCN->GetNDOF(); NUIS_LOG(FIT, - std::left << std::setw(46) << "Likelihood for JointFCN: " << like); + std::left << std::setw(55) << "Likelihood for JointFCN" << ": " << like << "/" << ndof) NUIS_LOG(FIT, "------------"); } //************************************* void MinimizerRoutines::GetMinimizerState() { //************************************* - NUIS_LOG(FIT, "Minimizer State: "); + NUIS_LOG(DEB, "Minimizer State: "); // 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 NUIS_LOG(FIT, "Filling covariance"); 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) { //************************************* NUIS_LOG(FIT, "Running Low Statistics Routine: " << routine); int lowstatsevents = FitPar::Config().GetParI("LOWSTATEVENTS"); int maxevents = FitPar::Config().GetParI("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 Config::SetPar("MAXEVENTS", lowstatsevents); Config::SetPar("VERBOSITY", 3); SetupFCN(); RunFitRoutine(trueroutine); Config::SetPar("MAXEVENTS", maxevents); SetupFCN(); Config::SetPar("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; NUIS_LOG(FIT, "Running 1D Scan for " << fParams[i]); 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 NUIS_LOG(FIT, "Running scan for " << fParams[i] << " " << fParams[j]); // 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 NUIS_ABORT("Contours not yet implemented as it is really slow!"); 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) { NUIS_LOG(FIT, "No dials needed fixing!"); return kNoChange; } else return kStateChange; } /* Write Functions */ //************************************* void MinimizerRoutines::SaveResults() { //************************************* fOutputRootFile->cd(); if (fMinimizer) { SetupCovariance(); SaveMinimizerState(); } SaveCurrentState(); } //************************************* void MinimizerRoutines::SaveMinimizerState() { //************************************* NUIS_LOG(FIT, "Saving Minimizer State"); if (!fMinimizer) { NUIS_ABORT("Can't save minimizer state without min object"); } // Save main fit tree fSampleFCN->WriteIterationTree(); // Get Vals and Errors GetMinimizerState(); // Save tree with fit status std::vector nameVect; std::vector valVect; std::vector errVect; std::vector minVect; std::vector maxVect; std::vector startVect; std::vector endfixVect; std::vector 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) { //************************************* NUIS_LOG(FIT, "Saving current full FCN predictions"); // 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(); NUIS_LOG(FIT, "Saving Nominal Predictions (be cautious with this)"); FitBase::GetRW()->Reconfigure(); SaveCurrentState("nominal"); }; //************************************* void MinimizerRoutines::SavePrefit() { //************************************* fOutputRootFile->cd(); NUIS_LOG(FIT, "Saving Prefit Predictions"); 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; NUIS_LOG(FIT, "Building covariance matrix..."); 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++) { NUIS_LOG(FIT, "Getting Param " << fParams[i]); if (!fFixVals[fParams[i]]) NFREE++; } } if (NDIM == 0) return; - NUIS_LOG(FIT, "NFREE == " << NFREE); + NUIS_LOG(DEB, "NFREE == " << NFREE); 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 rands; if (!fDecFree) { NUIS_ERR(WRN, "Trying to throw 0 free parameters"); 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(); // Make a second file to store throws std::string tempFileName = fOutputFile; if (tempFileName.find(".root") != std::string::npos) tempFileName.erase(tempFileName.find(".root"), 5); tempFileName += ".throws.root"; TFile *tempfile = new TFile(tempFileName.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; }; void MinimizerRoutines::ThrowDataToys() { NUIS_LOG(FIT, "Generating Toy Data Throws"); int verb = Config::GetParI("VERBOSITY"); SETVERBOSITY(FIT); int nthrows = FitPar::Config().GetParI("NToyThrows"); double maxlike = -1.0; double minlike = -1.0; std::vector values; for (int i = 0; i < 1.E4; i++) { fSampleFCN->ThrowDataToy(); double like = fSampleFCN->GetLikelihood(); values.push_back(like); if (maxlike == -1.0 or like > maxlike) maxlike = like; if (minlike == -1.0 or like < minlike) minlike = like; } SETVERBOSITY(verb); // Fill Histogram TH1D *likes = new TH1D("toydatalikelihood", "toydatalikelihood", int(sqrt(nthrows)), minlike, maxlike); for (size_t i = 0; i < values.size(); i++) { likes->Fill(values[i]); } // Save to file NUIS_LOG(FIT, "Writing toy data throws"); fOutputRootFile->cd(); likes->Write(); } diff --git a/src/Routines/MinimizerRoutines.h b/src/Routines/MinimizerRoutines.h index 4b3e10c..b3f32c2 100755 --- a/src/Routines/MinimizerRoutines.h +++ b/src/Routines/MinimizerRoutines.h @@ -1,284 +1,284 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MINIMIZER_ROUTINES_H #define MINIMIZER_ROUTINES_H /*! * \addtogroup Minimizer * @{ */ #include "TH1.h" #include "TF1.h" #include "TMatrixD.h" #include "TVectorD.h" #ifdef ROOT6_USE_FIT_FITTER_INTERFACE #include "Fit/Fitter.h" #else #include "Minuit2/FCNBase.h" #include "TFitterMinuit.h" #endif #include "TSystem.h" #include "TFile.h" #include "TProfile.h" #include #include #include #include #include #include "FitEvent.h" #include "JointFCN.h" #include "MinimizerFCN.h" #include "Math/Minimizer.h" #include "Math/Factory.h" #include "Math/Functor.h" #include "FitLogger.h" #include "ParserUtils.h" enum minstate { kErrorStatus = -1, kGoodStatus, kFitError, kNoChange, kFitFinished, kFitUnfinished, kStateChange, }; //************************************* //! Collects all possible fit routines into a single class to avoid repeated code class MinimizerRoutines{ //************************************* public: /* Constructor/Destructor */ MinimizerRoutines(); //! Constructor reads in arguments given at the command line for the fit here. MinimizerRoutines(int argc, char* argv[]); //! Default destructor ~MinimizerRoutines(); //! Reset everything to default/NULL void Init(); /* Input Functions */ //! Splits the arguments ready for initial setup void ParseArgs(int argc, char* argv[]); //! Sorts out configuration and verbosity right at the very start. //! Calls readCard to set everything else up. void InitialSetup(); //! Loops through each line of the card file and passes it to other read functions void ReadCard(std::string cardfile); //! Check for parameter string in the line and assign the correct type. //! Fills maps for each of the parameters int ReadParameters(std::string parstring); //! Reads in fake parameters and assigns them (Requires the parameter to be included as a normal parameter as well) int ReadFakeDataPars(std::string parstring); //! Read in the samples so we can set up the free normalisation dials if required int ReadSamples(std::string sampleString); void SetupMinimizerFromXML(); /* Setup Functions */ //! Setup the configuration given the arguments passed at the commandline and card file void SetupConfig(); //! Setups up our custom RW engine with all the parameters passed in the card file void SetupRWEngine(); //! Setups up the jointFCN. void SetupFCN(); //! Sets up the minimizerObj for ROOT. there are cases where this is called repeatedly, e.g. If you are using a brute force scan before using Migrad. void SetupFitter(std::string routine); //! Set the current data histograms in each sample to the fake data. void SetFakeData(); //! Setup the covariances with the correct dimensions. At the start this is either uncorrelated or merged given all the input covariances. //! At the end of the fit this produces the blank covariances which can then be filled by the minimizerObj with best fit covariances. void SetupCovariance(); /* Fitting Functions */ //! Main function to actually start iterating over the different required fit routines void Run(); //! Given a new map change the values that the RW engine is currently set to void UpdateRWEngine(std::map& updateVals); //! Given a single routine (see tutorial for options) run that fit routine now. int RunFitRoutine(std::string routine); //! Get the current state of minimizerObj and fill it into currentVals and currentNorms void GetMinimizerState(); //! Print current value void PrintState(); //! Performs a fit routine where the input.maxevents is set to a much lower value to try and move closer to the best fit minimum. void LowStatRoutine(std::string routine); //! Perform a chi2 scan in 1D around the current point void Create1DScans(); //! Perform a chi2 scan in 2D around the current point void Chi2Scan2D(); //! Currently a placeholder NEEDS UPDATING void CreateContours(); //! If any currentVals are close to the limits set them to the limit and fix them int FixAtLimit(); //! Throw the current covariance of dial values we have, and fill the thrownVals and thrownNorms maps. //! If uniformly is true parameters will be thrown uniformly between their upper and lower limits. void ThrowCovariance(bool uniformly); //! Given the covariance we currently have generate error bands by throwing the covariance. //! The FitPar config "error_uniform" defines whether to throw using the covariance or uniformly. //! The FitPar config "error_throws" defines how many throws are needed. //! Currently only supports TH1D plots. void GenerateErrorBands(); /* Write Functions */ //! Write plots and TTrees listing the minimizerObj result of the fit to file void SaveMinimizerState(); //! Save the sample plots for current MC //! dir if not empty forces plots to be saved in a subdirectory of outputfile void SaveCurrentState(std::string subdir=""); //! Save starting predictions into a separate folder void SaveNominal(); //! Save predictions before the fit is ran into a separate folder void SavePrefit(); void SaveResults(); /* MISC Functions */ //! Get previous fit status from a file Int_t GetStatus(); /// Makes a histogram of likelihoods when throwing the data according to its statistics void ThrowDataToys(); protected: //! Our Custom ReWeight Object FitWeight* rw; std::string fOutputFile; std::string fInputFile; TFile* fInputRootFile; TFile* fOutputRootFile; //! Flag for whether the fit should be continued if an output file is already found. bool fitContinue; //! Minimizer Object for handling roots different minimizer methods ROOT::Math::Minimizer* fMinimizer; JointFCN* fSampleFCN; MinimizerFCN* fMinimizerFCN; ROOT::Math::Functor* fCallFunctor; int nfreepars; std::string fCardFile; std::string fStrategy; std::vector fRoutines; std::string fAllowedRoutines; std::string fFakeDataInput; // Input Dial Vals //! Vector of dial names std::vector fParams; std::map fStateVals; std::map fStartVals; std::map fCurVals; std::map fErrorVals; std::map fMinVals; std::map fMaxVals; std::map fStepVals; std::map fTypeVals; std::map fFixVals; std::map fStartFixVals; struct mirror_param { double mirror_value; bool mirror_above; }; std::map fMirroredParams; //! Vector of fake parameter names std::map fFakeVals; //! Map of thrown parameter names and values (After ThrowCovariance) std::map fThrownVals; TH2D* fCorrel; TH2D* fDecomp; TH2D* fCovar; TH2D* fCorFree; TH2D* fDecFree; TH2D* fCovFree; nuiskey fCompKey; }; /*! @} */ #endif diff --git a/src/Routines/SplineRoutines.cxx b/src/Routines/SplineRoutines.cxx index 7bfa6a8..fa34443 100755 --- a/src/Routines/SplineRoutines.cxx +++ b/src/Routines/SplineRoutines.cxx @@ -1,2598 +1,2598 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "SplineRoutines.h" void SplineRoutines::Init() { fStrategy = "SaveEvents"; fRoutines.clear(); fCardFile = ""; fSampleFCN = NULL; fRW = NULL; fAllowedRoutines = ("SaveEvents,TestEvents,SaveSplineEvents"); }; SplineRoutines::~SplineRoutines(){}; SplineRoutines::SplineRoutines(int argc, char *argv[]) { // Initialise Defaults Init(); nuisconfig configuration = Config::Get(); // Default containers std::string cardfile = ""; std::string maxevents = "-1"; int errorcount = 0; int verbocount = 0; std::vector xmlcmds; std::vector configargs; // Make easier to handle arguments. std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); ParserUtils::ParseArgument(args, "-c", fCardFile, true); ParserUtils::ParseArgument(args, "-o", fOutputFile, false, false); ParserUtils::ParseArgument(args, "-n", maxevents, false, false); ParserUtils::ParseArgument(args, "-f", fStrategy, false, false); ParserUtils::ParseArgument(args, "-i", xmlcmds); ParserUtils::ParseArgument(args, "-q", configargs); ParserUtils::ParseCounter(args, "e", errorcount); ParserUtils::ParseCounter(args, "v", verbocount); ParserUtils::CheckBadArguments(args); // Add extra defaults if none given if (fCardFile.empty() and xmlcmds.empty()) { NUIS_ABORT("No input supplied!"); } if (fOutputFile.empty() and !fCardFile.empty()) { fOutputFile = fCardFile + ".root"; NUIS_ERR(WRN, "No output supplied so saving it to: " << fOutputFile); } else if (fOutputFile.empty()) { NUIS_ABORT("No output file or cardfile supplied!"); } // Configuration Setup ============================= // Check no comp key is available nuiskey fCompKey; if (Config::Get().GetNodes("nuiscomp").empty()) { fCompKey = Config::Get().CreateNode("nuiscomp"); } else { fCompKey = Config::Get().GetNodes("nuiscomp")[0]; } if (!fCardFile.empty()) fCompKey.Set("cardfile", fCardFile); fCompKey.Set("outputfile", fOutputFile); if (!fStrategy.empty()) fCompKey.Set("strategy", fStrategy); // Load XML Cardfile configuration.LoadSettings(fCompKey.GetS("cardfile"), ""); // Add Config Args for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } if (maxevents.compare("-1")) { std::cout << "[ NUISANCE ] : Overriding " << "MAXEVENTS=" + maxevents << std::endl; configuration.OverrideConfig("MAXEVENTS=" + maxevents); } // Finish configuration XML configuration.FinaliseSettings(fCompKey.GetS("outputfile") + ".xml"); // Add Error Verbo Lines verbocount += Config::GetParI("VERBOSITY"); errorcount += Config::GetParI("ERROR"); std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; // FitPar::log_verb = verbocount; SETVERBOSITY(verbocount); // ERR_VERB(errorcount); // Starting Setup // --------------------------- SetupRWEngine(); return; }; /* Setup Functions */ //************************************* void SplineRoutines::SetupRWEngine() { //************************************* fRW = new FitWeight("splineweight"); // std::vector splinekeys = Config::QueryKeys("spline"); std::vector parameterkeys = Config::QueryKeys("parameter"); // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; std::string parname = key.GetS("name"); std::string partype = key.GetS("type"); double nom = key.GetD("nominal"); fRW->IncludeDial(key.GetS("name"), FitBase::ConvDialType(key.GetS("type")), nom); fRW->SetDialValue(key.GetS("name"), key.GetD("nominal")); } fRW->Reconfigure(); return; } /* Fitting Functions */ //************************************* void SplineRoutines::UpdateRWEngine(std::map &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() { //************************************* std::cout << "Running " << std::endl; // Parse given routines fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); if (fRoutines.empty()) { NUIS_ABORT("Trying to run ComparisonRoutines with no routines given!"); } for (size_t i = 0; i < fRoutines.size(); i++) { NUIS_LOG(FIT, "Running Routine: " << fRoutines[i]); std::string rout = fRoutines[i]; if (!rout.compare("SaveEvents")) SaveEvents(); else if (!rout.compare("TestEvents")) TestEvents(); else if (!rout.compare("GenerateEventSplines")) { GenerateEventWeights(); BuildEventSplines(); } else if (!rout.compare("GenerateEventWeights")) { GenerateEventWeights(); } else if (!rout.compare("GenerateEventWeightChunks")) { GenerateEventWeightChunks(FitPar::Config().GetParI("spline_procchunk")); } else if (!rout.compare("BuildEventSplines")) { BuildEventSplines(); } else if (!rout.compare("TestSplines_1DEventScan")) TestSplines_1DEventScan(); else if (!rout.compare("TestSplines_NDEventThrow")) TestSplines_NDEventThrow(); else if (!rout.compare("SaveSplinePlots")) SaveSplinePlots(); else if (!rout.compare("TestSplines_1DLikelihoodScan")) TestSplines_1DLikelihoodScan(); else if (!rout.compare("TestSplines_NDLikelihoodThrow")) TestSplines_NDLikelihoodThrow(); else if (!rout.compare("BuildEventSplinesChunks")) { int chunk = FitPar::Config().GetParI("spline_procchunk"); BuildEventSplines(chunk); } else if (!rout.compare("MergeEventSplinesChunks")) { MergeEventSplinesChunks(); } } } //************************************* void SplineRoutines::SaveEvents() { //************************************* if (fRW) delete fRW; SetupRWEngine(); fRW->Reconfigure(); fRW->Print(); // Generate a set of nominal events // Method, Loop over inputs, create input handler, then create a ttree std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make new outputfile TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); InputHandlerBase *input = InputUtils::CreateInputHandler( "eventsaver", inptype, file_descriptor[1]); // Get info from inputhandler int nevents = input->GetNEvents(); int countwidth = (nevents / 10); FitEvent *nuisevent = input->FirstNuisanceEvent(); // Setup a TTree to save the event outputfile->cd(); TTree *eventtree = new TTree("nuisance_events", "nuisance_events"); nuisevent->AddBranchesToTree(eventtree); // Loop over all events and fill the TTree int icount = 0; // int countwidth = nevents / 5; while (nuisevent) { // Get Event Weight nuisevent->RWWeight = fRW->CalcWeight(nuisevent); // if (nuisevent->RWWeight != 1.0){ // std::cout << "Weight = " << nuisevent->RWWeight << std::endl; // } // Save everything eventtree->Fill(); // Logging if (icount % countwidth == 0) { NUIS_LOG(REC, "Saved " << icount << "/" << nevents << " nuisance events. [M, W] = [" << nuisevent->Mode << ", " << nuisevent->RWWeight << "]"); } // iterate nuisevent = input->NextNuisanceEvent(); icount++; } // Save flux and close file outputfile->cd(); eventtree->Write(); input->GetFluxHistogram()->Write("nuisance_fluxhist"); input->GetEventHistogram()->Write("nuisance_eventhist"); // Close Output outputfile->Close(); // Delete Inputs delete input; } // remove Keys eventkeys.clear(); // Finished NUIS_LOG(FIT, "Finished processing all nuisance events."); } //************************************* void SplineRoutines::TestEvents() { //************************************* NUIS_LOG(FIT, "Testing events."); // Create a new file for the test samples if (!fOutputRootFile) { fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); } // Loop over all tests int count = 0; std::vector testkeys = Config::QueryKeys("sampletest"); for (std::vector::iterator iter = testkeys.begin(); iter != testkeys.end(); iter++) { nuiskey key = (*iter); // 0. Create new measurement list std::list samplelist; // 1. Build Sample From Events std::string samplename = key.GetS("name"); std::string eventsid = key.GetS("inputid"); nuiskey eventskey = Config::QueryLastKey("events", "id=" + eventsid); std::string rawfile = eventskey.GetS("input"); NUIS_LOG(FIT, "Creating sample " << samplename); MeasurementBase *rawsample = SampleUtils::CreateSample( samplename, rawfile, "", "", FitBase::GetRW()); // 2. Build Sample From Nuisance Events std::string eventsfile = eventskey.GetS("output"); NUIS_LOG(FIT, "Creating Fit Eevnt Sample " << samplename << " " << eventsfile); MeasurementBase *nuissample = SampleUtils::CreateSample( samplename, "FEVENT:" + eventsfile, "", "", FitBase::GetRW()); // 3. Make some folders to save stuff TDirectory *sampledir = (TDirectory *)fOutputRootFile->mkdir( Form((samplename + "_test_%d").c_str(), count)); TDirectory *rawdir = (TDirectory *)sampledir->mkdir("raw"); TDirectory *nuisancedir = (TDirectory *)sampledir->mkdir("nuisance"); TDirectory *difdir = (TDirectory *)sampledir->mkdir("difference"); // 4. Reconfigure both rawdir->cd(); rawsample->Reconfigure(); rawsample->Write(); nuisancedir->cd(); nuissample->Reconfigure(); nuissample->Write(); // 4. Compare Raw to Nuisance Events // Loop over all keyse TIter next(rawdir->GetListOfKeys()); TKey *dirkey; while ((dirkey = (TKey *)next())) { // If not a 1D/2D histogram skip TClass *cl = gROOT->GetClass(dirkey->GetClassName()); if (!cl->InheritsFrom("TH1D") and !cl->InheritsFrom("TH2D")) continue; // Get TH1* from both dir TH1 *rawplot = (TH1 *)rawdir->Get(dirkey->GetName()); TH1 *nuisanceplot = (TH1 *)nuisancedir->Get(dirkey->GetName()); // Take Difference nuisanceplot->Add(rawplot, -1.0); // Save to dif folder difdir->cd(); nuisanceplot->Write(); } // 5. Tidy Up samplelist.clear(); // Iterator count++; } } void SplineRoutines::GenerateEventWeightChunks(int procchunk) { if (fRW) delete fRW; SetupRWEngine(); // Setup the spline reader SplineWriter *splwrite = new SplineWriter(fRW); std::vector splinekeys = Config::QueryKeys("spline"); // Add splines to splinewriter for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader splwrite->AddSpline(splkey); } splwrite->SetupSplineSet(); // Event Loop // Loop over all events and calculate weights for each parameter set. // Generate a set of nominal events // Method, Loop over inputs, create input handler, then create a ttree std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN,"No output give for set of output events! Saving to " << outputfilename); } outputfilename += ".weights.root"; // Make new outputfile TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); InputHandlerBase *input = InputUtils::CreateInputHandler( "eventsaver", inptype, file_descriptor[1]); // Get info from inputhandler int nevents = input->GetNEvents(); // int countwidth = (nevents / 1000); FitEvent *nuisevent = input->FirstNuisanceEvent(); // Setup a TTree to save the event outputfile->cd(); TTree *eventtree = new TTree("nuisance_events", "nuisance_events"); // Add a flag that allows just splines to be saved. nuisevent->AddBranchesToTree(eventtree); // Save the spline reader splwrite->Write("spline_reader"); // Setup the spline TTree TTree *weighttree = new TTree("weight_tree", "weight_tree"); splwrite->AddWeightsToTree(weighttree); // Make container for all weights int nweights = splwrite->GetNWeights(); // int npar = splwrite->GetNPars(); // double* weightcont = new double[nweights]; int lasttime = time(NULL); // Load N Chunks of the Weights into Memory // Split into N processing chunks int nchunks = FitPar::Config().GetParI("spline_chunks"); if (nchunks <= 0) nchunks = 1; if (nchunks >= nevents / 2) nchunks = nevents / 2; std::cout << "Starting NChunks " << nchunks << std::endl; for (int ichunk = 0; ichunk < nchunks; ichunk++) { // Skip to only do one processing chunk if (procchunk != -1 and procchunk != ichunk) continue; NUIS_LOG(FIT, "On Processing Chunk " << ichunk); int neventsinchunk = nevents / nchunks; int loweventinchunk = neventsinchunk * ichunk; // int higheventinchunk = neventsinchunk * (ichunk + 1); double **allweightcont = new double *[neventsinchunk]; for (int k = 0; k < neventsinchunk; k++) { allweightcont[k] = new double[nweights]; } // Start Set Processing Here. for (int iset = 0; iset < nweights; iset++) { splwrite->ReconfigureSet(iset); // Could reorder this to save the weightconts in order instead of // reconfiguring per event. Loop over all events and fill the TTree for (int i = 0; i < neventsinchunk; i++) { nuisevent = input->GetNuisanceEvent(i + loweventinchunk); double w = splwrite->GetWeightForThisSet(nuisevent); if (iset == 0) { allweightcont[i][0] = w; } else { allweightcont[i][iset] = w / allweightcont[i][0]; } // Save everything if (iset == 0) { eventtree->Fill(); } } std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (timeelapsed) { lasttime = time(NULL); int setsleft = (nweights - iset - 1) + (nweights * (nchunks - ichunk - 1)); float proj = (float(setsleft) * timeelapsed) / 60 / 60; timestring << setsleft << " sets remaining. Last one took " << timeelapsed << ". " << proj << " hours remaining."; } NUIS_LOG(REC, "Processed Set " << iset << "/" << nweights << " in chunk " << ichunk << "/" << nchunks << " " << timestring.str()); } // Fill weights for this chunk into the TTree for (int k = 0; k < neventsinchunk; k++) { splwrite->SetWeights(allweightcont[k]); weighttree->Fill(); } } // at end of the chunk, when all sets have been done // loop over the container and fill weights to ttree outputfile->cd(); eventtree->Write(); weighttree->Write(); input->GetFluxHistogram()->Write("nuisance_fluxhist"); input->GetEventHistogram()->Write("nuisance_eventhist"); splwrite->Write("spline_reader"); outputfile->Close(); // Close Output outputfile->Close(); // Delete Inputs delete input; } // remove Keys eventkeys.clear(); } //************************************* void SplineRoutines::GenerateEventWeights() { //************************************* if (fRW) delete fRW; SetupRWEngine(); // Setup the spline reader SplineWriter *splwrite = new SplineWriter(fRW); std::vector splinekeys = Config::QueryKeys("spline"); // Add splines to splinewriter for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader splwrite->AddSpline(splkey); } splwrite->SetupSplineSet(); // Event Loop // Loop over all events and calculate weights for each parameter set. // Generate a set of nominal events // Method, Loop over inputs, create input handler, then create a ttree std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } outputfilename += ".weights.root"; // Make new outputfile TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); InputHandlerBase *input = InputUtils::CreateInputHandler( "eventsaver", inptype, file_descriptor[1]); // Get info from inputhandler int nevents = input->GetNEvents(); int countwidth = (nevents / 1000); FitEvent *nuisevent = input->FirstNuisanceEvent(); // Setup a TTree to save the event outputfile->cd(); TTree *eventtree = new TTree("nuisance_events", "nuisance_events"); // Add a flag that allows just splines to be saved. nuisevent->AddBranchesToTree(eventtree); // Save the spline reader splwrite->Write("spline_reader"); // Setup the spline TTree TTree *weighttree = new TTree("weight_tree", "weight_tree"); splwrite->AddWeightsToTree(weighttree); // Make container for all weights int nweights = splwrite->GetNWeights(); // int npar = splwrite->GetNPars(); double *weightcont = new double[nweights]; int lasttime = time(NULL); // Could reorder this to save the weightconts in order instead of // reconfiguring per event. Loop over all events and fill the TTree while (nuisevent) { // Calculate the weights for each parameter set splwrite->GetWeightsForEvent(nuisevent, weightcont); // Save everything eventtree->Fill(); weighttree->Fill(); // Logging if (i % countwidth == 0) { std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (i != 0 and timeelapsed) { lasttime = time(NULL); int eventsleft = nevents - i; float speed = float(countwidth) / float(timeelapsed); float proj = (float(eventsleft) / float(speed)) / 60 / 60; timestring << proj << " hours remaining."; } NUIS_LOG(REC, "Saved " << i << "/" << nevents << " nuisance spline weights. " << timestring.str()); } // Iterate i++; nuisevent = input->NextNuisanceEvent(); } // at end of the chunk, when all sets have been done // loop over the container and fill weights to ttree outputfile->cd(); eventtree->Write(); weighttree->Write(); input->GetFluxHistogram()->Write("nuisance_fluxhist"); input->GetEventHistogram()->Write("nuisance_eventhist"); splwrite->Write("spline_reader"); outputfile->Close(); // Close Output outputfile->Close(); // Delete Inputs delete input; } // remove Keys eventkeys.clear(); } //************************************* void SplineRoutines::GenerateEventSplines() { //************************************* if (fRW) delete fRW; SetupRWEngine(); // Setup the spline reader SplineWriter *splwrite = new SplineWriter(fRW); std::vector splinekeys = Config::QueryKeys("spline"); // Add splines to splinewriter for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader splwrite->AddSpline(splkey); } splwrite->SetupSplineSet(); // Make an ugly list for N cores int ncores = FitPar::Config().GetParI("NCORES"); // omp_get_max_threads(); std::vector splwriterlist; for (int i = 0; i < ncores; i++) { SplineWriter *tmpwriter = new SplineWriter(fRW); for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader tmpwriter->AddSpline(splkey); } tmpwriter->SetupSplineSet(); splwriterlist.push_back(tmpwriter); } // Event Loop // Loop over all events and calculate weights for each parameter set. // Generate a set of nominal events // Method, Loop over inputs, create input handler, then create a ttree std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make new outputfile TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); InputHandlerBase *input = InputUtils::CreateInputHandler( "eventsaver", inptype, file_descriptor[1]); // Get info from inputhandler int nevents = input->GetNEvents(); int countwidth = (nevents / 1000); FitEvent *nuisevent = input->FirstNuisanceEvent(); // Setup a TTree to save the event outputfile->cd(); TTree *eventtree = new TTree("nuisance_events", "nuisance_events"); // Add a flag that allows just splines to be saved. nuisevent->AddBranchesToTree(eventtree); // Save the spline reader splwrite->Write("spline_reader"); // Setup the spline TTree TTree *weighttree = new TTree("weight_tree", "weight_tree"); splwrite->AddWeightsToTree(weighttree); // Make container for all weights int nweights = splwrite->GetNWeights(); double **weightcont = new double *[nevents]; for (int k = 0; k < nevents; k++) { weightcont[k] = new double[nweights]; } int npar = splwrite->GetNPars(); int lasttime = time(NULL); // Could reorder this to save the weightconts in order instead of // reconfiguring per event. Loop over all events and fill the TTree while (nuisevent) { // std::cout << "Fitting event " << i << std::endl; // Calculate the weights for each parameter set // splwrite->FitSplinesForEvent(nuisevent); splwrite->GetWeightsForEvent(nuisevent, weightcont[i]); bool hasresponse = false; for (int j = 0; j < nweights; j++) { if (weightcont[i][j] != 1.0) { // std::cout << "Non Zero Weight at " << i << " " << j << // std::endl; hasresponse = true; } else { // std::cout << "Empty Weight at " << i << " " << j << std::endl; } } if (!hasresponse) { // std::cout << "Deleting flat response " << nuisevent->Mode << // std::endl; delete weightcont[i]; weightcont[i] = NULL; } // Save everything eventtree->Fill(); weighttree->Fill(); // splinetree->Fill(); // nuisevent->Print(); // std::cout << "Done with event " << i << std::endl; // Push weight sets into a the array // sleep(4); // Logging if (i % countwidth == 0) { std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (i != 0 and timeelapsed) { lasttime = time(NULL); int eventsleft = nevents - i; float speed = float(countwidth) / float(timeelapsed); float proj = (float(eventsleft) / float(speed)) / 60 / 60; timestring << proj << " hours remaining."; } NUIS_LOG(REC, "Saved " << i << "/" << nevents << " nuisance spline weights. " << timestring.str()); } // Iterate i++; nuisevent = input->NextNuisanceEvent(); } outputfile->cd(); eventtree->Write(); weighttree->Write(); input->GetFluxHistogram()->Write("nuisance_fluxhist"); input->GetEventHistogram()->Write("nuisance_eventhist"); outputfile->Close(); outputfile = new TFile(outputfilename.c_str(), "UPDATE"); outputfile->cd(); weighttree = (TTree *)outputfile->Get("weight_tree"); // splwrite->ReadWeightsFromTree(weighttree); // Divide weights container into Ncores. // Parrallelise this loop checking for what core we are on. // for (int i = 0; i < nevents; i++){ // splwriterlist[int(i / (nevents/4))]->FitSplinesForEvent(coeff); // } // // Now loop over weights tree // for (int i = 0; i < weighttree->GetEntries(); i++) { // weighttree->GetEntry(i); // splwrite->FitSplinesForEvent(); // splinetree->Fill(); // if (i % countwidth == 0) { // std::ostringstream timestring; // int timeelapsed = time(NULL) - lasttime; // if (i != 0 and timeelapsed) { // lasttime = time(NULL); // int eventsleft = nevents - i; // float speed = float(countwidth) / float(timeelapsed); // float proj = (float(eventsleft) / float(speed)) / 60 / 60; // timestring << proj << " hours remaining."; // } // LOG(REC) << "Built " << i << "/" << nevents << " nuisance spline // events. " << timestring.str() << std::endl; // } // } // Get Splines float **allcoeff = new float *[nevents]; for (int k = 0; k < nevents; k++) { allcoeff[k] = new float[npar]; } // #pragma omp parallel for num_threads(ncores) for (int i = 0; i < nevents; i++) { //#pragma omp atomic // printf("Using Thread %d to build event %d \n", // int(omp_get_thread_num()), (int)i ); std::cout<< " -> Writer = " // << splwriterlist[ i / (nevents/ncores) ] << std::endl; // #pragma omp atomic if (weightcont[i]) { splwriterlist[int(omp_get_thread_num())]->FitSplinesForEvent( weightcont[i], allcoeff[i]); } else { for (int j = 0; j < npar; j++) { allcoeff[i][j] = float(0.0); } } // splwrite->FitSplinesForEvent(weightcont[i], allcoeff[i]); if (i % 500 == 0) { if (LOG_LEVEL(REC)) { printf("Using Thread %d to build event %d \n", int(omp_get_thread_num()), (int)i); } } /* std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (i != 0 and timeelapsed) { lasttime = time(NULL); int eventsleft = nevents - i; float speed = float(countwidth) / float(timeelapsed); float proj = (float(eventsleft) / float(speed)) / 60 / 60; timestring << proj << " hours remaining."; timestring << " Using Writer at " << i / (nevents/ncores) << " = " << splwriterlist[ i / (nevents/ncores) ] << std::endl; } LOG(REC) << "Built " << i << "/" << nevents << " nuisance spline events. " << timestring.str() << std::endl; } */ } // Save Splines into TTree float *coeff = new float[npar]; outputfile->cd(); TTree *splinetree = new TTree("spline_tree", "spline_tree"); splinetree->Branch("SplineCoeff", coeff, Form("SplineCoeff[%d]/F", npar)); std::cout << "Saving to the allcoeff" << std::endl; for (int k = 0; k < nevents; k++) { for (int l = 0; l < npar; l++) { coeff[l] = allcoeff[k][l]; } std::cout << "Coeff 0, 1, 2 = " << coeff[0] << " " << coeff[1] << " " << coeff[2] << std::endl; splinetree->Fill(); } // Save flux and close file outputfile->cd(); splinetree->Write(); // Delete the container. for (int k = 0; k < nevents; k++) { delete weightcont[k]; } delete weightcont; delete coeff; // Close Output outputfile->Close(); // Delete Inputs delete input; } // remove Keys eventkeys.clear(); } //************************************* void SplineRoutines::BuildEventSplines(int procchunk) { //************************************* if (fRW) delete fRW; SetupRWEngine(); // Setup the spline reader SplineWriter *splwrite = new SplineWriter(fRW); std::vector splinekeys = Config::QueryKeys("spline"); // Add splines to splinewriter for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader splwrite->AddSpline(splkey); } splwrite->SetupSplineSet(); // Make an ugly list for N cores int ncores = FitPar::Config().GetParI("spline_cores"); // omp_get_max_threads(); if (ncores > omp_get_max_threads()) ncores = omp_get_max_threads(); if (ncores <= 0) ncores = 1; std::vector splwriterlist; for (int i = 0; i < ncores; i++) { SplineWriter *tmpwriter = new SplineWriter(fRW); for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader tmpwriter->AddSpline(splkey); } tmpwriter->SetupSplineSet(); splwriterlist.push_back(tmpwriter); } // Event Loop // Loop over all events and calculate weights for each parameter set. // Generate a set of nominal events // Method, Loop over inputs, create input handler, then create a ttree std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make new outputfile TFile *outputfile; if (procchunk == -1) outputfile = new TFile(outputfilename.c_str(), "RECREATE"); else outputfile = new TFile( (outputfilename + std::string(Form(".coeffchunk_%d.root", procchunk))) .c_str(), "RECREATE"); outputfile->cd(); // Get Weights File TFile *weightsfile = new TFile((outputfilename + ".weights.root").c_str(), "READ"); TTree *weighttree = (TTree *)weightsfile->Get("weight_tree"); // Get SPLWRite Info // splwrite->ReadWeightsFromTree(weighttree); int nevents = weighttree->GetEntries(); // int countwidth = (nevents / 1000); int nweights = splwrite->GetNWeights(); int npar = splwrite->GetNPars(); // Access Weights double *eventweights = new double[nweights]; weighttree->SetBranchAddress("SplineWeights", eventweights); // Make counter // int lasttime = time(NULL); // Setup Splines To Be Saved into TTree outputfile->cd(); TTree *splinetree = new TTree("spline_tree", "spline_tree"); float *coeff = new float[npar]; splinetree->Branch("SplineCoeff", coeff, Form("SplineCoeff[%d]/F", npar)); // Load N Chunks of the Weights into Memory // Split into N processing chunks int nchunks = FitPar::Config().GetParI("spline_chunks"); if (nchunks <= 0) nchunks = 1; if (nchunks >= nevents / 2) nchunks = nevents / 2; std::cout << "Starting NChunks " << nchunks << std::endl; sleep(1); for (int ichunk = 0; ichunk < nchunks; ichunk++) { // Skip to only do one processing chunk if (procchunk != -1 and procchunk != ichunk) continue; NUIS_LOG(FIT, "On Processing Chunk " << ichunk); int neventsinchunk = nevents / nchunks; int loweventinchunk = neventsinchunk * ichunk; // int higheventinchunk = neventsinchunk * (ichunk + 1); // Build Chunk Containers for Event Weights double **weightcont = new double *[nevents]; float **allcoeff = new float *[nevents]; // Load Chunks into Containers for (int k = 0; k < neventsinchunk; k++) { weighttree->GetEntry(loweventinchunk + k); weightcont[k] = new double[nweights]; allcoeff[k] = new float[npar]; bool hasresponse = false; for (int j = 0; j < nweights; j++) { weightcont[k][j] = eventweights[j]; if (eventweights[j] != 1.0) hasresponse = true; } if (!hasresponse) delete weightcont[k]; } // Loop over ncores and process chunks // #pragma omp parallel for num_threads(ncores) for (int k = 0; k < neventsinchunk; k++) { if (weightcont[k]) { splwriterlist[int(omp_get_thread_num())]->FitSplinesForEvent( weightcont[k], allcoeff[k]); } else { for (int j = 0; j < npar; j++) { allcoeff[k][j] = float(0.0); } } if (k + loweventinchunk % 500 == 0) { if (LOG_LEVEL(REC)) { printf("Using Thread %d to build event %d in chunk %d \n", int(omp_get_thread_num()), (int)loweventinchunk + k, ichunk); } } } // Save Coeff To Tree std::cout << "Saving coeffs to Tree in Chunk " << ichunk << std::endl; for (int k = 0; k < neventsinchunk; k++) { for (int l = 0; l < npar; l++) { coeff[l] = allcoeff[k][l]; } // std::cout << "Coeff 0, 1, 2 = " << coeff[0] << " " << coeff[1] << " " // << coeff[2] << std::endl; splinetree->Fill(); } // Delete the container. for (int k = 0; k < neventsinchunk; k++) { if (weightcont[k]) delete weightcont[k]; if (allcoeff[k]) delete allcoeff[k]; } delete allcoeff; delete weightcont; } // Save flux and close file outputfile->cd(); splinetree->Write(); if (procchunk == -1 or procchunk == 0) { outputfile->cd(); splwrite->Write("spline_reader"); TTree *nuisanceevents = (TTree *)weightsfile->Get("nuisance_events"); nuisanceevents->CloneTree()->Write(); weighttree->CloneTree()->Write(); TH1D *nuisance_fluxhist = (TH1D *)weightsfile->Get("nuisance_fluxhist"); TH1D *nuisance_eventhist = (TH1D *)weightsfile->Get("nuisance_eventhist"); nuisance_fluxhist->Write("nuisance_fluxhist"); nuisance_eventhist->Write("nuisance_eventhist"); } weightsfile->Close(); // Add option to build separate chunks // Close Output outputfile->Close(); } // remove Keys eventkeys.clear(); } void SplineRoutines::MergeEventSplinesChunks() { if (fRW) delete fRW; SetupRWEngine(); // Setup the spline reader SplineWriter *splwrite = new SplineWriter(fRW); std::vector splinekeys = Config::QueryKeys("spline"); // Add splines to splinewriter for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader splwrite->AddSpline(splkey); } splwrite->SetupSplineSet(); std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make new outputfile TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Get Weights File TFile *weightsfile = new TFile((outputfilename + ".weights.root").c_str(), "READ"); TTree *weighttree = (TTree *)weightsfile->Get("weight_tree"); // Get SPLWRite Info // splwrite->ReadWeightsFromTree(weighttree); int nevents = weighttree->GetEntries(); // int countwidth = (nevents / 1000); // int nweights = splwrite->GetNWeights(); int npar = splwrite->GetNPars(); // Make counter // int lasttime = time(NULL); // Setup Splines To Be Saved into TTree outputfile->cd(); TTree *splinetree = new TTree("spline_tree", "spline_tree"); float *coeff = new float[npar]; splinetree->Branch("SplineCoeff", coeff, Form("SplineCoeff[%d]/F", npar)); // Load N Chunks of the Weights into Memory // Split into N processing chunks int nchunks = FitPar::Config().GetParI("spline_chunks"); if (nchunks <= 0) nchunks = 1; if (nchunks >= nevents / 2) nchunks = nevents / 2; int neventsinchunk = nevents / nchunks; for (int ichunk = 0; ichunk < nchunks; ichunk++) { // Get Output File TFile *chunkfile = new TFile( (outputfilename + std::string(Form(".coeffchunk_%d.root", ichunk))) .c_str()); // Get TTree for spline coeffchunk TTree *splinetreechunk = (TTree *)chunkfile->Get("spline_tree"); // Set Branch Address to coeffchunk float *coeffchunk = new float[npar]; splinetreechunk->SetBranchAddress("SplineCoeff", coeffchunk); // Loop over nevents in chunk for (int k = 0; k < neventsinchunk; k++) { splinetreechunk->GetEntry(k); for (int j = 0; j < npar; j++) { coeff[j] = coeffchunk[j]; } splinetree->Fill(); } // Close up chunkfile->Close(); delete coeffchunk; std::cout << "Merged chunk " << ichunk << std::endl; } // Save flux and close file outputfile->cd(); splinetree->Write(); outputfile->cd(); splwrite->Write("spline_reader"); TTree *nuisanceevents = (TTree *)weightsfile->Get("nuisance_events"); nuisanceevents->CloneTree()->Write(); weighttree->CloneTree()->Write(); TH1D *nuisance_fluxhist = (TH1D *)weightsfile->Get("nuisance_fluxhist"); TH1D *nuisance_eventhist = (TH1D *)weightsfile->Get("nuisance_eventhist"); nuisance_fluxhist->Write("nuisance_fluxhist"); nuisance_eventhist->Write("nuisance_eventhist"); weightsfile->Close(); // Add option to build separate chunks // Close Output outputfile->Close(); } // remove Keys eventkeys.clear(); } // void SplineRoutines::BuildSplineChunk(){ //} // void SplineRoutines::MergeSplineChunks(){ //} //************************************* void SplineRoutines::MergeSplines() { //************************************* // Loop over all 'splinemerge' keys. // Add them to the Merger. // Call setup splines. // Get the key with eventinput // - remaining keys should have splineinput // - Loop over number of entries. // - FillEntry in merger. // - Fill NUISANCEEvent into a new TTree. SplineMerger *splmerge = new SplineMerger(); std::vector splinekeys = Config::QueryKeys("splinemerge"); for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); TFile *infile = new TFile(splkey.GetS("input").c_str(), "READ"); splmerge->AddSplineSetFromFile(infile); } splmerge->SetupSplineSet(); // Now get Event File std::vector eventkeys = Config::QueryKeys("eventmerge"); nuiskey key = eventkeys[0]; std::string inputfilename = key.GetS("input"); // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); InputHandlerBase *input = InputUtils::CreateInputHandler("eventsaver", inptype, file_descriptor[1]); std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make new outputfile TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Get info from inputhandler int nevents = input->GetNEvents(); int countwidth = (nevents / 1000); FitEvent *nuisevent = input->FirstNuisanceEvent(); // Setup a TTree to save the event outputfile->cd(); TTree *eventtree = new TTree("nuisance_events", "nuisance_events"); // Add a flag that allows just splines to be saved. nuisevent->AddBranchesToTree(eventtree); // Save the spline reader splmerge->Write("spline_reader"); // Setup the spline TTree TTree *splinetree = new TTree("spline_tree", "spline_tree"); splmerge->AddCoefficientsToTree(splinetree); int lasttime = time(NULL); int i = 0; // Loop over all events and fill the TTree while (nuisevent) { // Calculate the weights for each parameter set splmerge->FillMergedSplines(i); // Save everything eventtree->Fill(); splinetree->Fill(); // Logging if (i % countwidth == 0) { std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (i != 0 and timeelapsed) { lasttime = time(NULL); int eventsleft = nevents - i; float speed = float(countwidth) / float(timeelapsed); float proj = (float(eventsleft) / float(speed)) / 60 / 60; timestring << proj << " hours remaining."; } NUIS_LOG(REC, "Saved " << i << "/" << nevents << " nuisance spline events. " << timestring.str()); } // Iterate i++; nuisevent = input->NextNuisanceEvent(); } // Save flux and close file outputfile->cd(); eventtree->Write(); splinetree->Write(); input->GetFluxHistogram()->Write("nuisance_fluxhist"); input->GetEventHistogram()->Write("nuisance_eventhist"); // Close Output outputfile->Close(); // Delete Inputs delete input; } //************************************* void SplineRoutines::TestSplines_1DEventScan() { //************************************* // Setup RW Engine if (fRW) delete fRW; SetupRWEngine(); // Make a spline RW Engine too. FitWeight *splweight = new FitWeight("splinerwaweight"); // std::vector splinekeys = Config::QueryKeys("spline"); std::vector parameterkeys = Config::QueryKeys("parameter"); TH1D *parhisttemplate = new TH1D("parhist", "parhist", parameterkeys.size(), 0.0, float(parameterkeys.size())); // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; std::string parname = key.GetS("name"); std::string partype = key.GetS("type"); double nom = key.GetD("nominal"); parhisttemplate->SetBinContent(i + 1, nom); parhisttemplate->GetXaxis()->SetBinLabel(i + 1, parname.c_str()); splweight->IncludeDial(key.GetS("name"), kSPLINEPARAMETER, nom); splweight->SetDialValue(key.GetS("name"), key.GetD("nominal")); } splweight->Reconfigure(); // Make a high resolution spline set. std::vector nomvals = fRW->GetDialValues(); // int testres = FitPar::Config().GetParI("spline_test_resolution"); std::vector > scanparset_vals; std::vector scanparset_hists; // Loop over all params // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; // Get Par Name std::string name = key.GetS("name"); if (!key.Has("low") or !key.Has("high") or !key.Has("step")) { continue; } // Push Back Scan double low = key.GetD("low"); double high = key.GetD("high"); double cur = low; double step = key.GetD("step"); while (cur <= high) { // Make new set std::vector newvals = nomvals; newvals[i] = cur; // Add to vects scanparset_vals.push_back(newvals); TH1D *parhist = (TH1D *)parhisttemplate->Clone(); for (size_t j = 0; j < newvals.size(); j++) { parhist->SetBinContent(j + 1, newvals[j]); } scanparset_hists.push_back(parhist); // Move to next one cur += step; } } // Print out the parameter set to test for (uint i = 0; i < scanparset_vals.size(); i++) { std::cout << "Parset " << i; for (uint j = 0; j < scanparset_vals[i].size(); j++) { std::cout << " " << scanparset_vals[i][j]; } std::cout << std::endl; } // Weight holders double *rawweights = new double[scanparset_vals.size()]; double *splweights = new double[scanparset_vals.size()]; double *difweights = new double[scanparset_vals.size()]; int nweights = scanparset_vals.size(); // int NParSets = scanparset_vals.size(); // Loop over all event I/O std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!") } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); // Make handlers for input and output InputHandlerBase *input = InputUtils::CreateInputHandler( "rawevents", inptype, file_descriptor[1]); InputHandlerBase *output = InputUtils::CreateInputHandler( "splineevents", InputUtils::kEVSPLN_Input, outputfilename); // Get Base Events for each case. FitEvent *rawevent = input->FirstNuisanceEvent(); FitEvent *splevent = output->FirstNuisanceEvent(); // Setup outputfile std::string outputtest = outputfilename + ".splinetest.1DEventScan.root"; TFile *outputtestfile = new TFile(outputtest.c_str(), "RECREATE"); outputtestfile->cd(); // Save Parameter Sets for (size_t i = 0; i < scanparset_hists.size(); i++) { scanparset_hists[i]->Write(Form("Paramater_Set_%i", (int)i)); } // Save a TTree of weights and differences. TTree *weighttree = new TTree("weightscan", "weightscan"); // Make a branch for each weight set for (size_t i = 0; i < scanparset_hists.size(); i++) { weighttree->Branch(Form("RawWeights_Set_%i", (int)i), &rawweights[i], Form("RawWeights_Set_%i/D", (int)i)); weighttree->Branch(Form("SplineWeights_Set_%i", (int)i), &splweights[i], Form("SplineWeights_Set_%i/D", (int)i)); weighttree->Branch(Form("DifWeights_Set_%i", (int)i), &difweights[i], Form("DifWeights_Set_%i/D", (int)i)); } // Count // int i = 0; int nevents = input->GetNEvents(); int lasttime = time(NULL); // Load N Chunks of the Weights into Memory // Split into N processing chunks int nchunks = FitPar::Config().GetParI("spline_chunks"); if (nchunks <= 0) nchunks = 1; if (nchunks >= nevents / 2) nchunks = nevents / 2; std::cout << "Starting NChunks " << nchunks << std::endl; for (int ichunk = 0; ichunk < nchunks; ichunk++) { // Skip to only do one processing chunk // if (procchunk != -1 and procchunk != ichunk) continue; NUIS_LOG(FIT, "On Processing Chunk " << ichunk); int neventsinchunk = nevents / nchunks; int loweventinchunk = neventsinchunk * ichunk; // int higheventinchunk = neventsinchunk * (ichunk + 1); double **allrawweights = new double *[neventsinchunk]; double **allsplweights = new double *[neventsinchunk]; double **alldifweights = new double *[neventsinchunk]; for (int k = 0; k < neventsinchunk; k++) { allrawweights[k] = new double[nweights]; allsplweights[k] = new double[nweights]; alldifweights[k] = new double[nweights]; } // Start Set Processing Here. for (int iset = 0; iset < nweights; iset++) { // Reconfigure fRW->SetAllDials(&scanparset_vals[iset][0], scanparset_vals[iset].size()); fRW->Reconfigure(); // Reconfigure spline RW splweight->SetAllDials(&scanparset_vals[iset][0], scanparset_vals[iset].size()); splweight->Reconfigure(); splevent->fSplineRead->SetNeedsReconfigure(true); // Could reorder this to save the weightconts in order instead of // reconfiguring per event. Loop over all events and fill the TTree for (int i = 0; i < neventsinchunk; i++) { rawevent = input->GetNuisanceEvent(i + loweventinchunk); splevent = output->GetNuisanceEvent(i + loweventinchunk); allrawweights[i][iset] = fRW->CalcWeight(rawevent); allsplweights[i][iset] = splweight->CalcWeight(splevent); alldifweights[i][iset] = allsplweights[i][iset] - allrawweights[i][iset]; } std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (timeelapsed) { lasttime = time(NULL); int setsleft = (nweights - iset - 1) + (nweights * (nchunks - ichunk - 1)); float proj = (float(setsleft) * timeelapsed) / 60 / 60; timestring << setsleft << " sets remaining. Last one took " << timeelapsed << ". " << proj << " hours remaining."; } NUIS_LOG(REC, "Processed Set " << iset << "/" << nweights << " in chunk " << ichunk << "/" << nchunks << " " << timestring.str()); } // Fill weights for this chunk into the TTree for (int k = 0; k < neventsinchunk; k++) { for (int l = 0; l < nweights; l++) { rawweights[l] = allrawweights[k][l]; splweights[l] = allsplweights[k][l]; difweights[l] = alldifweights[k][l]; } weighttree->Fill(); } } // Loop over nchunks // Loop over parameter sets // Set All Dials and reconfigure // Loop over events in chunk // Fill Chunkweightcontainers // Once all dials are done, fill the weight tree // Iterator to next chunk outputtestfile->cd(); weighttree->Write(); outputtestfile->Close(); } } /* // Make a high resolution spline set. std::vector nomvals = fRW->GetDialValues(); int testres = FitPar::Config().GetParI("spline_test_resolution"); std::vector< std::vector > scanparset_vals; std::vector< TH1D* > scanparset_hists; // Loop over all params // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; // Get Par Name std::string name = key.GetS("name"); if (!key.Has("low") or !key.Has("high") or !key.Has("step")) { continue; } // Push Back Scan double low = key.GetD("low"); double high = key.GetD("high"); double cur = low; double step = key.GetD("step"); while (cur <= high) { // Make new set std::vector newvals = nomvals; newvals[i] = cur; // Add to vects scanparset_vals.push_back(newvals); TH1D* parhist = (TH1D*)parhisttemplate->Clone(); for (size_t j = 0; j < newvals.size(); j++) { parhist->SetBinContent(j + 1, newvals[j]); } scanparset_hists.push_back(parhist); // Move to next one cur += step; } } // Print out the parameter set to test for (int i = 0; i < scanparset_vals.size(); i++) { std::cout << "Parset " << i; for (int j = 0 ; j < scanparset_vals[i].size(); j++) { std::cout << " " << scanparset_vals[i][j]; } std::cout << std::endl; } // Weight holders double* rawweights = new double[scanparset_vals.size()]; double* splweights = new double[scanparset_vals.size()]; double* difweights = new double[scanparset_vals.size()]; int NParSets = scanparset_vals.size(); // Loop over all event I/O std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { ERR(FTL) << "No input given for set of input events!" << std::endl; throw; } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; ERR(FTL) << "No output give for set of output events! Saving to " << outputfilename << std::endl; } // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { ERR(FTL) << "File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\"" << std::endl; throw; } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); // Make handlers for input and output InputHandlerBase* input = InputUtils::CreateInputHandler("rawevents", inptype, file_descriptor[1]); InputHandlerBase* output = InputUtils::CreateInputHandler("splineevents", InputUtils::kEVSPLN_Input, outputfilename); // Get Base Events for each case. FitEvent* rawevent = input->FirstNuisanceEvent(); FitEvent* splevent = output->FirstNuisanceEvent(); // Setup outputfile std::string outputtest = outputfilename + ".splinetest.1DEventScan.root"; TFile* outputtestfile = new TFile(outputtest.c_str(), "RECREATE"); outputtestfile->cd(); // Save Parameter Sets for (size_t i = 0; i < scanparset_hists.size(); i++) { scanparset_hists[i]->Write(Form("Paramater_Set_%i", (int)i)); } // Save a TTree of weights and differences. TTree* weighttree = new TTree("weightscan", "weightscan"); // Make a branch for each weight set for (size_t i = 0; i < scanparset_hists.size(); i++) { weighttree->Branch(Form("RawWeights_Set_%i", (int)i), &rawweights[i], Form("RawWeights_Set_%i/D", (int)i) ); weighttree->Branch(Form("SplineWeights_Set_%i", (int)i), &splweights[i], Form("SplineWeights_Set_%i/D", (int)i) ); weighttree->Branch(Form("DifWeights_Set_%i", (int)i), &difweights[i], Form("DifWeights_Set_%i/D", (int)i) ); } // Count int i = 0; int nevents = input->GetNEvents(); while (rawevent and splevent) { // Loop over 1D parameter sets. for (size_t j = 0; j < scanparset_vals.size(); j++) { // Reconfigure fRW->SetAllDials(&scanparset_vals[j][0], scanparset_vals[j].size()); fRW->Reconfigure(); // Reconfigure spline RW splweight->SetAllDials(&scanparset_vals[j][0], scanparset_vals[j].size()); splweight->Reconfigure(); splevent->fSplineRead->SetNeedsReconfigure(true); // Calc weight for both events rawweights[j] = fRW->CalcWeight(rawevent); splweights[j] = splweight->CalcWeight(splevent); difweights[j] = splweights[j] - rawweights[j]; } if (i % 1000 == 0) { LOG(FIT) << "Processed " << i << "/" << nevents << std::endl; } // Fill Array weighttree->Fill(); // Iterate to next event. i++; rawevent = input->NextNuisanceEvent(); splevent = output->NextNuisanceEvent(); } outputtestfile->cd(); weighttree->Write(); outputtestfile->Close(); } } */ //************************************* void SplineRoutines::TestSplines_NDEventThrow() { //************************************* // Setup RW Engine if (fRW) delete fRW; SetupRWEngine(); // Make a spline RW Engine too. FitWeight *splweight = new FitWeight("splinerwaweight"); std::vector parameterkeys = Config::QueryKeys("parameter"); TH1D *parhisttemplate = new TH1D("parhist", "parhist", parameterkeys.size(), 0.0, float(parameterkeys.size())); // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; std::string parname = key.GetS("name"); std::string partype = key.GetS("type"); double nom = key.GetD("nominal"); parhisttemplate->SetBinContent(i + 1, nom); parhisttemplate->GetXaxis()->SetBinLabel(i + 1, parname.c_str()); splweight->IncludeDial(key.GetS("name"), kSPLINEPARAMETER, nom); splweight->SetDialValue(key.GetS("name"), key.GetD("nominal")); } splweight->Reconfigure(); // Make a high resolution spline set. std::vector nomvals = fRW->GetDialValues(); // int testres = FitPar::Config().GetParI("spline_test_resolution"); std::vector scanparset_names; std::vector > scanparset_vals; std::vector scanparset_hists; // Loop over all params // Add Parameters int nthrows = FitPar::Config().GetParI("spline_test_throws"); for (int i = 0; i < nthrows; i++) { std::vector newvals = nomvals; for (size_t j = 0; j < parameterkeys.size(); j++) { nuiskey key = parameterkeys[j]; if (!key.Has("low") or !key.Has("high") or !key.Has("step")) { continue; } // Push Back Scan double low = key.GetD("low"); double high = key.GetD("high"); newvals[j] = gRandom->Uniform(low, high); } // Add to vects scanparset_vals.push_back(newvals); TH1D *parhist = (TH1D *)parhisttemplate->Clone(); for (size_t j = 0; j < newvals.size(); j++) { parhist->SetBinContent(j + 1, newvals[j]); } scanparset_hists.push_back(parhist); } // Print out the parameter set to test for (uint i = 0; i < scanparset_vals.size(); i++) { std::cout << "Parset " << i; for (uint j = 0; j < scanparset_vals[i].size(); j++) { std::cout << " " << scanparset_vals[i][j]; } std::cout << std::endl; } // Weight holders double *rawweights = new double[scanparset_vals.size()]; double *splweights = new double[scanparset_vals.size()]; double *difweights = new double[scanparset_vals.size()]; int nweights = scanparset_vals.size(); // int NParSets = scanparset_vals.size(); // Loop over all event I/O std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); // Make handlers for input and output InputHandlerBase *input = InputUtils::CreateInputHandler( "rawevents", inptype, file_descriptor[1]); InputHandlerBase *output = InputUtils::CreateInputHandler( "splineevents", InputUtils::kEVSPLN_Input, outputfilename); // Get Base Events for each case. FitEvent *rawevent = input->FirstNuisanceEvent(); FitEvent *splevent = output->FirstNuisanceEvent(); // Setup outputfile std::string outputtest = outputfilename + ".splinetest.NDEventThrow.root"; TFile *outputtestfile = new TFile(outputtest.c_str(), "RECREATE"); outputtestfile->cd(); // Save Parameter Sets for (size_t i = 0; i < scanparset_hists.size(); i++) { scanparset_hists[i]->Write(Form("Paramater_Set_%i", (int)i)); } // Save a TTree of weights and differences. TTree *weighttree = new TTree("weightscan", "weightscan"); // Make a branch for each weight set for (size_t i = 0; i < scanparset_hists.size(); i++) { weighttree->Branch(Form("RawWeights_Set_%i", (int)i), &rawweights[i], Form("RawWeights_Set_%i/D", (int)i)); weighttree->Branch(Form("SplineWeights_Set_%i", (int)i), &splweights[i], Form("SplineWeights_Set_%i/D", (int)i)); weighttree->Branch(Form("DifWeights_Set_%i", (int)i), &difweights[i], Form("DifWeights_Set_%i/D", (int)i)); } // Count // int i = 0; int nevents = input->GetNEvents(); int lasttime = time(NULL); // Load N Chunks of the Weights into Memory // Split into N processing chunks int nchunks = FitPar::Config().GetParI("spline_chunks"); if (nchunks <= 0) nchunks = 1; if (nchunks >= nevents / 2) nchunks = nevents / 2; std::cout << "Starting NChunks " << nchunks << std::endl; for (int ichunk = 0; ichunk < nchunks; ichunk++) { // Skip to only do one processing chunk // if (procchunk != -1 and procchunk != ichunk) continue; NUIS_LOG(FIT, "On Processing Chunk " << ichunk); int neventsinchunk = nevents / nchunks; int loweventinchunk = neventsinchunk * ichunk; // int higheventinchunk = neventsinchunk * (ichunk + 1); double **allrawweights = new double *[neventsinchunk]; double **allsplweights = new double *[neventsinchunk]; double **alldifweights = new double *[neventsinchunk]; for (int k = 0; k < neventsinchunk; k++) { allrawweights[k] = new double[nweights]; allsplweights[k] = new double[nweights]; alldifweights[k] = new double[nweights]; } // Start Set Processing Here. for (int iset = 0; iset < nweights; iset++) { // Reconfigure fRW->SetAllDials(&scanparset_vals[iset][0], scanparset_vals[iset].size()); fRW->Reconfigure(); // Reconfigure spline RW splweight->SetAllDials(&scanparset_vals[iset][0], scanparset_vals[iset].size()); splweight->Reconfigure(); splevent->fSplineRead->SetNeedsReconfigure(true); // Could reorder this to save the weightconts in order instead of // reconfiguring per event. Loop over all events and fill the TTree for (int i = 0; i < neventsinchunk; i++) { rawevent = input->GetNuisanceEvent(i + loweventinchunk); splevent = output->GetNuisanceEvent(i + loweventinchunk); allrawweights[i][iset] = fRW->CalcWeight(rawevent); allsplweights[i][iset] = splweight->CalcWeight(splevent); alldifweights[i][iset] = allsplweights[i][iset] - allrawweights[i][iset]; } std::ostringstream timestring; int timeelapsed = time(NULL) - lasttime; if (timeelapsed) { lasttime = time(NULL); int setsleft = (nweights - iset - 1) + (nweights * (nchunks - ichunk - 1)); float proj = (float(setsleft) * timeelapsed) / 60 / 60; timestring << setsleft << " sets remaining. Last one took " << timeelapsed << ". " << proj << " hours remaining."; } NUIS_LOG(REC, "Processed Set " << iset << "/" << nweights << " in chunk " << ichunk << "/" << nchunks << " " << timestring.str()); } // Fill weights for this chunk into the TTree for (int k = 0; k < neventsinchunk; k++) { for (int l = 0; l < nweights; l++) { rawweights[l] = allrawweights[k][l]; splweights[l] = allsplweights[k][l]; difweights[l] = alldifweights[k][l]; } weighttree->Fill(); } } // Loop over nchunks // Loop over parameter sets // Set All Dials and reconfigure // Loop over events in chunk // Fill Chunkweightcontainers // Once all dials are done, fill the weight tree // Iterator to next chunk outputtestfile->cd(); weighttree->Write(); outputtestfile->Close(); } } void SplineRoutines::SaveSplinePlots() { if (fRW) delete fRW; SetupRWEngine(); // Setup the spline reader SplineWriter *splwrite = new SplineWriter(fRW); std::vector splinekeys = Config::QueryKeys("spline"); // Add splines to splinewriter for (std::vector::iterator iter = splinekeys.begin(); iter != splinekeys.end(); iter++) { nuiskey splkey = (*iter); // Add Spline Info To Reader splwrite->AddSpline(splkey); } splwrite->SetupSplineSet(); // Event Loop // Loop over all events and calculate weights for each parameter set. // Generate a set of nominal events // Method, Loop over inputs, create input handler, then create a ttree std::vector eventkeys = Config::QueryKeys("events"); for (size_t i = 0; i < eventkeys.size(); i++) { nuiskey key = eventkeys.at(i); // Get I/O std::string inputfilename = key.GetS("input"); if (inputfilename.empty()) { NUIS_ABORT("No input given for set of input events!"); } std::string outputfilename = key.GetS("output"); if (outputfilename.empty()) { outputfilename = inputfilename + ".nuisance.root"; NUIS_ERR(WRN, "No output give for set of output events! Saving to " << outputfilename); } // Make new outputfile outputfilename += ".SplinePlots.root"; TFile *outputfile = new TFile(outputfilename.c_str(), "RECREATE"); outputfile->cd(); // Make a new input handler std::vector file_descriptor = GeneralUtils::ParseToStr(inputfilename, ":"); if (file_descriptor.size() != 2) { NUIS_ABORT("File descriptor had no filetype declaration: \"" << inputfilename << "\". expected \"FILETYPE:file.root\""); } InputUtils::InputType inptype = InputUtils::ParseInputType(file_descriptor[0]); InputHandlerBase *input = InputUtils::CreateInputHandler( "eventsaver", inptype, file_descriptor[1]); // Get info from inputhandler int nevents = input->GetNEvents(); int countwidth = (nevents / 1000); FitEvent *nuisevent = input->FirstNuisanceEvent(); outputfile->cd(); // int lasttime = time(NULL); TCanvas *fitcanvas = NULL; // Loop over all events and fill the TTree while (nuisevent) { // std::cout << "Fitting event " << i << std::endl; // Calculate the weights for each parameter set splwrite->GetWeightsForEvent(nuisevent); splwrite->FitSplinesForEvent(fitcanvas, true); if (fitcanvas) { outputfile->cd(); fitcanvas->Write(Form("Event_SplineCanvas_%i", (int)i)); } // Logging if (i % countwidth == 0) { NUIS_LOG(REC, "Saved " << i << "/" << nevents << " nuisance spline plots. "); } // Iterate i++; nuisevent = input->NextNuisanceEvent(); } // Save flux and close file outputfile->cd(); // Close Output outputfile->Close(); // Delete Inputs delete input; } // remove Keys eventkeys.clear(); } void SplineRoutines::TestSplines_NDLikelihoodThrow() { // Setup RW Engine if (fRW) delete fRW; SetupRWEngine(); // Make a spline RW Engine too. FitWeight *splweight = new FitWeight("splinerwaweight"); std::vector parameterkeys = Config::QueryKeys("parameter"); TH1D *parhisttemplate = new TH1D("parhist", "parhist", parameterkeys.size(), 0.0, float(parameterkeys.size())); // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; std::string parname = key.GetS("name"); std::string partype = key.GetS("type"); double nom = key.GetD("nominal"); parhisttemplate->SetBinContent(i + 1, nom); parhisttemplate->GetXaxis()->SetBinLabel(i + 1, parname.c_str()); splweight->IncludeDial(key.GetS("name"), kSPLINEPARAMETER, nom); splweight->SetDialValue(key.GetS("name"), key.GetD("nominal")); } splweight->Reconfigure(); // Make a high resolution spline set. std::vector nomvals = fRW->GetDialValues(); // int testres = FitPar::Config().GetParI("spline_test_resolution"); std::vector scanparset_names; std::vector > scanparset_vals; std::vector scanparset_hists; // Loop over all params // Add Parameters int nthrows = FitPar::Config().GetParI("spline_test_throws"); for (int i = 0; i < nthrows; i++) { std::vector newvals = nomvals; for (size_t j = 0; j < parameterkeys.size(); j++) { nuiskey key = parameterkeys[j]; if (!key.Has("low") or !key.Has("high") or !key.Has("step")) { continue; } // Push Back Scan double low = key.GetD("low"); double high = key.GetD("high"); newvals[j] = gRandom->Uniform(low, high); } // Add to vects scanparset_vals.push_back(newvals); TH1D *parhist = (TH1D *)parhisttemplate->Clone(); for (size_t j = 0; j < newvals.size(); j++) { parhist->SetBinContent(j + 1, newvals[j]); } scanparset_hists.push_back(parhist); } // Print out the parameter set to test for (uint i = 0; i < scanparset_vals.size(); i++) { std::cout << "Parset " << i; for (uint j = 0; j < scanparset_vals[i].size(); j++) { std::cout << " " << scanparset_vals[i][j]; } std::cout << std::endl; } // Make a new set of Raw/Spline Sample Keys std::vector eventkeys = Config::QueryKeys("events"); std::vector testkeys = Config::QueryKeys("sampletest"); std::vector rawkeys; std::vector splkeys; for (std::vector::iterator iter = testkeys.begin(); iter != testkeys.end(); iter++) { nuiskey key = (*iter); std::string samplename = key.GetS("name"); std::string eventsid = key.GetS("inputid"); nuiskey eventskey = Config::QueryLastKey("events", "id=" + eventsid); std::string rawfile = eventskey.GetS("input"); std::string splfile = eventskey.GetS("output"); nuiskey rawkeytemp = Config::CreateKey("sample"); rawkeytemp.SetS("name", samplename); rawkeytemp.SetS("input", rawfile); nuiskey splkeytemp = Config::CreateKey("sample"); splkeytemp.SetS("name", samplename); splkeytemp.SetS("input", "EVSPLN:" + splfile); rawkeys.push_back(rawkeytemp); splkeys.push_back(splkeytemp); } if (fOutputRootFile) delete fOutputRootFile; fOutputRootFile = new TFile(fOutputFile.c_str(), "RECREATE"); fOutputRootFile->ls(); // Make two new JointFCN JointFCN *rawfcn = new JointFCN(rawkeys, fOutputRootFile); JointFCN *splfcn = new JointFCN(splkeys, fOutputRootFile); // Create iteration tree in output file fOutputRootFile->cd(); rawfcn->CreateIterationTree("raw_iterations", fRW); splfcn->CreateIterationTree("spl_iterations", splweight); // Loop over parameter sets. for (size_t j = 0; j < scanparset_vals.size(); j++) { FitBase::SetRW(fRW); double rawtotal = rawfcn->DoEval(&scanparset_vals[j][0]); FitBase::SetRW(splweight); double spltotal = splfcn->DoEval(&scanparset_vals[j][0]); NUIS_LOG(FIT, "RAW SPLINE DIF = " << rawtotal << " " << spltotal << " " << spltotal - rawtotal); } fOutputRootFile->cd(); rawfcn->WriteIterationTree(); splfcn->WriteIterationTree(); } void SplineRoutines::TestSplines_1DLikelihoodScan() { // Setup RW Engine. if (fRW) delete fRW; SetupRWEngine(); // Setup Parameter Set. // Make a spline RW Engine too. FitWeight *splweight = new FitWeight("splinerwaweight"); // std::vector splinekeys = Config::QueryKeys("spline"); std::vector parameterkeys = Config::QueryKeys("parameter"); TH1D *parhisttemplate = new TH1D("parhist", "parhist", parameterkeys.size(), 0.0, float(parameterkeys.size())); // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; std::string parname = key.GetS("name"); std::string partype = key.GetS("type"); double nom = key.GetD("nominal"); parhisttemplate->SetBinContent(i + 1, nom); parhisttemplate->GetXaxis()->SetBinLabel(i + 1, parname.c_str()); splweight->IncludeDial(key.GetS("name"), kSPLINEPARAMETER, nom); splweight->SetDialValue(key.GetS("name"), key.GetD("nominal")); } splweight->Reconfigure(); // Make a high resolution spline set. std::vector nomvals = fRW->GetDialValues(); // int testres = FitPar::Config().GetParI("spline_test_resolution"); std::vector > scanparset_vals; std::vector scanparset_hists; // Loop over all params // Add Parameters for (size_t i = 0; i < parameterkeys.size(); i++) { nuiskey key = parameterkeys[i]; // Get Par Name std::string name = key.GetS("name"); if (!key.Has("low") or !key.Has("high") or !key.Has("step")) { continue; } // Push Back Scan double low = key.GetD("low"); double high = key.GetD("high"); double cur = low; double step = key.GetD("step"); while (cur <= high) { // Make new set std::vector newvals = nomvals; newvals[i] = cur; // Add to vects scanparset_vals.push_back(newvals); TH1D *parhist = (TH1D *)parhisttemplate->Clone(); for (size_t j = 0; j < newvals.size(); j++) { parhist->SetBinContent(j + 1, newvals[j]); } scanparset_hists.push_back(parhist); // Move to next one cur += step; } } // Print out the parameter set to test for (uint i = 0; i < scanparset_vals.size(); i++) { std::cout << "Parset " << i; for (uint j = 0; j < scanparset_vals[i].size(); j++) { std::cout << " " << scanparset_vals[i][j]; } std::cout << std::endl; } // Make a new set of Raw/Spline Sample Keys std::vector eventkeys = Config::QueryKeys("events"); std::vector testkeys = Config::QueryKeys("sampletest"); std::vector rawkeys; std::vector splkeys; for (std::vector::iterator iter = testkeys.begin(); iter != testkeys.end(); iter++) { nuiskey key = (*iter); std::string samplename = key.GetS("name"); std::string eventsid = key.GetS("inputid"); nuiskey eventskey = Config::QueryLastKey("events", "id=" + eventsid); std::string rawfile = eventskey.GetS("input"); std::string splfile = eventskey.GetS("output"); nuiskey rawkeytemp = Config::CreateKey("sample"); rawkeytemp.SetS("name", samplename); rawkeytemp.SetS("input", rawfile); nuiskey splkeytemp = Config::CreateKey("sample"); splkeytemp.SetS("name", samplename); splkeytemp.SetS("input", "EVSPLN:" + splfile); rawkeys.push_back(rawkeytemp); splkeys.push_back(splkeytemp); } if (fOutputRootFile) delete fOutputRootFile; fOutputRootFile = new TFile(fOutputFile.c_str(), "RECREATE"); fOutputRootFile->ls(); // Make two new JointFCN JointFCN *rawfcn = new JointFCN(rawkeys, fOutputRootFile); JointFCN *splfcn = new JointFCN(splkeys, fOutputRootFile); // Create iteration tree in output file fOutputRootFile->cd(); rawfcn->CreateIterationTree("raw_iterations", fRW); splfcn->CreateIterationTree("spl_iterations", splweight); // Loop over parameter sets. for (size_t j = 0; j < scanparset_vals.size(); j++) { FitBase::SetRW(fRW); double rawtotal = rawfcn->DoEval(&scanparset_vals[j][0]); FitBase::SetRW(splweight); double spltotal = splfcn->DoEval(&scanparset_vals[j][0]); NUIS_LOG(FIT, "RAW SPLINE DIF = " << rawtotal << " " << spltotal << " " << spltotal - rawtotal); } fOutputRootFile->cd(); rawfcn->WriteIterationTree(); splfcn->WriteIterationTree(); } /* MISC Functions */ //************************************* int SplineRoutines::GetStatus() { //************************************* return 0; } diff --git a/src/Routines/SplineRoutines.h b/src/Routines/SplineRoutines.h index 5cedfd2..45c9e00 100755 --- a/src/Routines/SplineRoutines.h +++ b/src/Routines/SplineRoutines.h @@ -1,197 +1,197 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SPLINE_ROUTINES_H #define SPLINE_ROUTINES_H /*! * \addtogroup Minimizer * @{ */ #include "TH1.h" #include "TF1.h" #include "TMatrixD.h" #include "TVectorD.h" #include "TSystem.h" #include "TFile.h" #include "TProfile.h" #include #include #include #include #include #include "FitEvent.h" #include "JointFCN.h" #include "FitLogger.h" #include "BaseFitEvt.h" #include "NuisConfig.h" #include "NuisKey.h" #include "SplineReader.h" #include "SplineWriter.h" #include "SplineMerger.h" #include "ParserUtils.h" #include "OpenMPWrapper.h" enum minstate { kErrorStatus = -1, kGoodStatus, kFitError, kNoChange, kFitFinished, kFitUnfinished, kStateChange, }; //************************************* //! Collects all possible fit routines into a single class to avoid repeated code class SplineRoutines{ //************************************* public: /* Constructor/Destructor */ //! Constructor reads in arguments given at the command line for the fit here. SplineRoutines(int argc, char* argv[]); //! Default destructor ~SplineRoutines(); //! Reset everything to default/NULL void Init(); /* Input Functions */ //! Splits the arguments ready for initial setup void ParseArgs(int argc, char* argv[]); /* Setup Functions */ //! Setup the configuration given the arguments passed at the commandline and card file void SetupConfig(); //! Setups up our custom RW engine with all the parameters passed in the card file void SetupRWEngine(); void Run(); void SaveEvents(); void TestEvents(); void GenerateEventSplines(); void GenerateEventWeights(); void GenerateEventWeightChunks(int procchunk = -1); void BuildEventSplines(int procchunk = -1); void MergeEventSplinesChunks(); /* Testing Functions */ /// Scan parameter space in 1D at finer resolution than points. Compare Raw/Spline on an event by event basis. void TestSplines_1DEventScan(); /// Scan parameter space in 1D at finer resolution than points. Compare likelihoods for all testsamples. void TestSplines_1DLikelihoodScan(); /// Randomly throw in parameter space. For each throw, calc average weight difference. void TestSplines_NDEventThrow(); /// Randomly thow in parameter space. For each throw, calc likelihood difference for each sample. void TestSplines_NDLikelihoodThrow(); /// Generate a set of spline vs weight canvases and save to file void SaveSplinePlots(); /* Fitting Functions */ //! Given a new map change the values that the RW engine is currently set to void UpdateRWEngine(std::map& updateVals); /* MISC Functions */ //! Get previous fit status from a file Int_t GetStatus(); void MergeSplines(); protected: //! Our Custom ReWeight Object FitWeight* rw; FitWeight* fRW; std::string fOutputFile; std::string fInputFile; TFile* fInputRootFile; TFile* fOutputRootFile; JointFCN* fSampleFCN; std::list fSamples; std::string fCardFile; std::string fStrategy; std::vector fRoutines; std::string fAllowedRoutines; // Input Dial Vals //! Vector of dial names std::vector fParams; std::map fStateVals; std::map fStartVals; std::map fCurVals; std::map fErrorVals; std::map fMinVals; std::map fMaxVals; std::map fStepVals; std::map fTypeVals; std::map fFixVals; std::map fStartFixVals; std::vector fGenericInputNames; std::map fGenericInputFiles; std::map fGenericOutputFiles; std::map fGenericOutputTypes; std::map fGenericInputs; std::vector fSplineNames; std::map fSplineTypes; std::map fSplinePoints; nuiskey fCompKey; }; /*! @} */ #endif diff --git a/src/Routines/SystematicRoutines.cxx b/src/Routines/SystematicRoutines.cxx index 2054f24..cb205f7 100755 --- a/src/Routines/SystematicRoutines.cxx +++ b/src/Routines/SystematicRoutines.cxx @@ -1,1490 +1,1490 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "SystematicRoutines.h" void SystematicRoutines::Init() { fInputFile = ""; fInputRootFile = NULL; fOutputFile = ""; fOutputRootFile = NULL; fCovar = fCovarFree = NULL; fCorrel = fCorrelFree = NULL; fDecomp = fDecompFree = NULL; fStrategy = "ErrorBands"; fRoutines.clear(); fRoutines.push_back("ErrorBands"); fCardFile = ""; fFakeDataInput = ""; fSampleFCN = NULL; fAllowedRoutines = ("ErrorBands,PlotLimits"); }; SystematicRoutines::~SystematicRoutines(){}; SystematicRoutines::SystematicRoutines(int argc, char *argv[]) { // Initialise Defaults Init(); nuisconfig configuration = Config::Get(); // Default containers std::string cardfile = ""; std::string maxevents = "-1"; int errorcount = 0; int verbocount = 0; std::vector xmlcmds; std::vector configargs; fNThrows = 250; fStartThrows = 0; fThrowString = ""; // Make easier to handle arguments. std::vector args = GeneralUtils::LoadCharToVectStr(argc, argv); ParserUtils::ParseArgument(args, "-c", fCardFile, true); ParserUtils::ParseArgument(args, "-o", fOutputFile, false, false); ParserUtils::ParseArgument(args, "-n", maxevents, false, false); ParserUtils::ParseArgument(args, "-f", fStrategy, false, false); ParserUtils::ParseArgument(args, "-d", fFakeDataInput, false, false); ParserUtils::ParseArgument(args, "-s", fStartThrows, false, false); ParserUtils::ParseArgument(args, "-t", fNThrows, false, false); ParserUtils::ParseArgument(args, "-p", fThrowString, false, false); ParserUtils::ParseArgument(args, "-i", xmlcmds); ParserUtils::ParseArgument(args, "-q", configargs); ParserUtils::ParseCounter(args, "e", errorcount); ParserUtils::ParseCounter(args, "v", verbocount); ParserUtils::CheckBadArguments(args); // Add extra defaults if none given if (fCardFile.empty() and xmlcmds.empty()) { NUIS_ABORT("No input supplied!"); } if (fOutputFile.empty() and !fCardFile.empty()) { fOutputFile = fCardFile + ".root"; NUIS_ERR(WRN, "No output supplied so saving it to: " << fOutputFile); } else if (fOutputFile.empty()) { NUIS_ABORT("No output file or cardfile supplied!"); } // Configuration Setup ============================= // Check no comp key is available if (Config::Get().GetNodes("nuiscomp").empty()) { fCompKey = Config::Get().CreateNode("nuiscomp"); } else { fCompKey = Config::Get().GetNodes("nuiscomp")[0]; } if (!fCardFile.empty()) fCompKey.Set("cardfile", fCardFile); if (!fOutputFile.empty()) fCompKey.Set("outputfile", fOutputFile); if (!fStrategy.empty()) fCompKey.Set("strategy", fStrategy); // Load XML Cardfile configuration.LoadSettings(fCompKey.GetS("cardfile"), ""); // Add Config Args for (size_t i = 0; i < configargs.size(); i++) { configuration.OverrideConfig(configargs[i]); } if (maxevents.compare("-1")) { configuration.OverrideConfig("MAXEVENTS=" + maxevents); } // Finish configuration XML configuration.FinaliseSettings(fCompKey.GetS("outputfile") + ".xml"); // Add Error Verbo Lines verbocount += Config::GetParI("VERBOSITY"); errorcount += Config::GetParI("ERROR"); std::cout << "[ NUISANCE ]: Setting VERBOSITY=" << verbocount << std::endl; std::cout << "[ NUISANCE ]: Setting ERROR=" << errorcount << std::endl; SETVERBOSITY(verbocount); // Proper Setup if (fStrategy.find("ErrorBands") != std::string::npos || fStrategy.find("MergeErrors") != std::string::npos) { fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); } // fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), // "RECREATE"); SetupSystematicsFromXML(); SetupCovariance(); SetupRWEngine(); SetupFCN(); GetCovarFromFCN(); // Run(); return; }; void SystematicRoutines::SetupSystematicsFromXML() { NUIS_LOG(FIT, "Setting up nuismin"); // Setup Parameters ------------------------------------------ std::vector parkeys = Config::QueryKeys("parameter"); if (!parkeys.empty()) { NUIS_LOG(FIT, "Number of parameters : " << parkeys.size()); } for (size_t i = 0; i < parkeys.size(); i++) { nuiskey key = parkeys.at(i); // Check for type,name,nom if (!key.Has("type")) { NUIS_ABORT("No type given for parameter " << i); } else if (!key.Has("name")) { NUIS_ABORT("No name given for parameter " << i); } else if (!key.Has("nominal")) { NUIS_ABORT("No nominal given for parameter " << i); } // Get Inputs std::string partype = key.GetS("type"); std::string parname = key.GetS("name"); double parnom = key.GetD("nominal"); double parlow = parnom - 1; double parhigh = parnom + 1; double parstep = 1; // Override if state not given if (!key.Has("state")) { key.SetS("state", "FIX"); } std::string parstate = key.GetS("state"); // Extra limits if (key.Has("low")) { parlow = key.GetD("low"); parhigh = key.GetD("high"); parstep = key.GetD("step"); NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parlow << " < p < " << parhigh << " : " << parstate); } else { NUIS_LOG(FIT, "Read " << partype << " : " << parname << " = " << parnom << " : " << parstate); } // Run Parameter Conversion if needed if (parstate.find("ABS") != std::string::npos) { parnom = FitBase::RWAbsToSigma(partype, parname, parnom); parlow = FitBase::RWAbsToSigma(partype, parname, parlow); parhigh = FitBase::RWAbsToSigma(partype, parname, parhigh); parstep = FitBase::RWAbsToSigma(partype, parname, parstep); } else if (parstate.find("FRAC") != std::string::npos) { parnom = FitBase::RWFracToSigma(partype, parname, parnom); parlow = FitBase::RWFracToSigma(partype, parname, parlow); parhigh = FitBase::RWFracToSigma(partype, parname, parhigh); parstep = FitBase::RWFracToSigma(partype, parname, parstep); } // Push into vectors fParams.push_back(parname); fTypeVals[parname] = FitBase::ConvDialType(partype); fStartVals[parname] = parnom; fCurVals[parname] = parnom; fErrorVals[parname] = 0.0; fStateVals[parname] = parstate; bool fixstate = parstate.find("FIX") != std::string::npos; fFixVals[parname] = fixstate; fStartFixVals[parname] = fFixVals[parname]; fMinVals[parname] = parlow; fMaxVals[parname] = parhigh; fStepVals[parname] = parstep; } // Setup Samples ---------------------------------------------- std::vector samplekeys = Config::QueryKeys("sample"); if (!samplekeys.empty()) { NUIS_LOG(FIT, "Number of samples : " << samplekeys.size()); } for (size_t i = 0; i < samplekeys.size(); i++) { nuiskey key = samplekeys.at(i); // Get Sample Options std::string samplename = key.GetS("name"); std::string samplefile = key.GetS("input"); std::string sampletype = key.Has("type") ? key.GetS("type") : "DEFAULT"; double samplenorm = key.Has("norm") ? key.GetD("norm") : 1.0; // Print out NUIS_LOG(FIT, "Read sample info " << i << " : " << samplename << std::endl << "\t\t input -> " << samplefile << std::endl << "\t\t state -> " << sampletype << std::endl << "\t\t norm -> " << samplenorm); // If FREE add to parameters otherwise continue if (sampletype.find("FREE") == std::string::npos) { continue; } // Form norm dial from samplename + sampletype + "_norm"; std::string normname = samplename + "_norm"; // Check normname not already present if (fTypeVals.find(normname) != fTypeVals.end()) { continue; } // Add new norm dial to list if its passed above checks fParams.push_back(normname); fTypeVals[normname] = kNORM; fStateVals[normname] = sampletype; fCurVals[normname] = samplenorm; fErrorVals[normname] = 0.0; fMinVals[normname] = 0.1; fMaxVals[normname] = 10.0; fStepVals[normname] = 0.5; bool state = sampletype.find("FREE") == std::string::npos; fFixVals[normname] = state; fStartFixVals[normname] = state; } // Setup Fake Parameters ----------------------------- std::vector fakekeys = Config::QueryKeys("fakeparameter"); if (!fakekeys.empty()) { NUIS_LOG(FIT, "Number of fake parameters : " << fakekeys.size()); } for (size_t i = 0; i < fakekeys.size(); i++) { nuiskey key = fakekeys.at(i); // Check for type,name,nom if (!key.Has("name")) { NUIS_ABORT("No name given for fakeparameter " << i); } else if (!key.Has("nom")) { NUIS_ABORT("No nominal given for fakeparameter " << i); } // Get Inputs std::string parname = key.GetS("name"); double parnom = key.GetD("nom"); // Push into vectors fFakeVals[parname] = parnom; } } /* 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() { //************************************* NUIS_LOG(FIT, "Making the jointFCN"); if (fSampleFCN) delete fSampleFCN; fSampleFCN = new JointFCN(fOutputRootFile); SetFakeData(); return; } //************************************* void SystematicRoutines::SetFakeData() { //************************************* if (fFakeDataInput.empty()) return; if (fFakeDataInput.compare("MC") == 0) { NUIS_LOG(FIT, "Setting fake data from MC starting prediction."); UpdateRWEngine(fFakeVals); FitBase::GetRW()->Reconfigure(); fSampleFCN->ReconfigureAllEvents(); fSampleFCN->SetFakeData("MC"); UpdateRWEngine(fCurVals); NUIS_LOG(FIT, "Set all data to fake MC predictions."); } else { fSampleFCN->SetFakeData(fFakeDataInput); } return; } //***************************************** // Setup the parameter covariances from the FCN void SystematicRoutines::GetCovarFromFCN() { //***************************************** NUIS_LOG(FIT, "Loading ParamPull objects from FCN to build covariance..."); // Make helperstring std::ostringstream helperstr; // Keep track of what is being thrown std::map dialthrowhandle; // Get Covariance Objects from FCN std::list inputpulls = fSampleFCN->GetPullList(); for (PullListConstIter iter = inputpulls.begin(); iter != inputpulls.end(); iter++) { ParamPull *pull = (*iter); if (pull->GetType().find("THROW") != std::string::npos) { fInputThrows.push_back(pull); fInputCovar.push_back(pull->GetFullCovarMatrix()); fInputDials.push_back(pull->GetDataHist()); NUIS_LOG(FIT, "Read ParamPull: " << pull->GetName() << " " << pull->GetType()); } 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(); // Add to Containers // Set the starting values etc to the postfit fParams.push_back(name); fCurVals[name] = dialhist.GetBinContent(i + 1); // Set the starting values to be nominal MC fStartVals[name] = 0.0; 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(); // If we find the string if (fCurVals.find(name) == fCurVals.end()) { // 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()) { NUIS_ERR(WRN, "No covariances given to nuissyst"); NUIS_ERR(WRN, "Pushing back an uncorrelated gaussian throw error for each " "free parameter using step size"); 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 = "GAUSTHROW/NEUT"; // 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 NUIS_LOG(FIT, "Added ParamPull : " << name << " " << pullterm.str() << " " << type); // 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()) { NUIS_LOG(FIT, "To remove these statements in future studies, add the lines " "below to your card:"); // 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()) { NUIS_LOG(FIT, "Dial " << i << ". " << setw(20) << syst << " = THROWing with " << dialthrowhandle[syst]); } else { NUIS_LOG(FIT, "Dial " << i << ". " << setw(20) << syst << " = is FIXED"); } } } /* Fitting Functions */ //************************************* void SystematicRoutines::UpdateRWEngine( std::map &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(); } //************************************* void SystematicRoutines::PrintState() { //************************************* NUIS_LOG(FIT, "------------"); // Count max size int maxcount = 0; for (UInt_t i = 0; i < fParams.size(); i++) { maxcount = max(int(fParams[i].size()), maxcount); } // Header NUIS_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)"); // 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; NUIS_LOG(FIT, curparstring.str()); } NUIS_LOG(FIT, "------------"); double like = fSampleFCN->GetLikelihood(); NUIS_LOG(FIT, std::left << std::setw(46) << "Likelihood for JointFCN: " << like); NUIS_LOG(FIT, "------------"); } /* Write Functions */ //************************************* void SystematicRoutines::SaveResults() { //************************************* if (!fOutputRootFile) fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); fOutputRootFile->cd(); SaveCurrentState(); } //************************************* void SystematicRoutines::SaveCurrentState(std::string subdir) { //************************************* NUIS_LOG(FIT, "Saving current full FCN predictions"); // 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() { //************************************* if (!fOutputRootFile) fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); fOutputRootFile->cd(); NUIS_LOG(FIT, "Saving Nominal Predictions (be cautious with this)"); FitBase::GetRW()->Reconfigure(); SaveCurrentState("nominal"); }; //************************************* void SystematicRoutines::SavePrefit() { //************************************* if (!fOutputRootFile) fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); fOutputRootFile->cd(); NUIS_LOG(FIT, "Saving Prefit Predictions"); 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 in case pulls are calculated. pull->ResetToy(); } }; //************************************* void SystematicRoutines::PlotLimits() { //************************************* std::cout << "Plotting Limits" << std::endl; if (!fOutputRootFile) fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); 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 allfolders; // Loop through each parameter for (UInt_t i = 0; i < fParams.size(); i++) { std::string syst = fParams[i]; std::cout << "Starting Param " << syst << std::endl; 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; } //************************************* void SystematicRoutines::Run() { //************************************* fRoutines = GeneralUtils::ParseToStr(fStrategy, ","); for (UInt_t i = 0; i < fRoutines.size(); i++) { std::string routine = fRoutines.at(i); int fitstate = kFitUnfinished; NUIS_LOG(FIT, "Running Routine: " << routine); if (routine.compare("PlotLimits") == 0) PlotLimits(); else if (routine.compare("ErrorBands") == 0) GenerateErrorBands(); else if (routine.compare("ThrowErrors") == 0) GenerateThrows(); else if (routine.compare("MergeErrors") == 0) MergeThrows(); else if (routine.compare("EigenErrors") == 0) EigenErrors(); else { NUIS_ABORT("Unknown ROUTINE : " << routine); } // If ending early break here if (fitstate == kFitFinished || fitstate == kNoChange) { NUIS_LOG(FIT, "Ending fit routines loop."); break; } } } void SystematicRoutines::GenerateErrorBands() { GenerateThrows(); MergeThrows(); } //************************************* void SystematicRoutines::GenerateThrows() { //************************************* TFile *tempfile = new TFile((fOutputFile + ".throws.root").c_str(), "RECREATE"); tempfile->cd(); // For generating throws we check with the config int nthrows = Config::GetParI("error_throws"); int startthrows = fStartThrows; int endthrows = startthrows + nthrows; if (nthrows < 0) nthrows = endthrows; if (startthrows < 0) startthrows = 0; if (endthrows < 0) endthrows = startthrows + nthrows; // Setting Seed // Matteo Mazzanti's Fix struct timeval mytime; gettimeofday(&mytime, NULL); Double_t seed = time(NULL) + int(getpid()) + (mytime.tv_sec * 1000.) + (mytime.tv_usec / 1000.); gRandom->SetSeed(seed); // int seed = (gRandom->Uniform(0.0,1.0)*100000 + 100000000*(startthrows + // endthrows) + time(NULL) + int(getpid()) ); gRandom->SetSeed(seed); NUIS_LOG(FIT, "Using Seed : " << seed); NUIS_LOG(FIT, "nthrows = " << nthrows); NUIS_LOG(FIT, "startthrows = " << startthrows); NUIS_LOG(FIT, "endthrows = " << endthrows); UpdateRWEngine(fStartVals); fSampleFCN->ReconfigureAllEvents(); // Make the nominal if (startthrows == 0) { NUIS_LOG(FIT, "Making nominal "); TDirectory *nominal = (TDirectory *)tempfile->mkdir("nominal"); nominal->cd(); fSampleFCN->Write(); // Make the postfit reading from the pull NUIS_LOG(FIT, "Making postfit "); TDirectory *postfit = (TDirectory *)tempfile->mkdir("postfit"); postfit->cd(); UpdateRWEngine(fCurVals); fSampleFCN->ReconfigureSignal(); fSampleFCN->Write(); } 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 < endthrows + 1; i++) { // Generate Random Parameter Throw ThrowCovariance(uniformly); if (i < startthrows) continue; if (i == 0) continue; NUIS_LOG(FIT, "Throw " << i << "/" << endthrows << " ================================"); TDirectory *throwfolder = (TDirectory *)tempfile->mkdir(Form("throw_%i", i)); throwfolder->cd(); // Run Eval double *vals = FitUtils::GetArrayFromMap(fParams, fThrownVals); fSampleFCN->DoEval(vals); delete vals; // Save the FCN fSampleFCN->Write(); } tempfile->cd(); fSampleFCN->WriteIterationTree(); tempfile->Close(); } // Merge throws together into one summary void SystematicRoutines::MergeThrows() { fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); fOutputRootFile->cd(); // Make a container folder TDirectory *errorDIR = (TDirectory *)fOutputRootFile->mkdir("error_bands"); errorDIR->cd(); TDirectory *outnominal = (TDirectory *)fOutputRootFile->mkdir("nominal_throw"); outnominal->cd(); // Split Input Files if (!fThrowString.empty()) fThrowList = GeneralUtils::ParseToStr(fThrowString, ","); // Add default if no throwlist given if (fThrowList.size() < 1) fThrowList.push_back(fOutputFile + ".throws.root"); /// Save location of file containing nominal std::string nominalfile; bool nominalfound; // Loop over files and check they exist. for (uint i = 0; i < fThrowList.size(); i++) { std::string file = fThrowList[i]; bool found = false; // normal std::string newfile = file; TFile *throwfile = new TFile(file.c_str(), "READ"); if (throwfile and !throwfile->IsZombie()) { found = true; } // normal.throws.root if (!found) { newfile = file + ".throws.root"; throwfile = new TFile((file + ".throws.root").c_str(), "READ"); if (throwfile and !throwfile->IsZombie()) { found = true; } } // If its found save to throwlist, else save empty. // Also search for nominal if (found) { fThrowList[i] = newfile; NUIS_LOG(FIT, "Throws File :" << newfile); // Find input which contains nominal if (throwfile->Get("nominal")) { nominalfound = true; nominalfile = newfile; } throwfile->Close(); } else { fThrowList[i] = ""; } delete throwfile; } // Make sure we have a nominal file if (!nominalfound or nominalfile.empty()) { NUIS_ABORT("No nominal found when merging! Exiting!"); } // Get the nominal throws file TFile *tempfile = new TFile((nominalfile).c_str(), "READ"); tempfile->cd(); TDirectory *nominal = (TDirectory *)tempfile->Get("nominal"); bool uniformly = FitPar::Config().GetParB("error_uniform"); // Check percentage of bad files is okay. int badfilecount = 0; for (uint i = 0; i < fThrowList.size(); i++) { if (!fThrowList[i].empty()) { NUIS_LOG(FIT, "Loading Throws From File " << i << " : " << fThrowList[i]); } else { badfilecount++; } } // Check we have at least one good file if ((uint)badfilecount == fThrowList.size()) { NUIS_ABORT("Found no good throw files for MergeThrows"); throw; } else if (badfilecount > (fThrowList.size() * 0.25)) { NUIS_ERR( WRN, "Over 25% of your throw files are dodgy. Please check this is okay!"); NUIS_ERR(WRN, "Will continue for the time being..."); sleep(5); } // 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; TH1 *baseplot = (TH1D *)key->ReadObj(); std::string plotname = std::string(baseplot->GetName()); NUIS_LOGN(FIT, "Creating error bands for " << plotname); if (LOG_LEVEL(FIT)) { if (!uniformly) { NUIS_LOG(FIT, " : Using COVARIANCE Throws! "); } else { NUIS_LOG(FIT, " : Using UNIFORM THROWS!!! "); } } int nbins = 0; if (cl->InheritsFrom("TH1D")) nbins = ((TH1D *)baseplot)->GetNbinsX(); else nbins = ((TH1D *)baseplot)->GetNbinsX() * ((TH1D *)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)); } // Make new throw plot TH1 *newplot; // Run Throw Merging. for (UInt_t i = 0; i < fThrowList.size(); i++) { TFile *throwfile = new TFile(fThrowList[i].c_str(), "READ"); // Loop over all throws in a folder TIter nextthrow(throwfile->GetListOfKeys()); TKey *throwkey; while ((throwkey = (TKey *)nextthrow())) { // Skip non throw folders if (std::string(throwkey->GetName()).find("throw_") == std::string::npos) continue; // Get Throw DIR TDirectory *throwdir = (TDirectory *)throwkey->ReadObj(); // Get Plot From Throw newplot = (TH1 *)throwdir->Get(plotname.c_str()); if (!newplot) continue; // Loop Over Plot 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(); } throwfile->Close(); delete throwfile; } errorDIR->cd(); if (uniformly) { NUIS_LOG(FIT, "Uniformly Calculating Plot Errors!"); } TH1 *statplot = (TH1 *)baseplot->Clone(); for (Int_t j = 0; j < nbins; j++) { if (!uniformly) { // if ((baseplot->GetBinError(j+1)/baseplot->GetBinContent(j+1)) //< 1.0) { // baseplot->SetBinError(j+1,sqrt(pow(tprof->GetBinError(j+1),2) //+ pow(baseplot->GetBinError(j+1),2))); } else { baseplot->SetBinContent(j + 1, tprof->GetBinContent(j + 1)); 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); } } baseplot->SetTitle("Profiled throws"); errorDIR->cd(); baseplot->Write(); tprof->Write(); bintree->Write(); outnominal->cd(); for (int i = 0; i < nbins; i++) { baseplot->SetBinError(i + 1, sqrt(pow(statplot->GetBinError(i + 1), 2) + pow(baseplot->GetBinError(i + 1), 2))); } baseplot->Write(); delete statplot; delete baseplot; delete tprof; delete bintree; delete[] bincontents; } }; void SystematicRoutines::EigenErrors() { fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "RECREATE"); fOutputRootFile->cd(); // Make Covariance TMatrixDSym *fullcovar = new TMatrixDSym(fParams.size()); // Extract covariance from all loaded ParamPulls for (PullListConstIter iter = fInputThrows.begin(); iter != fInputThrows.end(); iter++) { ParamPull *pull = *iter; // Check pull is actualyl Gaussian std::string pulltype = pull->GetType(); if (pulltype.find("GAUSTHROW") == std::string::npos) { NUIS_ABORT("Can only calculate EigenErrors for Gaussian pulls!"); } // Get data and covariances TH1D dialhist = pull->GetDataHist(); TH2D covhist = pull->GetFullCovar(); // Loop over all dials and compare names for (size_t pari = 0; pari < fParams.size(); pari++) { for (size_t parj = 0; parj < fParams.size(); parj++) { std::string name_pari = fParams[pari]; std::string name_parj = fParams[parj]; // Compare names to those in the pull for (int pulli = 0; pulli < dialhist.GetNbinsX(); pulli++) { for (int pullj = 0; pullj < dialhist.GetNbinsX(); pullj++) { std::string name_pulli = dialhist.GetXaxis()->GetBinLabel(pulli + 1); std::string name_pullj = dialhist.GetXaxis()->GetBinLabel(pullj + 1); if (name_pulli == name_pari && name_pullj == name_parj) { (*fullcovar)[pari][parj] = covhist.GetBinContent(pulli + 1, pullj + 1); fCurVals[name_pari] = dialhist.GetBinContent(pulli + 1); fCurVals[name_parj] = dialhist.GetBinContent(pullj + 1); } } } } } } /* TFile* test = new TFile("testingcovar.root","RECREATE"); test->cd(); TH2D* joinedcov = new TH2D("COVAR","COVAR", fullcovar->GetNrows(), 0.0, float(fullcovar->GetNrows()), fullcovar->GetNrows(), 0.0, float(fullcovar->GetNrows())); for (int i = 0; i < fullcovar->GetNrows(); i++){ for (int j = 0; j < fullcovar->GetNcols(); j++){ joinedcov->SetBinContent(i+1, j+1, (*fullcovar)[i][j]); } } joinedcov->Write("COVAR"); test->Close(); */ // Calculator all EigenVectors and EigenValues TMatrixDSymEigen *eigen = new TMatrixDSymEigen(*fullcovar); const TVectorD eigenVals = eigen->GetEigenValues(); const TMatrixD eigenVect = eigen->GetEigenVectors(); eigenVals.Print(); eigenVect.Print(); TDirectory *outnominal = (TDirectory *)fOutputRootFile->mkdir("nominal"); outnominal->cd(); // double *valst = FitUtils::GetArrayFromMap(fParams, fCurVals); // double chi2 = fSampleFCN->DoEval( valst ); // delete valst; fSampleFCN->Write(); // Loop over all throws TDirectory *throwsdir = (TDirectory *)fOutputRootFile->mkdir("throws"); throwsdir->cd(); int count = 0; // Produce all error throws. for (int i = 0; i < eigenVect.GetNrows(); i++) { TDirectory *throwfolder = (TDirectory *)throwsdir->mkdir(Form("throw_%i", count)); throwfolder->cd(); // Get New Parameter Vector NUIS_LOG(FIT, "Parameter Set " << count); for (int j = 0; j < eigenVect.GetNrows(); j++) { std::string param = fParams[j]; NUIS_LOG(FIT, " " << j << ". " << param << " : " << fCurVals[param] + sqrt(eigenVals[i]) * eigenVect[j][i]); fThrownVals[param] = fCurVals[param] + sqrt(eigenVals[i]) * eigenVect[j][i]; } // Run Eval double *vals = FitUtils::GetArrayFromMap(fParams, fThrownVals); double chi2 = fSampleFCN->DoEval(vals); NUIS_LOG(DEB, "Chi2 = " << chi2); delete vals; count++; fSampleFCN->Write(); throwfolder = (TDirectory *)throwsdir->mkdir(Form("throw_%i", count)); throwfolder->cd(); // Get New Parameter Vector NUIS_LOG(FIT, "Parameter Set " << count); for (int j = 0; j < eigenVect.GetNrows(); j++) { std::string param = fParams[j]; NUIS_LOG(FIT, " " << j << ". " << param << " : " << fCurVals[param] - sqrt(eigenVals[i]) * eigenVect[j][i]); fThrownVals[param] = fCurVals[param] - sqrt(eigenVals[i]) * eigenVect[j][i]; } // Run Eval double *vals2 = FitUtils::GetArrayFromMap(fParams, fThrownVals); chi2 = fSampleFCN->DoEval(vals2); NUIS_LOG(DEB, "Chi2 = " << chi2); delete vals2; count++; // Save the FCN fSampleFCN->Write(); } fOutputRootFile->Close(); fOutputRootFile = new TFile(fCompKey.GetS("outputfile").c_str(), "UPDATE"); fOutputRootFile->cd(); throwsdir = (TDirectory *)fOutputRootFile->Get("throws"); outnominal = (TDirectory *)fOutputRootFile->Get("nominal"); // Loop through Error DIR TDirectory *outerr = (TDirectory *)fOutputRootFile->mkdir("errors"); outerr->cd(); TIter next(outnominal->GetListOfKeys()); TKey *key; while ((key = (TKey *)next())) { TClass *cl = gROOT->GetClass(key->GetClassName()); if (!cl->InheritsFrom("TH1D") and !cl->InheritsFrom("TH2D")) continue; NUIS_LOG(FIT, "Creating error bands for " << key->GetName()); std::string plotname = std::string(key->GetName()); if (plotname.find("_EVT") != std::string::npos) continue; if (plotname.find("_FLUX") != std::string::npos) continue; if (plotname.find("_FLX") != std::string::npos) continue; TH1 *baseplot = (TH1D *)key->ReadObj()->Clone(Form("%s_ORIGINAL", key->GetName())); TH1 *errorplot_upper = (TH1D *)baseplot->Clone(Form("%s_ERROR_UPPER", key->GetName())); TH1 *errorplot_lower = (TH1D *)baseplot->Clone(Form("%s_ERROR_LOWER", key->GetName())); TH1 *meanplot = (TH1D *)baseplot->Clone(Form("%s_SET_MEAN", key->GetName())); TH1 *systplot = (TH1D *)baseplot->Clone(Form("%s_SYST", key->GetName())); TH1 *statplot = (TH1D *)baseplot->Clone(Form("%s_STAT", key->GetName())); TH1 *totlplot = (TH1D *)baseplot->Clone(Form("%s_TOTAL", key->GetName())); int nbins = 0; if (cl->InheritsFrom("TH1D")) nbins = ((TH1D *)baseplot)->GetNbinsX(); else nbins = ((TH1D *)baseplot)->GetNbinsX() * ((TH1D *)baseplot)->GetNbinsY(); meanplot->Reset(); errorplot_upper->Reset(); errorplot_lower->Reset(); for (int j = 0; j < nbins; j++) { errorplot_upper->SetBinError(j + 1, 0.0); errorplot_lower->SetBinError(j + 1, 0.0); } // Loop over throws and calculate mean and error for +- throws int addcount = 0; // Add baseplot first to slightly bias to central value meanplot->Add(baseplot); addcount++; for (int i = 0; i < count; i++) { TH1 *newplot = (TH1D *)throwsdir->Get(Form("throw_%i/%s", i, plotname.c_str())); if (!newplot) { NUIS_ERR(WRN, "Cannot find new plot : " << Form("throw_%i/%s", i, plotname.c_str())); NUIS_ERR(WRN, "This plot will not have the correct errors!"); continue; } newplot->SetDirectory(0); nbins = newplot->GetNbinsX(); for (int j = 0; j < nbins; j++) { if (i % 2 == 0) { errorplot_upper->SetBinContent( j + 1, errorplot_upper->GetBinContent(j + 1) + pow(baseplot->GetBinContent(j + 1) - newplot->GetBinContent(j + 1), 2)); } else { errorplot_lower->SetBinContent( j + 1, errorplot_lower->GetBinContent(j + 1) + pow(baseplot->GetBinContent(j + 1) - newplot->GetBinContent(j + 1), 2)); } meanplot->SetBinContent(j + 1, meanplot->GetBinContent(j + 1) + baseplot->GetBinContent(j + 1)); } delete newplot; addcount++; } // Get mean Average for (int j = 0; j < nbins; j++) { meanplot->SetBinContent(j + 1, meanplot->GetBinContent(j + 1) / double(addcount)); } for (int j = 0; j < nbins; j++) { errorplot_upper->SetBinContent( j + 1, sqrt(errorplot_upper->GetBinContent(j + 1))); errorplot_lower->SetBinContent( j + 1, sqrt(errorplot_lower->GetBinContent(j + 1))); statplot->SetBinError(j + 1, baseplot->GetBinError(j + 1)); systplot->SetBinError(j + 1, (errorplot_upper->GetBinContent(j + 1) + errorplot_lower->GetBinContent(j + 1)) / 2.0); totlplot->SetBinError(j + 1, sqrt(pow(statplot->GetBinError(j + 1), 2) + pow(systplot->GetBinError(j + 1), 2))); meanplot->SetBinError(j + 1, sqrt(pow(statplot->GetBinError(j + 1), 2) + pow(systplot->GetBinError(j + 1), 2))); } outerr->cd(); errorplot_upper->Write(); errorplot_lower->Write(); baseplot->Write(); meanplot->Write(); statplot->Write(); systplot->Write(); totlplot->Write(); delete errorplot_upper; delete errorplot_lower; delete baseplot; delete meanplot; delete statplot; delete systplot; delete totlplot; } } diff --git a/src/Routines/SystematicRoutines.h b/src/Routines/SystematicRoutines.h index e40a2bb..3ebf1b4 100755 --- a/src/Routines/SystematicRoutines.h +++ b/src/Routines/SystematicRoutines.h @@ -1,269 +1,269 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SYSTEMATIC_ROUTINES_H #define SYSTEMATIC_ROUTINES_H /*! * \addtogroup Minimizer * @{ */ #include "TH1.h" #include "TF1.h" #include "TMatrixD.h" #include "TVectorD.h" #include "TSystem.h" #include "TFile.h" #include "TProfile.h" #include #include #include #include #include #include #include "FitEvent.h" #include "JointFCN.h" #include "TMatrixDSymEigen.h" #include "ParserUtils.h" enum minstate { kErrorStatus = -1, kGoodStatus, kFitError, kNoChange, kFitFinished, kFitUnfinished, kStateChange, }; //************************************* //! Collects all possible fit routines into a single class to avoid repeated code class SystematicRoutines{ //************************************* public: /* Constructor/Destructor */ //! Constructor reads in arguments given at the command line for the fit here. SystematicRoutines(int argc, char* argv[]); //! Default destructor ~SystematicRoutines(); //! Reset everything to default/NULL void Init(); /* Input Functions */ //! Splits the arguments ready for initial setup void ParseArgs(int argc, char* argv[]); //! Sorts out configuration and verbosity right at the very start. //! Calls readCard to set everything else up. void InitialSetup(); //! Loops through each line of the card file and passes it to other read functions void ReadCard(std::string cardfile); //! Check for parameter string in the line and assign the correct type. //! Fills maps for each of the parameters int ReadParameters(std::string parstring); //! Reads in fake parameters and assigns them (Requires the parameter to be included as a normal parameter as well) int ReadFakeDataPars(std::string parstring); //! Read in the samples so we can set up the free normalisation dials if required int ReadSamples(std::string sampleString); /* Setup Functions */ void SetupSystematicsFromXML(); //! Setup the configuration given the arguments passed at the commandline and card file void SetupConfig(); //! Setups up our custom RW engine with all the parameters passed in the card file void SetupRWEngine(); //! Setups up the jointFCN. void SetupFCN(); //! Sets up the minimizerObj for ROOT. there are cases where this is called repeatedly, e.g. If you are using a brute force scan before using Migrad. void SetupFitter(std::string routine); //! Set the current data histograms in each sample to the fake data. void SetFakeData(); //! Setup the covariances with the correct dimensions. At the start this is either uncorrelated or merged given all the input covariances. //! At the end of the fit this produces the blank covariances which can then be filled by the minimizerObj with best fit covariances. void SetupCovariance(); void GetCovarFromFCN(); /* Fitting Functions */ //! Main function to actually start iterating over the different required fit routines void Run(); //! Given a new map change the values that the RW engine is currently set to void UpdateRWEngine(std::map& updateVals); //! Given a single routine (see tutorial for options) run that fit routine now. int RunFitRoutine(std::string routine); //! Print current value void PrintState(); //! Performs a fit routine where the input.maxevents is set to a much lower value to try and move closer to the best fit minimum. void LowStatRoutine(std::string routine); //! Perform a chi2 scan in 1D around the current point void Create1DScans(); //! Perform a chi2 scan in 2D around the current point void Chi2Scan2D(); //! Currently a placeholder NEEDS UPDATING void CreateContours(); //! If any currentVals are close to the limits set them to the limit and fix them int FixAtLimit(); //! Throw the current covariance of dial values we have, and fill the thrownVals and thrownNorms maps. //! If uniformly is true parameters will be thrown uniformly between their upper and lower limits. void ThrowCovariance(bool uniformly); //! Given the covariance we currently have generate error bands by throwing the covariance. //! The FitPar config "error_uniform" defines whether to throw using the covariance or uniformly. //! The FitPar config "error_throws" defines how many throws are needed. //! Currently only supports TH1D plots. void GenerateErrorBands(); void GenerateThrows(); void MergeThrows(); //! Step through each parameter one by one and create folders containing the MC predictions at each step. //! Doesn't handle correlated parameters well void PlotLimits(); void EigenErrors(); /* Write Functions */ //! Save the sample plots for current MC //! dir if not empty forces plots to be saved in a subdirectory of outputfile void SaveCurrentState(std::string subdir=""); //! Save starting predictions into a separate folder void SaveNominal(); //! Save predictions before the main study is ran into a separate folder void SavePrefit(); //! Save final outputs void SaveResults(); /* MISC Functions */ //! Get previous fit status from a file Int_t GetStatus(); protected: //! Our Custom ReWeight Object FitWeight* rw; std::string fOutputFile; std::string fInputFile; TFile* fInputRootFile; TFile* fOutputRootFile; //! Flag for whether the fit should be continued if an output file is already found. bool fitContinue; //! Minimizer Object for handling roots different minimizer methods JointFCN* fSampleFCN; int nfreepars; std::string fCardFile; std::string fStrategy; std::vector fRoutines; std::string fAllowedRoutines; std::string fFakeDataInput; // Input Dial Vals //! Vector of dial names std::vector fParams; std::map fStateVals; std::map fStartVals; std::map fCurVals; std::map fErrorVals; std::map fMinVals; std::map fMaxVals; std::map fStepVals; std::map fTypeVals; std::map fFixVals; std::map fStartFixVals; //! Vector of fake parameter names std::map fFakeVals; //! Map of thrown parameter names and values (After ThrowCovariance) std::map fThrownVals; TH2D* fCorrel; TH2D* fDecomp; TH2D* fCovar; TH2D* fCorrelFree; TH2D* fDecompFree; TH2D* fCovarFree; std::list fInputThrows; //!< Pointers to pull terms std::vector fInputDials; //!< Vector of Input Histograms std::vector fInputCovar; //!< Vector of Input Covariances nuiskey fCompKey; std::vector fThrowList; std::string fThrowString; int fNThrows; int fStartThrows; }; /*! @} */ #endif diff --git a/src/SciBooNE/CMakeLists.txt b/src/SciBooNE/CMakeLists.txt index 7fdad0c..f501c9f 100644 --- a/src/SciBooNE/CMakeLists.txt +++ b/src/SciBooNE/CMakeLists.txt @@ -1,79 +1,79 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES SciBooNE_CCCOH_STOP_NTrks_nu.cxx SciBooNE_CCCOH_1TRK_1DQ2_nu.cxx SciBooNE_CCCOH_1TRK_1Dpmu_nu.cxx SciBooNE_CCCOH_1TRK_1Dthetamu_nu.cxx SciBooNE_CCCOH_MuPr_1DQ2_nu.cxx SciBooNE_CCCOH_MuPr_1Dthetamu_nu.cxx SciBooNE_CCCOH_MuPr_1Dpmu_nu.cxx SciBooNE_CCCOH_MuPiVA_1DQ2_nu.cxx SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.cxx SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.cxx SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.cxx SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.cxx SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.cxx SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.cxx SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.cxx SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.cxx SciBooNE_CCInc_XSec_1DEnu_nu.cxx SciBooNEUtils.cxx ) set(HEADERFILES SciBooNE_CCCOH_STOP_NTrks_nu.h SciBooNE_CCCOH_1TRK_1DQ2_nu.h SciBooNE_CCCOH_1TRK_1Dpmu_nu.h SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h SciBooNE_CCCOH_MuPr_1DQ2_nu.h SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h SciBooNE_CCCOH_MuPr_1Dpmu_nu.h SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h SciBooNE_CCInc_XSec_1DEnu_nu.h SciBooNEUtils.h ) set(LIBNAME expSciBooNE) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION - "${ExtFit_VERSION_MAJOR}.${ExtFit_VERSION_MINOR}.${ExtFit_VERSION_REVISION}") + "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_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/SciBooNE) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/SciBooNE/SciBooNEUtils.cxx b/src/SciBooNE/SciBooNEUtils.cxx index 635c31e..de6ce20 100644 --- a/src/SciBooNE/SciBooNEUtils.cxx +++ b/src/SciBooNE/SciBooNEUtils.cxx @@ -1,565 +1,560 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "SciBooNEUtils.h" #include "FitUtils.h" double SciBooNEUtils::GetSciBarDensity(){ static double density = 0xdeadbeef; if (density == 0xdeadbeef){ density = FitPar::Config().GetParD("SciBarDensity"); } return density; } double SciBooNEUtils::GetSciBarRecoDist(){ static double dist = 0xdeadbeef; if (dist == 0xdeadbeef){ dist = FitPar::Config().GetParD("SciBarRecoDist"); } return dist; } double SciBooNEUtils::GetPenetratingMuonE(){ static double mue = 0xdeadbeef; if (mue == 0xdeadbeef){ mue = FitPar::Config().GetParD("PenetratingMuonEnergy"); } return mue; } // Replacs with a function to draw from the z distribution that Zach made, and require the pion goes further. // Ignores correlation between angle and distance, but... nevermind double SciBooNEUtils::GetMainPionRange(){ static TF1 *func = new TF1("f1", "250 - (2./3.)*(x-10)", 10, 160); return func->GetRandom(); } int SciBooNEUtils::GetNumRangeSteps(){ static uint nsteps = 0xdeadbeef; if (nsteps == 0xdeadbeef){ nsteps = FitPar::Config().GetParI("NumRangeSteps"); } return nsteps; } bool SciBooNEUtils::GetUseProton(){ static bool isSet = false; static bool usep = false; if (!isSet){ usep = FitPar::Config().GetParB("UseProton"); isSet = true; } return usep; } bool SciBooNEUtils::GetUseZackEff(){ static bool isSet = false; static bool use = false; if (!isSet){ use = FitPar::Config().GetParB("UseZackEff"); isSet = true; } return use; } double SciBooNEUtils::GetFlatEfficiency(){ static double var = 0xdeadbeef; if (var == 0xdeadbeef){ var = FitPar::Config().GetParD("FlatEfficiency"); } return var; } // Obtained from a simple fit to test beam data 1 < p < 2 GeV double SciBooNEUtils::ProtonMisIDProb(double mom){ return 0.1; double prob = 0.10; if (mom < 1) return prob; if (mom > 2) mom = 2; prob = -2.83 + 3.75*mom - 0.96*mom*mom; if (prob < 0.10) prob = 0.10; return prob; } // This function uses pion-scintillator cross sections to calculate the pion SI probability double SciBooNEUtils::PionReinteractionProb(double energy, double thickness){ static TGraph *total_xsec = 0; static TGraph *inel_xsec = 0; if (!total_xsec){ total_xsec = PlotUtils::GetTGraphFromRootFile(FitPar::GetDataBase()+"/SciBooNE/cross_section_pion_scintillator_hd.root", "totalXS"); } if (!inel_xsec){ inel_xsec = PlotUtils::GetTGraphFromRootFile(FitPar::GetDataBase()+"/SciBooNE/cross_section_pion_scintillator_hd.root", "inelXS"); } if (total_xsec->Eval(energy) == 0) return 0; double total = total_xsec->Eval(energy)*1E-27; double inel = inel_xsec->Eval(energy)*1E-27; double prob = (1 - exp(-thickness*SciBooNEUtils::GetSciBarDensity()*4.63242e+22*total))*(inel/total); return prob; } bool SciBooNEUtils::ThrowAcceptReject(double test_value, double ceiling){ static TRandom3 *rand = 0; if (!rand){ rand = new TRandom3(0); } double throw_value = rand->Uniform(ceiling); if (throw_value < test_value) return false; return true; } double SciBooNEUtils::StoppedEfficiency(TH2D *effHist, FitParticle *nu, FitParticle *muon){ double eff = 0.; if (!effHist) return eff; // For Morgan's efficiencies if (!SciBooNEUtils::GetUseZackEff()) eff = effHist->GetBinContent(effHist->GetXaxis()->FindBin(FitUtils::p(muon)), effHist->GetYaxis()->FindBin(FitUtils::th(nu, muon)/TMath::Pi()*180.)); // For Zack's efficiencies else eff = effHist->GetBinContent(effHist->GetXaxis()->FindBin(FitUtils::th(nu, muon)/TMath::Pi()*180.), effHist->GetYaxis()->FindBin(FitUtils::p(muon)*1000.)); return eff; } double SciBooNEUtils::ProtonEfficiency(TH2D *effHist, FitParticle *nu, FitParticle *muon){ double eff = 0.; if (!effHist) return eff; eff = effHist->GetBinContent(effHist->GetXaxis()->FindBin(FitUtils::th(nu, muon)/TMath::Pi()*180.), effHist->GetYaxis()->FindBin(FitUtils::p(muon)*1000.)); return eff; } double SciBooNEUtils::PenetratedEfficiency(FitParticle *nu, FitParticle *muon){ double eff = 0.; if (FitUtils::th(nu, muon)/TMath::Pi()*180. > 50) eff = 0.; if (FitUtils::p(muon) < SciBooNEUtils::GetPenetratingMuonE()) eff = 0.; return eff; } double SciBooNEUtils::BetheBlochCH(double E, double mass){ double beta2 = 1 - mass*mass/E/E; double gamma = 1./sqrt(1-beta2); double mass_ratio = PhysConst::mass_electron*1000./mass; // Argh, have to remember to convert to MeV or you'll hate yourself! double I2 = 68.7e-6*68.7e-6; double w_max = 2*PhysConst::mass_electron*1000.*beta2*gamma*gamma; w_max /= 1 + 2*gamma*mass_ratio + mass_ratio*mass_ratio; // Values taken from the PDG for K = 0.307075 MeV mol-1 cm2, mean ionization energy I = 68.7 eV (Polystyrene) // = 0.53768 (pdg.lbl.gov/AtomicNuclearProperties) double log_term = log(2*PhysConst::mass_electron*1000.*beta2*gamma*gamma*w_max/I2); double dedx = 0.307075*0.53768/beta2*(0.5*log_term - beta2); return dedx; } // This function returns an estimate of the range of the particle in scintillator. // It uses crude integration and Bethe-Bloch to approximate the range. double SciBooNEUtils::RangeInScintillator(FitParticle* particle, int nsteps){ // The particle energy double E = particle->fP.E(); double M = particle->fP.M(); double Ek = E - M; double step_size = Ek/float(nsteps+1); double range = 0; // Add an offset to make the integral a touch more accurate Ek -= step_size/2.; for (int i = 0; i < nsteps; ++i){ double dEdx = SciBooNEUtils::BetheBlochCH(Ek+M, M); Ek -= step_size; // dEdx is -ve range -= step_size/dEdx; // If the particle is a pion. Also consider the reinteraction probability if (abs(particle->fPID) == 211){ double prob = SciBooNEUtils::PionReinteractionProb(Ek, step_size/dEdx/SciBooNEUtils::GetSciBarDensity()); if (!SciBooNEUtils::ThrowAcceptReject(prob)) break; } } // Account for density of polystyrene range /= SciBooNEUtils::GetSciBarDensity(); // Range estimate is in cm return range; } // Function to calculate the distance the particle travels in scintillator bool SciBooNEUtils::PassesDistanceCut(FitParticle* beam, FitParticle* particle){ // First apply some basic thresholds (from K2K SciBar description) if (FitUtils::p(particle) < 0.15) return false; if (particle->fPID == 2212 && FitUtils::p(particle) < 0.45) return false; double dist = SciBooNEUtils::RangeInScintillator(particle, SciBooNEUtils::GetNumRangeSteps()); double zdist = dist*cos(FitUtils::th(beam, particle)); // Allow for vertex migration for backward tracks //if (zdist < 0) zdist -= 2; if (abs(zdist) < SciBooNEUtils::GetSciBarRecoDist()) return false; return true; } int SciBooNEUtils::isProton(FitParticle* track){ if (track->fPID == 2212) return true; return false; } // Function to return the MainTrk int SciBooNEUtils::GetMainTrack(FitEvent *event, TH2D *mupiHist, TH2D *protonHist, FitParticle*& mainTrk, double& weight, bool penetrated){ FitParticle *nu = event->GetNeutrinoIn(); int index = 0; int indexPr = 0; double highWeight = 0; double highWeightPr = 0; double runningWeight= 0; mainTrk = NULL; // Loop over particles for (uint j = 2; j < event->Npart(); ++j){ // Final state only! if (!(event->PartInfo(j))->fIsAlive) continue; if (event->PartInfo(j)->fNEUTStatusCode != 0) continue; int PID = event->PartInfo(j)->fPID; // Only consider pions, muons for now if (abs(PID) != 211 && abs(PID) != 13 && PID != 2212) continue; if (!SciBooNEUtils::GetUseProton() && PID == 2212) continue; // Get the track with the highest weight double thisWeight = 0; if (PID == 2212) { thisWeight = SciBooNEUtils::ProtonEfficiency(protonHist, nu, event->PartInfo(j)); if (thisWeight == 0) continue; if (runningWeight == 0) runningWeight = thisWeight; else runningWeight += (1 - runningWeight)*thisWeight; if (thisWeight < highWeightPr) continue; highWeightPr = thisWeight; indexPr = j; } else { thisWeight = SciBooNEUtils::StoppedEfficiency(mupiHist, nu, event->PartInfo(j)); if (thisWeight == 0) continue; if (runningWeight == 0) runningWeight = thisWeight; else runningWeight += (1 - runningWeight)*thisWeight; if (thisWeight < highWeight) continue; // Add a range calculation for pi+ if (abs(PID) == 211){ double range = SciBooNEUtils::RangeInScintillator(event->PartInfo(j)); if (abs(range) < SciBooNEUtils::GetMainPionRange()) continue; } highWeight = thisWeight; index = j; } } // end loop over particle stack // Use MuPi if it's there, if not, use proton info if (highWeightPr > highWeight){ highWeight = highWeightPr; index = indexPr; } // Pass the weight back (don't want to apply a weight twice by accident) mainTrk = event->PartInfo(index); weight *= highWeight; //weight *= runningWeight; //std::cout << "High weight = " << highWeight << "; running weight = " << runningWeight << std::endl; return index; } void SciBooNEUtils::GetOtherTrackInfo(FitEvent *event, int mainIndex, int& nProtons, int& nPiMus, int& nVertex, FitParticle*& secondTrk){ // Reset everything nPiMus = 0; nProtons = 0; nVertex = 0; secondTrk = NULL; if (mainIndex == 0) return; double highestMom = 0.; // Loop over particles for (uint j = 2; j < event->Npart(); ++j){ // Don't re-count the main track if (j == (uint)mainIndex) continue; // Final state only! if (!(event->PartInfo(j))->fIsAlive) continue; if (event->PartInfo(j)->fNEUTStatusCode != 0) continue; int PID = event->PartInfo(j)->fPID; // Only consider pions, muons, protons if (abs(PID) != 211 && PID != 2212 && abs(PID) != 13) continue; // Must be reconstructed as a track in SciBooNE, and pass inefficiency cut if (SciBooNEUtils::PassesDistanceCut(event->PartInfo(0), event->PartInfo(j)) && !SciBooNEUtils::ThrowAcceptReject(SciBooNEUtils::GetFlatEfficiency())){ // Keep track of the second highest momentum track if (FitUtils::p(event->PartInfo(j)) > highestMom){ highestMom = FitUtils::p(event->PartInfo(j)); secondTrk = event->PartInfo(j); } if (PID == 2212) nProtons += 1; else nPiMus += 1; // Ignore backward tracks for VA } else if ( FitUtils::th(event->PartInfo(0), event->PartInfo(j))/TMath::Pi() < 0.5) nVertex += 1; } // end loop over particle stack return; } double SciBooNEUtils::apply_smear(double central, double width){ static TRandom3 *rand = 0; if (!rand){ rand = new TRandom3(0); } double output = rand->Gaus(central, width); return output; } -// double SciBooNEUtils::apply_double_gaus_smear(double central1, double width1, double central2, double width2){ -// static TF1 *func = new TF1("double_gaus", "exp(-0.5*((x)/1.)**2) + 0.1*exp(-0.5*((x)/5.)**2", -20, 20); -// return func->GetRandom(); -//} - double SciBooNEUtils::smear_p(FitParticle* track, double smear){ static TF1 *f1 = new TF1("f1", "gaus(0)+gaus(3)", -0.8, 0.8); static bool set_pars = false; if (!set_pars){ f1->SetParameter(0, 1275.87); f1->SetParameter(1, -0.0160104); f1->SetParameter(2, 0.0424547); f1->SetParameter(3, 116.157); f1->SetParameter(4, -0.0287358); f1->SetParameter(5, 0.157022); set_pars = true; } double mod_mom = FitUtils::p(track) + f1->GetRandom(); return mod_mom; } double SciBooNEUtils::smear_th(FitParticle* track1, FitParticle* track2, double smear){ static TF1 *f1 = new TF1("f1", "gaus(0)+gaus(3)", -15, 15); static bool set_pars = false; if (!set_pars){ f1->SetParameter(0, 1878.41); f1->SetParameter(1, 0.0622622); f1->SetParameter(2, 0.869508); f1->SetParameter(3, 616.559); f1->SetParameter(4, 0.138734); f1->SetParameter(5, 1.96287); set_pars = true; } double mod_th = FitUtils::th(track1, track2) + f1->GetRandom()*TMath::Pi()/180; return mod_th; } // NOTE: need to adapt this to allow for penetrating events... // Simpler, but gives the same results as in Hirade-san's thesis double SciBooNEUtils::CalcThetaPr(FitEvent *event, FitParticle *main, FitParticle *second, bool penetrated){ FitParticle *nu = event->GetNeutrinoIn(); if (!main || !nu || !second) return -999; // Construct the vector p_pr = (-p_mux, -p_muy, Enurec - pmucosthetamu) // where p_mux, p_muy are the projections of the candidate muon momentum onto the x and y dimension respectively double pmu = main->fP.Vect().Mag(); double pmu_x = main->fP.Vect().X(); double pmu_y = main->fP.Vect().Y(); double theta_s = cos(FitUtils::th(nu, main)); double Enuqe = FitUtils::EnuQErec(pmu/1000.,theta_s, 27., true)*1000.; double p_pr_z = Enuqe - pmu*theta_s; TVector3 p_pr = TVector3(-pmu_x, -pmu_y, p_pr_z); double thetapr = p_pr.Angle(second->fP.Vect())/TMath::Pi()*180.; return thetapr; } double SciBooNEUtils::CalcThetaPi(FitEvent *event, FitParticle *second){ FitParticle *nu = event->GetNeutrinoIn(); if (!second || !nu) return -999; double thetapi = FitUtils::th(nu, second)/TMath::Pi()*180.; return thetapi; } /// Functions to deal with the SB mode stacks SciBooNEUtils::ModeStack::ModeStack(std::string name, std::string title, TH1* hist) { fName = name; fTitle = title; AddMode(0, "CCCOH", "CCCOH", kGreen+2, 2, 3244); AddMode(1, "CCRES", "CCRES", kRed, 2, 3304); AddMode(2, "CCQE", "CCQE", kGray+2, 2, 1001); AddMode(3, "2p2h", "2p2h", kMagenta, 2, 1001); AddMode(4, "Other", "Other", kAzure+1, 2, 1001); StackBase::SetupStack(hist); }; int SciBooNEUtils::ModeStack::ConvertModeToIndex(int mode){ switch (abs(mode)){ case 16: return 0; // CCCOH case 11: case 12: case 13: return 1; // CCRES case 1: return 2; // CCQE case 2: return 3; // 2p2h default: return 4; // Other } }; void SciBooNEUtils::ModeStack::Fill(int mode, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::ModeStack::ConvertModeToIndex(mode), x, y, z, weight); }; void SciBooNEUtils::ModeStack::Fill(FitEvent* evt, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::ModeStack::ConvertModeToIndex(evt->Mode), x, y, z, weight); }; void SciBooNEUtils::ModeStack::Fill(BaseFitEvt* evt, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::ModeStack::ConvertModeToIndex(evt->Mode), x, y, z, weight); }; // Functions to deal with Main track PID stack SciBooNEUtils::MainPIDStack::MainPIDStack(std::string name, std::string title, TH1* hist) { fName = name; fTitle = title; AddMode(0, "mu", "#mu^{-}", kGreen+2, 2, 3244); AddMode(1, "pip", "#pi^{+}", kRed, 2, 3304); AddMode(2, "pim", "#pi^{-}", kGray+2, 2, 1001); AddMode(3, "proton", "p", kMagenta, 2, 1001); AddMode(4, "Other", "Other", kAzure+1, 2, 1001); StackBase::SetupStack(hist); }; int SciBooNEUtils::MainPIDStack::ConvertPIDToIndex(int PID){ switch (PID){ case 13: return 0; case 211: return 1; case -211: return 2; case 2212: return 3; default: return 4; } }; void SciBooNEUtils::MainPIDStack::Fill(int PID, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::MainPIDStack::ConvertPIDToIndex(PID), x, y, z, weight); }; // Functions to deal with second type of mode breakdown (from the thesis) SciBooNEUtils::ModeStack2::ModeStack2(std::string name, std::string title, TH1* hist) { fName = name; fTitle = title; AddMode(0, "CCCOH", "#nu CC coh. #pi", kGreen+2, 2, 3244); AddMode(1, "CCRES", "#nu CC res. #pi", kRed, 2, 3304); AddMode(2, "ANTINU", "#bar{#nu} BG", kMagenta, 2, 1001); AddMode(3, "NC", "#nu NC", kYellow, 2, 1001); AddMode(4, "CCOTHER", "#nu CC other", kBlue+2, 2, 1001); AddMode(5, "CCQE", "#nu CCQE", kBlack, 2, 1001); AddMode(6, "2p2h", "#nu 2p2h", kGray+1, 2, 1001); StackBase::SetupStack(hist); }; int SciBooNEUtils::ModeStack2::ConvertModeToIndex(int mode){ // Catch wrong sign contribution if (mode < 0) return 2; // Catch NC contributions if (mode > 30) return 3; switch (abs(mode)){ case 16: return 0; // CCCOH case 11: case 12: case 13: return 1; // CCRES case 1: return 5; // CCQE case 2: return 6; // 2p2h default: return 4; // Other } }; void SciBooNEUtils::ModeStack2::Fill(int mode, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::ModeStack2::ConvertModeToIndex(mode), x, y, z, weight); }; void SciBooNEUtils::ModeStack2::Fill(FitEvent* evt, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::ModeStack2::ConvertModeToIndex(evt->Mode), x, y, z, weight); }; void SciBooNEUtils::ModeStack2::Fill(BaseFitEvt* evt, double x, double y, double z, double weight) { StackBase::FillStack(SciBooNEUtils::ModeStack2::ConvertModeToIndex(evt->Mode), x, y, z, weight); }; diff --git a/src/SciBooNE/SciBooNEUtils.h b/src/SciBooNE/SciBooNEUtils.h index e10f3fc..a97c4fc 100644 --- a/src/SciBooNE/SciBooNEUtils.h +++ b/src/SciBooNE/SciBooNEUtils.h @@ -1,143 +1,143 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SCIBOONEUTILS_H_SEEN #define SCIBOONEUTILS_H_SEEN #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "FitParticle.h" #include "FitEvent.h" #include "FitLogger.h" #include "StandardStacks.h" /*! * \addtogroup Utils * @{ */ namespace SciBooNEUtils { double GetSciBarDensity(); double GetSciBarRecoDist(); double GetPenetratingMuonE(); double GetMainPionRange(); double GetFlatEfficiency(); int GetNumRangeSteps(); bool GetUseProton(); bool GetUseZackEff(); double PionReinteractionProb(double energy, double thickness); bool ThrowAcceptReject(double test_value, double ceiling=1.0); double apply_smear(double central, double width); double smear_p(FitParticle* track, double smear=0.10); // smearing in GeV double smear_th(FitParticle* track1, FitParticle* track2, double smear=2); // smearing in degrees int isProton(FitParticle* track); double ProtonMisIDProb(double mom); double StoppedEfficiency(TH2D *effHist, FitParticle *nu, FitParticle *muon); double ProtonEfficiency(TH2D *effHist, FitParticle *nu, FitParticle *muon); double PenetratedEfficiency(FitParticle *nu, FitParticle *muon); double BetheBlochCH(double beta, double mass); double RangeInScintillator(FitParticle* particle, int nsteps=50); bool PassesDistanceCut(FitParticle* beam, FitParticle* particle); int GetMainTrack(FitEvent *event, TH2D *mupiHist, TH2D *protonHist, FitParticle*& mainTrk, double& weight, bool penetrated=false); void GetOtherTrackInfo(FitEvent *event, int mainIndex, int& nProtons, int& nPiMus, int& nVertex, FitParticle*& secondTrk); double CalcThetaPr(FitEvent *event, FitParticle *main, FitParticle *second, bool penetrated=false); double CalcThetaPi(FitEvent *event, FitParticle *second); /// Break down the plots as in the SciBooNE papers class ModeStack : public StackBase { public: /// Main constructor listing true mode categories. ModeStack(std::string name, std::string title, TH1* hist); /// List to convert Modes to Index. /// Should be kept in sync with constructor. int ConvertModeToIndex(int mode); /// Fill from given mode integer void Fill(int mode, double x, double y = 1.0, double z = 1.0, double weight = 1.0); /// Extracts Mode from FitEvent and fills void Fill(FitEvent* evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); /// Extracts Mode from BaseFitEvt void Fill(BaseFitEvt* evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; /// Break down the plots as in the SciBooNE thesis class ModeStack2 : public StackBase { public: /// Main constructor listing true mode categories. ModeStack2(std::string name, std::string title, TH1* hist); /// List to convert Modes to Index. /// Should be kept in sync with constructor. int ConvertModeToIndex(int mode); /// Fill from given mode integer void Fill(int mode, double x, double y = 1.0, double z = 1.0, double weight = 1.0); /// Extracts Mode from FitEvent and fills void Fill(FitEvent* evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); /// Extracts Mode from BaseFitEvt void Fill(BaseFitEvt* evt, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; class MainPIDStack : public StackBase { public: /// Main constructor listing categories MainPIDStack(std::string name, std::string title, TH1* hist); /// List to convert Maintrack PID to Index. /// Should be kept in sync with constructor. int ConvertPIDToIndex(int PID); /// Fill from given PID void Fill(int PID, double x, double y = 1.0, double z = 1.0, double weight = 1.0); }; } #endif diff --git a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.cxx b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.cxx index c9057ac..50cf352 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.cxx +++ b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.cxx @@ -1,100 +1,101 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "SciBooNE_CCCOH_1TRK_1DQ2_nu.h" SciBooNE_CCCOH_1TRK_1DQ2_nu::SciBooNE_CCCOH_1TRK_1DQ2_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1 track sample.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Entries/0.05 (GeV^{2})"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH 1TRK"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig10a_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); // Estimate the number of CH molecules in SciBooNE... - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_1TRK_1DQ2_nu::FillEventVariables(FitEvent *event){ q2qe = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ q2qe = FitUtils::Q2QErec(SciBooNEUtils::smear_p(this->mainTrack),cos(SciBooNEUtils::smear_th(nu,this->mainTrack)), 27., true); } if (q2qe < 0) q2qe = 0; //return; // Set X Variables fXVar = q2qe; return; }; bool SciBooNE_CCCOH_1TRK_1DQ2_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nProtons+this->nPiMus != 0) return false; return true; }; void SciBooNE_CCCOH_1TRK_1DQ2_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; } diff --git a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.h b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.h index a7e02bd..7d3ded7 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1DQ2_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 10a from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_1TRK_1DQ2_NU_H_SEEN #define SCIBOONE_CCCOH_1TRK_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_1TRK_1DQ2_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_1TRK_1DQ2_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_1TRK_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double q2qe; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_1TRK_1Dpmu_nu.h" SciBooNE_CCCOH_1TRK_1Dpmu_nu::SciBooNE_CCCOH_1TRK_1Dpmu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30a_pmu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_1TRK_1Dpmu_nu::FillEventVariables(FitEvent *event){ pmu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); if (this->mainTrack){ pmu = FitUtils::p(this->mainTrack);//SciBooNEUtils::smear_p(this->mainTrack); } if (pmu < 0) pmu = 0;//return; // Set X Variables fXVar = pmu; return; }; bool SciBooNE_CCCOH_1TRK_1Dpmu_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nProtons+this->nPiMus != 0) return false; return true; }; void SciBooNE_CCCOH_1TRK_1Dpmu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dpmu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dpmu_nu.h index 8478dbf..9bc308d 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dpmu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dpmu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom right) from Hiraide's thesis #ifndef SCIBOONE_CCCOH_1TRK_1DPMU_NU_H_SEEN #define SCIBOONE_CCCOH_1TRK_1DPMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_1TRK_1Dpmu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_1TRK_1Dpmu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_1TRK_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double pmu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h" SciBooNE_CCCOH_1TRK_1Dthetamu_nu::SciBooNE_CCCOH_1TRK_1Dthetamu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#mu}"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30a_thetamu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_1TRK_1Dthetamu_nu::FillEventVariables(FitEvent *event){ thetamu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ thetamu = cos(SciBooNEUtils::smear_th(nu,this->mainTrack)); } if (thetamu < 0) thetamu = 0;//return; // Set X Variables fXVar = thetamu; return; }; bool SciBooNE_CCCOH_1TRK_1Dthetamu_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nProtons+this->nPiMus != 0) return false; return true; }; void SciBooNE_CCCOH_1TRK_1Dthetamu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h index 7351af4..fecdc5b 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_1TRK_1Dthetamu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom left) from Hiride's thesis #ifndef SCIBOONE_CCCOH_1TRK_1DTHETAMU_NU_H_SEEN #define SCIBOONE_CCCOH_1TRK_1DTHETAMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_1TRK_1Dthetamu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_1TRK_1Dthetamu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_1TRK_1Dthetamu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double thetamu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h" SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu::SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Entries/0.05 (GeV^{2})"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig10d_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu::FillEventVariables(FitEvent *event){ q2qe = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ q2qe = FitUtils::Q2QErec(SciBooNEUtils::smear_p(this->mainTrack),cos(SciBooNEUtils::smear_th(nu,this->mainTrack)), 27., true); } if (q2qe < 0) q2qe = 0;//return; // Set X Variables fXVar = q2qe; return; }; bool SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex != 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->mainTrack)); if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h index 0b73904..ec86001 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 10d from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_MUPINOVA_1DQ2_NU_H_SEEN #define SCIBOONE_CCCOH_MUPINOVA_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiNoVA_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double q2qe; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h" SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu::SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30d_pmu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu::FillEventVariables(FitEvent *event){ pmu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); if (this->mainTrack){ pmu = FitUtils::p(this->mainTrack);//SciBooNEUtils::smear_p(this->mainTrack); } if (pmu < 0) pmu = 0;//return; // Set X Variables fXVar = pmu; return; }; bool SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex != 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->mainTrack)); if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h index 41411ca..901271d 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom right) from Hiraide's thesis #ifndef SCIBOONE_CCCOH_MUPINOVA_1DPMU_NU_H_SEEN #define SCIBOONE_CCCOH_MUPINOVA_1DPMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiNoVA_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double pmu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h" SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu::SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#mu}"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30d_thetamu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu::FillEventVariables(FitEvent *event){ thetamu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ thetamu = cos(SciBooNEUtils::smear_th(nu,this->mainTrack)); } if (thetamu < 0) thetamu = 0;//return; // Set X Variables fXVar = thetamu; return; }; bool SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex != 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->mainTrack)); if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h index ec93676..c99ab57 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom left) from Hiride's thesis #ifndef SCIBOONE_CCCOH_MUPINOVA_1DTHETAMU_NU_H_SEEN #define SCIBOONE_CCCOH_MUPINOVA_1DTHETAMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiNoVA_1Dthetamu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double thetamu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h" SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu::SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent pion no VA pion angle.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Pion track angle (degrees)"); fSettings.SetYTitle("Entries/5 degrees"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig12_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu::FillEventVariables(FitEvent *event){ this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); thetapi = SciBooNEUtils::CalcThetaPi(event, this->secondTrack); if (thetapi < 0) return; // Set X Variables fXVar = thetapi; return; }; bool SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex != 0) return false; // Require dth_proton > 20 if (SciBooNEUtils::CalcThetaPr(event, this->mainTrack, this->secondTrack) < 20) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->mainTrack)); if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1-misIDProb); return true; }; void SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h index b511a5d..2c30d5b 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 12 from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_MUPINOVA_1DTHETAPI_NU_H_SEEN #define SCIBOONE_CCCOH_MUPINOVA_1DTHETAPI_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiNoVA_1Dthetapi_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double thetapi; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h" SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu::SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1 pion no VA #theta_{pr}.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#Delta #theta_{p} (degrees)"); fSettings.SetYTitle("Entries/5 degrees"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH pion no VA #theta_{pr}"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig11_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu::FillEventVariables(FitEvent *event){ thetapr = -999; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); thetapr = SciBooNEUtils::CalcThetaPr(event, this->mainTrack, this->secondTrack); if (thetapr < 0) { //std::cout << "Error: theta_pr = " << thetapr << std::endl; return; } // Set X Variables fXVar = thetapr; return; }; bool SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex != 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->mainTrack)); if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h index bb7cf5f..551a659 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 11 from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_MUPINOVA_1DTHETAPR_NU_H_SEEN #define SCIBOONE_CCCOH_MUPINOVA_1DTHETAPR_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiNoVA_1Dthetapr_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double thetapr; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h" SciBooNE_CCCOH_MuPiVA_1DQ2_nu::SciBooNE_CCCOH_MuPiVA_1DQ2_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1 pion with VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Entries/0.05 (GeV^{2})"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig10c_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiVA_1DQ2_nu::FillEventVariables(FitEvent *event){ q2qe = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ q2qe = FitUtils::Q2QErec(SciBooNEUtils::smear_p(this->mainTrack),cos(SciBooNEUtils::smear_th(nu,this->mainTrack)), 27., true); } if (q2qe < 0) q2qe = 0; //return; // Set X Variables fXVar = q2qe; return; }; bool SciBooNE_CCCOH_MuPiVA_1DQ2_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex == 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiVA_1DQ2_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h index 60a8766..d2d050b 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1DQ2_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 10c from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_MUPIVA_1DQ2_NU_H_SEEN #define SCIBOONE_CCCOH_MUPIVA_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiVA_1DQ2_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiVA_1DQ2_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiVA_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double q2qe; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h" SciBooNE_CCCOH_MuPiVA_1Dpmu_nu::SciBooNE_CCCOH_MuPiVA_1Dpmu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30c_pmu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiVA_1Dpmu_nu::FillEventVariables(FitEvent *event){ pmu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); if (this->mainTrack){ pmu = FitUtils::p(this->mainTrack);//SciBooNEUtils::smear_p(this->mainTrack); } if (pmu < 0) pmu = 0;//return; // Set X Variables fXVar = pmu; return; }; bool SciBooNE_CCCOH_MuPiVA_1Dpmu_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex == 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiVA_1Dpmu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h index 8ace090..add49f3 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dpmu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom right) from Hiraide's thesis #ifndef SCIBOONE_CCCOH_MUPIVA_1DPMU_NU_H_SEEN #define SCIBOONE_CCCOH_MUPIVA_1DPMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiVA_1Dpmu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiVA_1Dpmu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiVA_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double pmu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h" SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu::SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#mu}"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30c_thetamu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu::FillEventVariables(FitEvent *event){ thetamu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ thetamu = cos(SciBooNEUtils::smear_th(nu,this->mainTrack)); } if (thetamu < 0) thetamu = 0;//return; // Set X Variables fXVar = thetamu; return; }; bool SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu::isSignal(FitEvent *event){ if (!this->mainTrack || !this->secondTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex == 0) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h index aea7231..a9d40e0 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom left) from Hiride's thesis #ifndef SCIBOONE_CCCOH_MUPIVA_1DTHETAMU_NU_H_SEEN #define SCIBOONE_CCCOH_MUPIVA_1DTHETAMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPiVA_1Dthetamu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double thetamu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPr_1DQ2_nu.h" SciBooNE_CCCOH_MuPr_1DQ2_nu::SciBooNE_CCCOH_MuPr_1DQ2_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent proton sample.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Entries/0.05 (GeV^{2})"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig10b_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID " + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPr_1DQ2_nu::FillEventVariables(FitEvent *event){ q2qe = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ q2qe = FitUtils::Q2QErec(SciBooNEUtils::smear_p(this->mainTrack),cos(SciBooNEUtils::smear_th(nu,this->mainTrack)), 27., true); } if (q2qe < 0) q2qe = 0; //return; // Set X Variables fXVar = q2qe; return; }; bool SciBooNE_CCCOH_MuPr_1DQ2_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; if (this->nProtons == 1) this->Weight *= (1 - misIDProb); if (this->nPiMus == 1) this->Weight *= misIDProb; return true; }; void SciBooNE_CCCOH_MuPr_1DQ2_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPr_1DQ2_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPr_1DQ2_nu.h index d1ef680..5622100 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPr_1DQ2_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPr_1DQ2_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 10b from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_MUPR_1DQ2_NU_H_SEEN #define SCIBOONE_CCCOH_MUPR_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPr_1DQ2_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPr_1DQ2_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPr_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double q2qe; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPr_1Dpmu_nu.h" SciBooNE_CCCOH_MuPr_1Dpmu_nu::SciBooNE_CCCOH_MuPr_1Dpmu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30b_pmu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPr_1Dpmu_nu::FillEventVariables(FitEvent *event){ pmu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); if (this->mainTrack){ pmu = FitUtils::p(this->mainTrack);//SciBooNEUtils::smear_p(this->mainTrack); } if (pmu < 0) pmu = 0;//return; // Set X Variables fXVar = pmu; return; }; bool SciBooNE_CCCOH_MuPr_1Dpmu_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; if (this->nProtons == 1) this->Weight *= (1 - misIDProb); if (this->nPiMus == 1) this->Weight *= misIDProb; return true; }; void SciBooNE_CCCOH_MuPr_1Dpmu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dpmu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dpmu_nu.h index fe26dca..1bd7d8d 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dpmu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dpmu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom right) from Hiraide's thesis #ifndef SCIBOONE_CCCOH_MUPR_1DPMU_NU_H_SEEN #define SCIBOONE_CCCOH_MUPR_1DPMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPr_1Dpmu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPr_1Dpmu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPr_1Dpmu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double pmu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h" SciBooNE_CCCOH_MuPr_1Dthetamu_nu::SciBooNE_CCCOH_MuPr_1Dthetamu_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1pion no VA.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("cos#theta_{#mu}"); fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7.30b_thetamu.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack2(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_MuPr_1Dthetamu_nu::FillEventVariables(FitEvent *event){ thetamu = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ thetamu = cos(SciBooNEUtils::smear_th(nu,this->mainTrack)); } if (thetamu < 0) thetamu = 0;//return; // Set X Variables fXVar = thetamu; return; }; bool SciBooNE_CCCOH_MuPr_1Dthetamu_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; if (this->nProtons == 1) this->Weight *= (1 - misIDProb); if (this->nPiMus == 1) this->Weight *= misIDProb; return true; }; void SciBooNE_CCCOH_MuPr_1Dthetamu_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h b/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h index d0084f8..3bda1a4 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_MuPr_1Dthetamu_nu.h @@ -1,50 +1,50 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 7.30 (bottom left) from Hiride's thesis #ifndef SCIBOONE_CCCOH_MUPR_1DTHETAMU_NU_H_SEEN #define SCIBOONE_CCCOH_MUPR_1DTHETAMU_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_MuPr_1Dthetamu_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_MuPr_1Dthetamu_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_MuPr_1Dthetamu_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack2 *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double thetamu; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h" SciBooNE_CCCOH_STOPFINAL_1DQ2_nu::SciBooNE_CCCOH_STOPFINAL_1DQ2_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent 1 pion no VA #theta_{pr}.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("Entries/0.05 (GeV^{2})"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH pion no VA FINAL"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig13_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); }; void SciBooNE_CCCOH_STOPFINAL_1DQ2_nu::FillEventVariables(FitEvent *event){ q2qe = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); FitParticle *nu = event->GetNeutrinoIn(); if (this->mainTrack){ q2qe = FitUtils::Q2QErec(SciBooNEUtils::smear_p(this->mainTrack),cos(SciBooNEUtils::smear_th(nu,this->mainTrack)), 27., true); } if (q2qe < 0) q2qe = 0; //return; // Set X Variables fXVar = q2qe; return; }; bool SciBooNE_CCCOH_STOPFINAL_1DQ2_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; if (this->nPiMus + this->nProtons != 1) return false; if (this->nVertex != 0) return false; // Require dth_proton > 20 if (SciBooNEUtils::CalcThetaPr(event, this->mainTrack, this->secondTrack) < 20) return false; // Require dth_pion < 90 if (SciBooNEUtils::CalcThetaPi(event, this->secondTrack) > 90) return false; if (SciBooNEUtils::isProton(this->mainTrack)) this->Weight *= 0.1; double misIDProb = SciBooNEUtils::ProtonMisIDProb(FitUtils::p(this->secondTrack)); if (this->nProtons == 1) this->Weight *= misIDProb; if (this->nPiMus == 1) this->Weight *= (1 - misIDProb); return true; }; void SciBooNE_CCCOH_STOPFINAL_1DQ2_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h b/src/SciBooNE/SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h index 9e07ca5..118008b 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_STOPFINAL_1DQ2_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 10d from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_STOPFINAL_1DQ2_NU_H_SEEN #define SCIBOONE_CCCOH_STOPFINAL_1DQ2_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_STOPFINAL_1DQ2_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_STOPFINAL_1DQ2_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_STOPFINAL_1DQ2_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double q2qe; ///. *******************************************************************************/ #include "SciBooNE_CCCOH_STOP_NTrks_nu.h" SciBooNE_CCCOH_STOP_NTrks_nu::SciBooNE_CCCOH_STOP_NTrks_nu(nuiskey samplekey){ // Sample overview std::string descrip = "SciBooNE CC-coherent N. tracks.\n" \ "Target: CH \n" \ "Flux: SciBooNE FHC numu \n"; // Common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2} (GeV^{2})"); - fSettings.SetYTitle("Entries/0.05 (GeV^{2})"); + fSettings.SetXTitle("N. tracks"); + fSettings.SetYTitle("Entries"); this->SetFitOptions("NOWIDTH"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fSettings.SetTitle("SciBooNE CCCOH proton"); fSettings.SetDataInput( FitPar::GetDataBase()+"/SciBooNE/SB_COH_Fig7_CVs.csv"); fSettings.SetHasExtraHistograms(true); fSettings.DefineAllowedSpecies("numu"); SetDataFromTextFile(fSettings.GetDataInput()); FinaliseSampleSettings(); // Setup Plots if (SciBooNEUtils::GetUseZackEff()) this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu_ZACK.root", "Ratio2DBSCC"); else this->muonStopEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_stopped_muon_eff_nu.root", "stopped_muon_eff"); this->protonEff = PlotUtils::GetTH2DFromRootFile(FitPar::GetDataBase()+"/SciBooNE/SciBooNE_proton_nu.root", "Ratio2DRS"); this->fMCStack = new SciBooNEUtils::ModeStack(fSettings.Name() + "_Stack", "Mode breakdown" + fSettings.PlotTitles(), PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); this->fPIDStack = new SciBooNEUtils::MainPIDStack(fSettings.Name() + "_MainPID", "Main PID" + fSettings.PlotTitles(), - PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName())); + PlotUtils::GetTH1DFromFile(fSettings.GetDataInput(), fSettings.GetName()+"_MainPID")); SetAutoProcessTH1(fMCStack); SetAutoProcessTH1(fPIDStack); - double nTargets = 10.6E6/13.*6.022E23; - this->fScaleFactor = GetEventHistogram()->Integral()*13.*1E-38/double(fNEvents)*nTargets; + double nTargets = 10.6E6/1.6749E-27*1E-3; + double pot = FitPar::Config().GetParD("SciBooNEScale"); + this->fScaleFactor = GetEventHistogram()->Integral()*1E-38/double(fNEvents)*nTargets*pot; FinaliseMeasurement(); - + fSaveFine = false; }; void SciBooNE_CCCOH_STOP_NTrks_nu::FillEventVariables(FitEvent *event){ nTrks = 0; this->mainIndex = SciBooNEUtils::GetMainTrack(event, this->muonStopEff, this->protonEff, this->mainTrack, this->Weight); SciBooNEUtils::GetOtherTrackInfo(event, this->mainIndex, this->nProtons, this->nPiMus, this->nVertex, this->secondTrack); nTrks = nProtons + nPiMus; if (this->mainTrack) nTrks += 1; else return; // Set X Variables fXVar = nTrks; return; }; bool SciBooNE_CCCOH_STOP_NTrks_nu::isSignal(FitEvent *event){ if (!this->mainTrack) return false; return true; }; void SciBooNE_CCCOH_STOP_NTrks_nu::FillExtraHistograms(MeasurementVariableBox* vars, double weight){ if (Signal){ fMCStack->Fill(Mode, fXVar, weight); fPIDStack->Fill(this->mainTrack->fPID, fXVar, weight); } return; }; diff --git a/src/SciBooNE/SciBooNE_CCCOH_STOP_NTrks_nu.h b/src/SciBooNE/SciBooNE_CCCOH_STOP_NTrks_nu.h index 6c2e76e..4476776 100644 --- a/src/SciBooNE/SciBooNE_CCCOH_STOP_NTrks_nu.h +++ b/src/SciBooNE/SciBooNE_CCCOH_STOP_NTrks_nu.h @@ -1,51 +1,51 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // This class corresponds to Fig 10a from PRD78 112004 (2008) #ifndef SCIBOONE_CCCOH_STOP_NTRKS_NU_H_SEEN #define SCIBOONE_CCCOH_STOP_NTRKS_NU_H_SEEN #include "Measurement1D.h" #include "SciBooNEUtils.h" //******************************************************************** class SciBooNE_CCCOH_STOP_NTrks_nu : public Measurement1D { //******************************************************************** public: SciBooNE_CCCOH_STOP_NTrks_nu(nuiskey samplekey); virtual ~SciBooNE_CCCOH_STOP_NTrks_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); void FillExtraHistograms(MeasurementVariableBox* vars, double weight); SciBooNEUtils::ModeStack *fMCStack; SciBooNEUtils::MainPIDStack *fPIDStack; private: double nTrks; ///. *******************************************************************************/ #include "SciBooNE_CCInc_XSec_1DEnu_nu.h" //******************************************************************** SciBooNE_CCInc_XSec_1DEnu_nu::SciBooNE_CCInc_XSec_1DEnu_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "SciBooNE_CCInc_XSec_1DEnu_nu sample. \n" "Target: CH \n" "Flux: SciBooNE Forward Horn Current\n" "Signal: Any event with 1 muon \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("E_{#nu} (GeV)"); - fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/Nucleon)"); + fSettings.SetYTitle("#sigma(E_{#nu}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/FULL,DIAG/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.25, 8.0); fSettings.DefineAllowedTargets("C,H"); fSettings.FoundFill("name", "NUANCE", use_nuance, true); // use_nuance plot information fSettings.SetTitle("SciBooNE_CCInc_XSec_1DEnu_nu"); if (!use_nuance) { fSettings.SetDataInput(FitPar::GetDataBase() + "SciBooNE/CCInc/ccinc_1denu_neut.txt"); fSettings.SetCovarInput(FitPar::GetDataBase() + "SciBooNE/CCInc/ccinc_1denu_neut_cov.txt"); } else { fSettings.SetDataInput(FitPar::GetDataBase() + "SciBooNE/CCInc/ccinc_1denu_nuance.txt"); fSettings.SetCovarInput(FitPar::GetDataBase() + "SciBooNE/CCInc/ccinc_1denu_nuance_cov.txt"); } fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2 fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / double(fNEvents); // Plot Setup ------------------------------------------------------- SetDataFromTextFile(fSettings.GetDataInput()); SetCorrelationFromTextFile(fSettings.GetCovarInput()); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void SciBooNE_CCInc_XSec_1DEnu_nu::FillEventVariables(FitEvent *event) { if (isSignal(event)) { fXVar = event->GetNeutrinoIn()->fP.E()*1E-3; } }; bool SciBooNE_CCInc_XSec_1DEnu_nu::isSignal(FitEvent *event) { return SignalDef::isCCINC(event, 14, EnuMin, EnuMax); } diff --git a/src/SciBooNE/SciBooNE_CCInc_XSec_1DEnu_nu.h b/src/SciBooNE/SciBooNE_CCInc_XSec_1DEnu_nu.h index d6586cd..0301664 100644 --- a/src/SciBooNE/SciBooNE_CCInc_XSec_1DEnu_nu.h +++ b/src/SciBooNE/SciBooNE_CCInc_XSec_1DEnu_nu.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SCIBOONE_CCINC_XSEC_1DENU_NU_H_SEEN #define SCIBOONE_CCINC_XSEC_1DENU_NU_H_SEEN #include "Measurement1D.h" class SciBooNE_CCInc_XSec_1DEnu_nu : public Measurement1D { public: SciBooNE_CCInc_XSec_1DEnu_nu(nuiskey samplekey); virtual ~SciBooNE_CCInc_XSec_1DEnu_nu(){}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); bool use_nuance; // Compare to the nuance-unfolded data }; #endif diff --git a/src/Smearceptance/CMakeLists.txt b/src/Smearceptance/CMakeLists.txt index e8b2fb8..3c3c80e 100644 --- a/src/Smearceptance/CMakeLists.txt +++ b/src/Smearceptance/CMakeLists.txt @@ -1,70 +1,70 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(HEADERFILES ISmearcepter.h Smearcepterton.h EfficiencyApplicator.h ThresholdAccepter.h TrackedMomentumMatrixSmearer.h GaussianSmearer.h EnergyShuffler.h MetaSimpleSmearcepter.h SmearceptanceUtils.h ) set(IMPLFILES ISmearcepter.cxx Smearcepterton.cxx EfficiencyApplicator.cxx ThresholdAccepter.cxx TrackedMomentumMatrixSmearer.cxx GaussianSmearer.cxx EnergyShuffler.cxx MetaSimpleSmearcepter.cxx SmearceptanceUtils.cxx ) set(LIBNAME Smearceptance) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Smearceptance) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Smearceptance/EfficiencyApplicator.cxx b/src/Smearceptance/EfficiencyApplicator.cxx index ebed17b..2e0f790 100644 --- a/src/Smearceptance/EfficiencyApplicator.cxx +++ b/src/Smearceptance/EfficiencyApplicator.cxx @@ -1,388 +1,388 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "EfficiencyApplicator.h" #include "TEfficiency.h" #include "TH2.h" #include "TH3.h" //#define DEBUG_EFFAPP EfficiencyApplicator::DependVar GetVarType(std::string const &axisvar) { if (axisvar == "kMomentum") { return EfficiencyApplicator::kMomentum; } else if (axisvar == "kKE") { return EfficiencyApplicator::kKE; } else if (axisvar == "kTheta") { return EfficiencyApplicator::kTheta; } else if (axisvar == "kCosTheta") { return EfficiencyApplicator::kCosTheta; } else if (axisvar == "kPhi") { return EfficiencyApplicator::kPhi; } return EfficiencyApplicator::kNoAxis; } TH1 *GetEffHist(TFile *inputFile, std::string const &HistName) { TH1 *hist = dynamic_cast(inputFile->Get(HistName.c_str())); if (hist) { return hist; } TEfficiency *effHist = dynamic_cast(inputFile->Get(HistName.c_str())); if (effHist) { TH1D *numer = dynamic_cast(effHist->GetCopyPassedHisto()); TH1D *denom = dynamic_cast(effHist->GetCopyTotalHisto()); if (numer && denom) { numer->Divide(denom); denom->SetDirectory(NULL); delete denom; // Gonna be a memory leak, but I'll get over it numer->SetDirectory(NULL); return numer; } NUIS_ERR(FTL, "TEfficiency internal histograms were not TH1Ds."); } NUIS_ABORT("Couldn't get appropriate efficiency object named " << HistName << " from input file " << inputFile->GetName()); } /// Reads particle efficiency nodes /// /// Nodes look like: /// /// /// /// /// /// void EfficiencyApplicator::SpecifcSetup(nuiskey &nk) { rand.~TRandom3(); new (&rand) TRandom3(); std::vector effDescriptors = nk.GetListOfChildNodes("EfficiencyCurve"); for (size_t t_it = 0; t_it < effDescriptors.size(); ++t_it) { std::string inputFileName = effDescriptors[t_it].GetS("InputFile"); std::string HistName = effDescriptors[t_it].GetS("HistName"); TFile inputFile(inputFileName.c_str()); if (!inputFile.IsOpen()) { NUIS_ABORT("Couldn't open specified input root file: " << inputFileName); } TH1 *inpHist = GetEffHist(&inputFile, HistName); if (!inpHist) { NUIS_ABORT("Couldn't get TH1D named: " << HistName << " from input root file: " << inputFileName); } int NDims = effDescriptors[t_it].GetI("NDims"); if (NDims < 1 || NDims > 3) { NUIS_ABORT("Read NDims attribute as: " << NDims << ", efficiency curve can " "currently have between 1 " "and 3 dimensions."); } EfficiencyApplicator::DependVar XVar = GetVarType(effDescriptors[t_it].GetS("XAxis")); double XAxisScale = effDescriptors[t_it].Has("XAxisScaleToInternal") ? effDescriptors[t_it].GetD("XAxisScaleToInternal") : 1; EfficiencyApplicator::DependVar YVar = NDims > 1 ? GetVarType(effDescriptors[t_it].GetS("YAxis")) : EfficiencyApplicator::kNoAxis; double YAxisScale = effDescriptors[t_it].Has("YAxisScaleToInternal") ? effDescriptors[t_it].GetD("YAxisScaleToInternal") : 1; EfficiencyApplicator::DependVar ZVar = NDims > 2 ? GetVarType(effDescriptors[t_it].GetS("ZAxis")) : EfficiencyApplicator::kNoAxis; double ZAxisScale = effDescriptors[t_it].Has("ZAxisScaleToInternal") ? effDescriptors[t_it].GetD("ZAxisScaleToInternal") : 1; bool Interpolate = effDescriptors[t_it].Has("Interpolate") && effDescriptors[t_it].GetI("Interpolate"); // bool ApplyAsWeight = effDescriptors[t_it].Has("ApplyAsWeight") && // effDescriptors[t_it].GetI("ApplyAsWeight"); std::string pdgs_s = effDescriptors[t_it].GetS("PDG"); std::vector pdgs_i = GeneralUtils::ParseToInt(pdgs_s, ","); for (size_t pdg_it = 0; pdg_it < pdgs_i.size(); ++pdg_it) { if (Efficiencies.count(pdgs_i[pdg_it])) { NUIS_ERR(WRN, "Smearceptor " << ElementName << ":" << InstanceName << " already has a efficiency for PDG: " << pdgs_i[pdg_it]); } EffMap em; em.EffCurve = static_cast(inpHist->Clone()); em.EffCurve->SetDirectory(NULL); em.Interpolate = Interpolate; // em.ApplyAsWeight = ApplyAsWeight; em.NDims = NDims; em.DependVars[0] = XVar; em.DependVars[1] = YVar; em.DependVars[2] = ZVar; em.AxisScales[0] = XAxisScale; em.AxisScales[1] = YAxisScale; em.AxisScales[2] = ZAxisScale; Efficiencies[pdgs_i[pdg_it]] = em; NUIS_LOG(FIT, "Added reconstruction efficiency curve for PDG: " << pdgs_i[pdg_it]); } } SlaveTA.Setup(nk); } RecoInfo *EfficiencyApplicator::Smearcept(FitEvent *fe) { RecoInfo *ri = new RecoInfo(); for (size_t p_it = 0; p_it < fe->NParticles(); ++p_it) { FitParticle *fp = fe->GetParticle(p_it); #ifdef DEBUG_EFFAPP std::cout << std::endl; std::cout << "[" << p_it << "]: " << fp->PDG() << ", " << fp->Status() << ", " << fp->E() << " -- KE:" << fp->KE() << " Mom: " << fp->P3().Mag() << std::flush; #endif if (fp->Status() != kFinalState) { #ifdef DEBUG_EFFAPP std::cout << " -- Not final state." << std::flush; #endif continue; } if (!Efficiencies.count(fp->PDG())) { SlaveTA.SmearceptOneParticle(ri, fp #ifdef DEBUG_THRESACCEPT , p_it #endif ); continue; } EffMap &em = Efficiencies[fp->PDG()]; double kineProps[3]; for (Int_t dim_it = 0; dim_it < em.NDims; ++dim_it) { switch (em.DependVars[dim_it]) { case kMomentum: { kineProps[dim_it] = fp->P3().Mag(); break; } case kKE: { kineProps[dim_it] = fp->KE(); break; } case kTheta: { kineProps[dim_it] = fp->P3().Theta(); break; } case kCosTheta: { kineProps[dim_it] = fp->P3().CosTheta(); break; } case kPhi: { kineProps[dim_it] = fp->P3().Phi(); break; } default: { NUIS_ABORT("Trying to find particle value for a kNoAxis."); } } kineProps[dim_it] /= em.AxisScales[dim_it]; } double effProb = 0; switch (em.NDims) { case 1: { TH1 *hist = em.EffCurve; if (em.Interpolate && (hist->GetXaxis()->GetBinCenter(1) < kineProps[0]) && (hist->GetXaxis()->GetBinCenter(hist->GetXaxis()->GetNbins()) > kineProps[0])) { effProb = hist->Interpolate(kineProps[0]); } else { Int_t xbin = hist->GetXaxis()->FindFixBin(kineProps[0]); if (!xbin || ((hist->GetXaxis()->GetNbins() + 1) == xbin)) { NUIS_ERR(WRN, "Tried to apply effiency but XBin: " << xbin << " is outside range (/" << hist->GetXaxis()->GetNbins() << "): Prop " << kineProps[0] << ", [" << hist->GetXaxis()->GetBinLowEdge(1) << " -- " << hist->GetXaxis()->GetBinUpEdge( hist->GetXaxis()->GetNbins())); } effProb = hist->GetBinContent(xbin); } break; } case 2: { TH2 *hist = static_cast(em.EffCurve); if (em.Interpolate && (hist->GetXaxis()->GetBinCenter(1) < kineProps[0]) && (hist->GetXaxis()->GetBinCenter(hist->GetXaxis()->GetNbins()) > kineProps[0]) && (hist->GetYaxis()->GetBinCenter(1) < kineProps[1]) && (hist->GetYaxis()->GetBinCenter(hist->GetYaxis()->GetNbins()) > kineProps[1])) { effProb = hist->Interpolate(kineProps[0], kineProps[1]); } else { Int_t xbin = hist->GetXaxis()->FindFixBin(kineProps[0]); Int_t ybin = hist->GetYaxis()->FindFixBin(kineProps[1]); if (!xbin || ((hist->GetXaxis()->GetNbins() + 1) == xbin)) { NUIS_ERR(WRN, "Tried to apply effiency but XBin: " << xbin << " is outside range (/" << hist->GetXaxis()->GetNbins() << "): Prop " << kineProps[0] << ", [" << hist->GetXaxis()->GetBinLowEdge(1) << " -- " << hist->GetXaxis()->GetBinUpEdge( hist->GetXaxis()->GetNbins())); } if (!ybin || ((hist->GetYaxis()->GetNbins() + 1) == ybin)) { NUIS_ERR(WRN, "Tried to apply effiency but XBin: " << ybin << " is outside range (/" << hist->GetYaxis()->GetNbins() << "): Prop " << kineProps[0] << ", [" << hist->GetYaxis()->GetBinLowEdge(1) << " -- " << hist->GetYaxis()->GetBinUpEdge( hist->GetYaxis()->GetNbins())); } effProb = hist->GetBinContent(xbin, ybin); #ifdef DEBUG_EFFAPP std::cout << "\t\t: XProp: " << kineProps[0] << ", YProp: " << kineProps[1] << " x/y bins: " << xbin << "/" << ybin << ". Prop ? " << effProb << std::endl; #endif } break; } case 3: { TH3 *hist = static_cast(em.EffCurve); if (em.Interpolate && (hist->GetXaxis()->GetBinCenter(1) < kineProps[0]) && (hist->GetXaxis()->GetBinCenter(hist->GetXaxis()->GetNbins()) > kineProps[0]) && (hist->GetYaxis()->GetBinCenter(1) < kineProps[1]) && (hist->GetYaxis()->GetBinCenter(hist->GetYaxis()->GetNbins()) > kineProps[2]) && (hist->GetZaxis()->GetBinCenter(hist->GetZaxis()->GetNbins()) > kineProps[2])) { effProb = hist->Interpolate(kineProps[0], kineProps[1], kineProps[2]); } else { Int_t xbin = hist->GetXaxis()->FindFixBin(kineProps[0]); Int_t ybin = hist->GetYaxis()->FindFixBin(kineProps[1]); Int_t zbin = hist->GetZaxis()->FindFixBin(kineProps[2]); if (!xbin || ((hist->GetXaxis()->GetNbins() + 1) == xbin)) { NUIS_ERR(WRN, "Tried to apply effiency but XBin: " << xbin << " is outside range (/" << hist->GetXaxis()->GetNbins() << "): Prop " << kineProps[0] << ", [" << hist->GetXaxis()->GetBinLowEdge(1) << " -- " << hist->GetXaxis()->GetBinUpEdge( hist->GetXaxis()->GetNbins())); } if (!ybin || ((hist->GetYaxis()->GetNbins() + 1) == ybin)) { NUIS_ERR(WRN, "Tried to apply effiency but XBin: " << ybin << " is outside range (/" << hist->GetYaxis()->GetNbins() << "): Prop " << kineProps[0] << ", [" << hist->GetYaxis()->GetBinLowEdge(1) << " -- " << hist->GetYaxis()->GetBinUpEdge( hist->GetYaxis()->GetNbins())); } if (!zbin || ((hist->GetZaxis()->GetNbins() + 1) == zbin)) { NUIS_ERR(WRN, "Tried to apply effiency but ZBin: " << zbin << " is outside range (/" << hist->GetZaxis()->GetNbins() << "): Prop " << kineProps[0] << ", [" << hist->GetZaxis()->GetBinLowEdge(1) << " -- " << hist->GetZaxis()->GetBinUpEdge( hist->GetZaxis()->GetNbins())); } effProb = hist->GetBinContent(xbin, ybin, zbin); } break; } } bool accepted = (rand.Uniform() < effProb); if (accepted) { #ifdef DEBUG_EFFAPP std::cout << " -- Reconstructed with probability: " << effProb << std::flush; #endif ri->RecObjMom.push_back(fp->P3()); ri->RecObjClass.push_back(fp->PDG()); continue; } #ifdef DEBUG_EFFAPP std::cout << " -- Rejected with probability: " << effProb << std::flush; #endif SlaveTA.SmearceptOneParticle(ri, fp #ifdef DEBUG_THRESACCEPT , p_it #endif ); } #ifdef DEBUG_EFFAPP std::cout << std::endl; #endif #ifdef DEBUG_EFFAPP std::cout << "Reconstructed " << ri->RecObjMom.size() << " particles. " << std::endl; #endif return ri; } diff --git a/src/Smearceptance/EfficiencyApplicator.h b/src/Smearceptance/EfficiencyApplicator.h index 4b3abce..f001f63 100644 --- a/src/Smearceptance/EfficiencyApplicator.h +++ b/src/Smearceptance/EfficiencyApplicator.h @@ -1,56 +1,56 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef EFFICIENCYAPPLICATOR_HXX_SEEN #define EFFICIENCYAPPLICATOR_HXX_SEEN #include "ISmearcepter.h" #include "ThresholdAccepter.h" #include "TRandom3.h" #include class EfficiencyApplicator : public ISmearcepter { public: enum DependVar { kMomentum, kKE, kTheta, kCosTheta, kPhi, kNoAxis }; private: struct EffMap { TH1 *EffCurve; bool Interpolate; // Need to work out how best to apply this. //bool ApplyAsWeight; int NDims; EfficiencyApplicator::DependVar DependVars[3]; double AxisScales[3]; }; std::map Efficiencies; void SpecifcSetup(nuiskey &); TRandom3 rand; ThresholdAccepter SlaveTA; public: RecoInfo *Smearcept(FitEvent *); ~EfficiencyApplicator(); }; #endif diff --git a/src/Smearceptance/EnergyShuffler.h b/src/Smearceptance/EnergyShuffler.h index d3a80ba..ad87359 100644 --- a/src/Smearceptance/EnergyShuffler.h +++ b/src/Smearceptance/EnergyShuffler.h @@ -1,49 +1,49 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ENERGYSHUFFLER_HXX_SEEN #define ENERGYSHUFFLER_HXX_SEEN #include "ISmearcepter.h" #include // #define DEBUG_ESHUFFLER /// Tool for shuffles KE between systems. /// Because it needs to run before an accepter has a chance to throw away /// particles it should not be an ISmearcepter and instead built into other /// smearcepters. class EnergyShuffler { private: struct ShuffleDescriptor { std::vector ToPDGs; double EFraction; }; std::vector< std::pair > ShufflersDescriptors; public: void Setup(nuiskey &); void DoTheShuffle(FitEvent *); }; #endif diff --git a/src/Smearceptance/GaussianSmearer.cxx b/src/Smearceptance/GaussianSmearer.cxx index 7fe6d66..981eef0 100644 --- a/src/Smearceptance/GaussianSmearer.cxx +++ b/src/Smearceptance/GaussianSmearer.cxx @@ -1,529 +1,529 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GaussianSmearer.h" namespace { GaussianSmearer::GSmearType GetVarType(std::string const &type) { if (type == "Absolute") { return GaussianSmearer::kAbsolute; } else if (type == "Fractional") { return GaussianSmearer::kFractional; } else if (type == "Function") { return GaussianSmearer::kFunction; } return GaussianSmearer::kNoType; } GaussianSmearer::DependVar GetKineType(std::string const &axisvar) { if (axisvar == "Momentum") { return GaussianSmearer::kMomentum; } else if (axisvar == "KE") { return GaussianSmearer::kKE; } else if (axisvar == "TEVis") { return GaussianSmearer::kTEVis; } else if (axisvar == "KEVis") { return GaussianSmearer::kKEVis; } else if (axisvar == "CosTheta") { return GaussianSmearer::kCosTheta; } else if (axisvar == "Theta") { return GaussianSmearer::kTheta; } NUIS_ABORT("Failed to parse smear type from \"" << axisvar << "\""); } std::string GetKineTypeName(GaussianSmearer::DependVar dv) { switch (dv) { case GaussianSmearer::kMomentum: { return "Momentum"; } case GaussianSmearer::kKE: { return "KE"; } case GaussianSmearer::kTEVis: { return "TEVis"; } case GaussianSmearer::kKEVis: { return "KEVis"; } case GaussianSmearer::kCosTheta: { return "CosTheta"; } case GaussianSmearer::kTheta: { return "Theta"; } default: { NUIS_ABORT("NO VAR!"); } } } } /// Nodes look like: /// Function attribute is given to a TF1, where any "V"s are replaced with the /// selected kinematic property on an event-by-event basis. e.g Function="{V} + /// gaus({P1}),..." with P1="0.2", should give the same result as /// Type="kFractional" and Width="0.2". /// /// /// void GaussianSmearer::SpecifcSetup(nuiskey &nk) { rand.~TRandom3(); new (&rand) TRandom3(); std::vector smearDescriptors = nk.GetListOfChildNodes("Smear"); for (size_t t_it = 0; t_it < smearDescriptors.size(); ++t_it) { std::string pdgs_s = smearDescriptors[t_it].GetS("PDG"); std::vector pdgs_i = GeneralUtils::ParseToInt(pdgs_s, ","); double Width = smearDescriptors[t_it].Has("Width") ? smearDescriptors[t_it].GetD("Width") : 0xdeadbeef; GaussianSmearer::GSmearType Type = GetVarType(smearDescriptors[t_it].GetS("Type")); GaussianSmearer::DependVar Kinematics = GetKineType(smearDescriptors[t_it].GetS("Kinematics")); bool IsVisSmear = (Kinematics == GaussianSmearer::kKEVis) || (Kinematics == GaussianSmearer::kTEVis); TF1 *sf = NULL; if (Type == GaussianSmearer::kFunction) { std::string funcDescriptor = smearDescriptors[t_it].Has("Function") ? smearDescriptors[t_it].GetS("Function") : ""; if (funcDescriptor.size()) { std::vector funcP = GeneralUtils::ParseToStr(funcDescriptor, "$"); if (funcP.size() != 3) { NUIS_ABORT( "Expected Function attribute to contain 3 comma separated " "entries. e.g. Function=\"1/{V}$$\". "); } bool FoundParam; int pCtr = 1; std::map PVals; do { std::stringstream pv_str(""); pv_str << "P" << pCtr++; if (smearDescriptors[t_it].Has(pv_str.str())) { PVals.insert( std::make_pair(std::string("{") + pv_str.str() + "}", smearDescriptors[t_it].GetS(pv_str.str()))); FoundParam = true; } else { FoundParam = false; } } while (FoundParam); for (std::map::iterator v_it = PVals.begin(); v_it != PVals.end(); ++v_it) { funcP[0] = GeneralUtils::ReplaceAll(funcP[0], v_it->first, v_it->second); } funcP[0] = GeneralUtils::ReplaceAll(funcP[0], "{V}", "[0]"); NUIS_LOG(FIT, "Added smearing func: " << funcP[0] << ", [" << GeneralUtils::StrToDbl(funcP[1]) << " -- " << GeneralUtils::StrToDbl(funcP[2]) << "]."); sf = new TF1("smear_dummy", funcP[0].c_str(), GeneralUtils::StrToDbl(funcP[1]), GeneralUtils::StrToDbl(funcP[2])); } else { NUIS_ABORT( "Expected Function attribute with 3 comma separated " "entries. e.g. Function=\"1/x,,\". "); } } for (size_t pdg_it = 0; pdg_it < pdgs_i.size(); ++pdg_it) { if (IsVisSmear && VisGausSmears.count(pdgs_i[pdg_it])) { NUIS_ERR(WRN, "Smearceptor " << ElementName << ":" << InstanceName << " already has a Visible Energy smearing function for PDG: " << pdgs_i[pdg_it]); } GSmear gs; gs.type = Type; gs.smearVar = Kinematics; gs.width = Width; gs.func = sf ? static_cast(sf->Clone()) : NULL; if (sf) { std::stringstream ss(""); ss << "GausSmear" << "_PDG" << pdgs_i[pdg_it]; gs.func->SetName(ss.str().c_str()); } if (IsVisSmear) { VisGausSmears[pdgs_i[pdg_it]] = gs; } else { TrackedGausSmears[pdgs_i[pdg_it]].push_back(gs); } NUIS_LOG(SAM, "Added gaussian " << GetKineTypeName(gs.smearVar) << " smearing function for PDG: " << pdgs_i[pdg_it]); } delete sf; } } void GaussianSmearer::SmearceptOneParticle(RecoInfo *ri, FitParticle *fp #ifdef DEBUG_GAUSSSMEAR , size_t p_it #endif ) { #ifdef DEBUG_GAUSSSMEAR std::cout << std::endl; std::cout << "[" << p_it << "]: " << fp->PDG() << ", " << fp->Status() << ", " << fp->E() << " -- KE:" << fp->KE() << " Mom: " << fp->P3().Mag() << std::flush; #endif if (fp->Status() != kFinalState) { #ifdef DEBUG_GAUSSSMEAR std::cout << " -- Not final state." << std::flush; #endif return; } if ((TrackedGausSmears.count(fp->PDG()) + VisGausSmears.count(fp->PDG())) == 0) { #ifdef DEBUG_GAUSSSMEAR std::cout << " -- Undetectable." << std::flush; #endif return; } if (TrackedGausSmears.count(fp->PDG())) { TVector3 ThreeMom = fp->P3(); for (size_t sm_it = 0; sm_it < TrackedGausSmears[fp->PDG()].size(); ++sm_it) { GSmear &sm = TrackedGausSmears[fp->PDG()][sm_it]; double kineProp = 0; switch (sm.smearVar) { case GaussianSmearer::kMomentum: { kineProp = fp->P3().Mag(); break; } case GaussianSmearer::kKE: { kineProp = fp->KE(); break; } case GaussianSmearer::kCosTheta: { kineProp = fp->P3().CosTheta(); break; } case GaussianSmearer::kTheta: { kineProp = fp->P3().Theta(); break; } default: { NUIS_ABORT("Trying to find particle value for a kNoVar."); } } double Smeared; size_t attempt = 0; bool ok = false; while (!ok) { if (sm.type == GaussianSmearer::kFunction) { sm.func->SetParameter(0, kineProp); Smeared = sm.func->GetRandom(); } else { double sThrow = rand.Gaus( 0, sm.width * ((sm.type == GaussianSmearer::kAbsolute) ? 1 : kineProp)); Smeared = kineProp + sThrow; } switch ( sm.smearVar) { // Different kinematics have different truncation. case GaussianSmearer::kMomentum: case GaussianSmearer::kKE: { ok = (Smeared > 0); break; } case GaussianSmearer::kCosTheta: { ok = ((Smeared >= -1) && (Smeared <= 1)); break; } case GaussianSmearer::kTheta: { ok = true; break; } default: { NUIS_ABORT("SHOULDN'T BE HERE."); } } attempt++; if (attempt > 1000) { NUIS_ABORT("Didn't get a good smeared value after " << attempt << " attempts."); } } switch (sm.smearVar) { case GaussianSmearer::kMomentum: { ThreeMom = (ThreeMom.Unit() * Smeared); break; } case GaussianSmearer::kKE: { double mass = fp->P4().M(); double TE = mass + Smeared; double magP = sqrt(TE * TE - mass * mass); ThreeMom = (ThreeMom.Unit() * magP); break; } case GaussianSmearer::kCosTheta: { ThreeMom.SetTheta(acos(Smeared)); break; } case GaussianSmearer::kTheta: { ThreeMom.SetTheta(Smeared); break; } default: {} } } #ifdef DEBUG_GAUSSSMEAR std::cout << " -- momentum reconstructed as Mom: " << ri->RecObjMom.back().Mag() << ", CT: " << ri->RecObjMom.back().CosTheta() << " from " << ThreeMom.Mag() << ", " << fp->P3().CosTheta() << " true." << std::endl; #endif ri->RecObjMom.push_back(ThreeMom); ri->RecObjClass.push_back(fp->PDG()); } else { // Smear to EVis GSmear &sm = VisGausSmears[fp->PDG()]; double kineProp = 0; switch (sm.smearVar) { case GaussianSmearer::kKEVis: { kineProp = fp->KE(); break; } case GaussianSmearer::kTEVis: { kineProp = fp->E(); break; } default: { NUIS_ABORT("Trying to find particle value for a kNoVar."); } } double Smeared; if (sm.type == GaussianSmearer::kFunction) { sm.func->SetParameter(0, kineProp); Smeared = sm.func->GetRandom(); } else { double sThrow = rand.Gaus( 0, sm.width * ((sm.type == GaussianSmearer::kAbsolute) ? 1.0 : kineProp)); Smeared = kineProp + sThrow; } Smeared = (Smeared < 0) ? 0 : Smeared; #ifdef DEBUG_GAUSSSMEAR std::cout << " -- Saw " << Smeared << " visible energy from " << kineProp << " available. [PDG: " << fp->PDG() << "]" << std::endl; #endif ri->RecVisibleEnergy.push_back(Smeared); ri->TrueContribPDGs.push_back(fp->PDG()); } #ifdef DEBUG_GAUSSSMEAR std::cout << std::endl; #endif } RecoInfo *GaussianSmearer::Smearcept(FitEvent *fe) { RecoInfo *ri = new RecoInfo(); for (size_t p_it = 0; p_it < fe->NParticles(); ++p_it) { FitParticle *fp = fe->GetParticle(p_it); SmearceptOneParticle(ri, fp #ifdef DEBUG_GAUSSSMEAR , p_it #endif ); } return ri; } void GaussianSmearer::SmearceptOneParticle(TVector3 &RecObjMom, int RecObjClass) { if (!TrackedGausSmears.count(RecObjClass)) { return; } TVector3 ThreeMom = RecObjMom; TVector3 OriginalKP = ThreeMom; for (size_t sm_it = 0; sm_it < TrackedGausSmears[RecObjClass].size(); ++sm_it) { GSmear &sm = TrackedGausSmears[RecObjClass][sm_it]; double kineProp = 0; switch (sm.smearVar) { case GaussianSmearer::kMomentum: { kineProp = RecObjMom.Mag(); break; } case GaussianSmearer::kKE: { double mass = PhysConst::GetMass(RecObjClass) * 1.0E3; kineProp = sqrt(RecObjMom.Mag2() + mass * mass) - mass; break; } case GaussianSmearer::kCosTheta: { kineProp = OriginalKP.CosTheta(); break; } case GaussianSmearer::kTheta: { kineProp = OriginalKP.Theta(); break; } default: { NUIS_ABORT("Trying to find particle value for a kNoVar."); } } double Smeared; bool ok = false; int attempt = 0; while (!ok) { if (sm.type == GaussianSmearer::kFunction) { sm.func->SetParameter(0, kineProp); Smeared = sm.func->GetRandom(); } else { double sThrow = rand.Gaus( 0, sm.width * ((sm.type == GaussianSmearer::kAbsolute) ? 1.0 : kineProp)); Smeared = kineProp + sThrow; #ifdef DEBUG_GAUSSSMEAR std::cout << "*** [" << attempt << "] Gaus(0," << (sm.width * (sm.type == GaussianSmearer::kAbsolute) ? 1 : kineProp) << "[" << sm.width << "]) = " << sThrow << ": " << kineProp << " -> " << Smeared << std::endl; #endif } switch (sm.smearVar) { // Different kinematics have different truncation. case GaussianSmearer::kMomentum: case GaussianSmearer::kKE: { ok = (Smeared > 0); break; } case GaussianSmearer::kCosTheta: { ok = ((Smeared >= -1) && (Smeared <= 1)); break; } case GaussianSmearer::kTheta: { ok = true; break; } default: { NUIS_ABORT("SHOULDN'T BE HERE."); } } attempt++; if (attempt > 1000) { NUIS_ABORT("Didn't get a good smeared value after " << attempt << " attempts."); } } switch (sm.smearVar) { case GaussianSmearer::kMomentum: { ThreeMom = (ThreeMom.Unit() * Smeared); break; } case GaussianSmearer::kKE: { double mass = PhysConst::GetMass(RecObjClass) * 1.0E3; double TE = mass + Smeared; double magP = sqrt(TE * TE - mass * mass); ThreeMom = (ThreeMom.Unit() * magP); break; } case GaussianSmearer::kCosTheta: { ThreeMom.SetTheta(acos(Smeared)); break; } case GaussianSmearer::kTheta: { ThreeMom.SetTheta(Smeared); break; } default: {} } } RecObjMom = ThreeMom; #ifdef DEBUG_GAUSSSMEAR std::cout << " -- momentum reconstructed as Mom: " << RecObjMom.Mag() << ", CT: " << RecObjMom.CosTheta() << " from " << OriginalKP.Mag() << ", " << OriginalKP.CosTheta() << " true." << std::endl; #endif } void GaussianSmearer::SmearceptOneParticle(double &RecVisibleEnergy, int TrueContribPDG) { if (!VisGausSmears.count(TrueContribPDG)) { return; } GSmear &sm = VisGausSmears[TrueContribPDG]; double kineProp = RecVisibleEnergy; double Smeared; if (sm.type == GaussianSmearer::kFunction) { sm.func->SetParameter(0, kineProp); Smeared = sm.func->GetRandom(); } else { double sThrow = rand.Gaus( 0, sm.width * ((sm.type == GaussianSmearer::kAbsolute) ? 1.0 : kineProp)); Smeared = kineProp + sThrow; } Smeared = (Smeared < 0) ? 0 : Smeared; #ifdef DEBUG_GAUSSSMEAR std::cout << " -- Saw " << Smeared << " visible energy from " << kineProp << " available. [PDG: " << TrueContribPDG << "]" << std::endl; #endif RecVisibleEnergy = Smeared; } void GaussianSmearer::SmearRecoInfo(RecoInfo *ri) { // Smear tracked particles for (size_t p_it = 0; p_it < ri->RecObjMom.size(); ++p_it) { SmearceptOneParticle(ri->RecObjMom[p_it], ri->RecObjClass[p_it]); } for (size_t ve_it = 0; ve_it < ri->RecVisibleEnergy.size(); ++ve_it) { SmearceptOneParticle(ri->RecVisibleEnergy[ve_it], ri->TrueContribPDGs[ve_it]); } #ifdef DEBUG_GAUSSSMEAR std::cout << std::endl; #endif } diff --git a/src/Smearceptance/GaussianSmearer.h b/src/Smearceptance/GaussianSmearer.h index 8add0cf..9f82ae8 100644 --- a/src/Smearceptance/GaussianSmearer.h +++ b/src/Smearceptance/GaussianSmearer.h @@ -1,67 +1,67 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GAUSSIANSMEARER_HXX_SEEN #define GAUSSIANSMEARER_HXX_SEEN #include "ISmearcepter.h" #include // #define DEBUG_GAUSSSMEAR class GaussianSmearer : public ISmearcepter { public: enum GSmearType { kAbsolute, kFractional, kFunction, kNoType }; enum DependVar { kMomentum, kKE, kKEVis, kTEVis, kCosTheta, kTheta, kNoVar }; private: struct GSmear { GSmearType type; DependVar smearVar; double width; TF1 *func; }; std::map > TrackedGausSmears; std::map VisGausSmears; TRandom3 rand; void SpecifcSetup(nuiskey &); public: RecoInfo *Smearcept(FitEvent *); void SmearceptOneParticle(RecoInfo *ri, FitParticle *fp #ifdef DEBUG_GAUSSSMEAR , size_t p_it #endif ); /// Helper method for using this class as a component in a more complex /// smearer void SmearRecoInfo(RecoInfo *); void SmearceptOneParticle(TVector3 &RecObjMom, int RecObjClass); void SmearceptOneParticle(double &RecVisibleEnergy, int TrueContribPDGs); }; #endif diff --git a/src/Smearceptance/Hist2DSlice.cxx b/src/Smearceptance/Hist2DSlice.cxx index f5674de..62005e3 100644 --- a/src/Smearceptance/Hist2DSlice.cxx +++ b/src/Smearceptance/Hist2DSlice.cxx @@ -1,54 +1,54 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "Hist2DSlice.h" Int_t Hist2DSlice::GetNbinsX() { return Bins.size(); } double Hist2DSlice::GetBinContent_Index(size_t i) { return Bins[i].second; } double Hist2DSlice::GetBinNumber_Index(size_t i) { return Bins[i].first; } double Hist2DSlice::GetBinContent_BinNum(Int_t i); double Hist2DSlice::GetMaximum() { return Max; } Hist2DSlice::Hist2DSlice(TH2D const *Hist, Int_t YBinNum) { std::stringstream ss(""); ss << Hist->GetName() << "_yslice_" << YBinNum; Slice = new TH1D(ss.str().c_str(),"",); Slice->SetDirectory(NULL); for (Int_t i = 0; i < (Hist->GetXaxis()->GetNbins() + 2); ++i) { Int_t MatrixBin = Hist->GetBin(i, YBinNum); Float_t cont = Hist->GetBinContent(MatrixBin); if (cont <= 0) { continue; } Bins.push_back(std::make_pair(i, cont)); Max = std::max(Max, Bins.back().second); } NOrigBinsX = Hist->GetXaxis()->GetNbins(); return GetNbinsX(); } Float_t Hist2DSlice::GetBinContent_BinNum(Int_t binnum) { for (size_t i = 0; i < Bins.size(); ++i) { if (Bins[i].first == binnum) { return Bins[i].second; } } return 0; } diff --git a/src/Smearceptance/Hist2DSlice.h b/src/Smearceptance/Hist2DSlice.h index 8a70120..555fe6f 100644 --- a/src/Smearceptance/Hist2DSlice.h +++ b/src/Smearceptance/Hist2DSlice.h @@ -1,43 +1,43 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef HIST2DSLICE_HXX_SEEN #define HIST2DSLICE_HXX_SEEN class Hist2DSlice { TH1D *Slice; bool IsSparse; std::vector > SparseBins; double Max; Int_t NOrigBinsX; Int_t GetNbinsX(); double GetBinContent_Index(size_t i); double GetBinNumber_Index(size_t i); double GetBinContent_BinNum(Int_t i); double GetMaximum(); public: Hist2DSlice(TH2D const *Hist, Int_t YBinNum); Int_t ThrowBin(TRandom3 *); double ThrowXValue(TRandom3 *); }; #endif diff --git a/src/Smearceptance/ISmearcepter.h b/src/Smearceptance/ISmearcepter.h index 0e814c0..df786bb 100644 --- a/src/Smearceptance/ISmearcepter.h +++ b/src/Smearceptance/ISmearcepter.h @@ -1,87 +1,87 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef ISMEARCEPTER_HXX_SEEN #define ISMEARCEPTER_HXX_SEEN #include "FitEvent.h" #include "NuisKey.h" #include "TVector3.h" #include #include /// Base reconstructed information that a smearcepter should fill. /// Smearcepters may allocate and return instances of RecoInfo subclasses. struct RecoInfo { RecoInfo() : RecObjMom(), RecObjClass(), RecVisibleEnergy(0), TrueContribPDGs(), Weight(1){}; /// Reconstructed 3-momentum std::vector RecObjMom; ///\brief 'Class' of a reconstructed object. Might be a PDG particle code, or /// some smearer-defined classification like MIP track/EMShower/... std::vector RecObjClass; /// The visible energy not left by fully reconstructed tracks std::vector RecVisibleEnergy; /// The true pdgs of particles that contributed to the visible energy std::vector TrueContribPDGs; double Weight; }; class ISmearcepter { protected: std::string ElementName; std::string InstanceName; public: void Setup(nuiskey &); virtual void SpecifcSetup(nuiskey &) = 0; std::string GetName() { return InstanceName; } std::string GetElementName() { return ElementName; } virtual RecoInfo *Smearcept(FitEvent *) = 0; /// Helper method for using this class as a component in a more complex /// smearer virtual void SmearRecoInfo(RecoInfo *) { NUIS_ABORT("Smearcepter: " << ElementName << " doesn't implement SmearRecoInfo."); ; } }; template ISmearcepter* BuildSmearcepter(nuiskey& nk) { ISmearcepter* rtn = new T(); rtn->Setup(nk); return rtn; } typedef ISmearcepter* (*SmearceptionFactory_fcn)(nuiskey&); #endif diff --git a/src/Smearceptance/MetaSimpleSmearcepter.cxx b/src/Smearceptance/MetaSimpleSmearcepter.cxx index 8b80334..e242e9f 100644 --- a/src/Smearceptance/MetaSimpleSmearcepter.cxx +++ b/src/Smearceptance/MetaSimpleSmearcepter.cxx @@ -1,74 +1,74 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "EfficiencyApplicator.h" #include "GaussianSmearer.h" #include "ThresholdAccepter.h" #include "TrackedMomentumMatrixSmearer.h" #include "VisECoalescer.h" #include "MetaSimpleSmearcepter.h" void MetaSimpleSmearcepter::SpecifcSetup(nuiskey &nk) { std::map factories; factories["ThresholdAccepter"] = &BuildSmearcepter; factories["EfficiencyApplicator"] = &BuildSmearcepter; factories["GaussianSmearer"] = &BuildSmearcepter; factories["VisECoalescer"] = &BuildSmearcepter; factories["TrackedMomentumMatrixSmearer"] = &BuildSmearcepter; std::vector smearcepters = nk.GetListOfChildNodes(); for (size_t smear_it = 0; smear_it < smearcepters.size(); ++smear_it) { std::string const &smearType = smearcepters[smear_it].GetElementName(); if (smearType == "EnergyShuffler") { ES = new EnergyShuffler(); ES->Setup(smearcepters[smear_it]); continue; } if (!factories.count(smearType)) { NUIS_ERR(WRN, "No known smearer accepts elements named: \"" << smearType << "\""); continue; } Smearcepters.push_back(factories[smearType](smearcepters[smear_it])); NUIS_LOG(FIT, "MetaSimpleSmearcepter adopted child smearcepter: " << Smearcepters.back()->GetName() << " of type: " << Smearcepters.back()->GetElementName()); } NSmearcepters = Smearcepters.size(); } RecoInfo *MetaSimpleSmearcepter::Smearcept(FitEvent *fe) { if (ES) { ES->DoTheShuffle(fe); } RecoInfo *ri = NULL; for (size_t sm_it = 0; sm_it < NSmearcepters; ++sm_it) { if (!sm_it) { ri = Smearcepters[sm_it]->Smearcept(fe); } else { Smearcepters[sm_it]->SmearRecoInfo(ri); } } return ri; } diff --git a/src/Smearceptance/MetaSimpleSmearcepter.h b/src/Smearceptance/MetaSimpleSmearcepter.h index 422800e..3a73fb7 100644 --- a/src/Smearceptance/MetaSimpleSmearcepter.h +++ b/src/Smearceptance/MetaSimpleSmearcepter.h @@ -1,43 +1,43 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef MetaSimpleSmearcepter_HXX_SEEN #define MetaSimpleSmearcepter_HXX_SEEN #include "ISmearcepter.h" #include "EnergyShuffler.h" #include class MetaSimpleSmearcepter : public ISmearcepter { private: size_t NSmearcepters; std::vector Smearcepters; EnergyShuffler *ES; void SpecifcSetup(nuiskey &); public: RecoInfo *Smearcept(FitEvent *); }; #endif diff --git a/src/Smearceptance/SmearceptanceUtils.cxx b/src/Smearceptance/SmearceptanceUtils.cxx index de66d37..ce584d4 100644 --- a/src/Smearceptance/SmearceptanceUtils.cxx +++ b/src/Smearceptance/SmearceptanceUtils.cxx @@ -1,284 +1,284 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "SmearceptanceUtils.h" #include "TDecompSVD.h" #include "FitLogger.h" namespace SmearceptanceUtils { double Smear1DProp(TH2D *mapping, double TrueProp, TRandom3 *rnjesus) { bool myrand = false; if (!rnjesus) { rnjesus = new TRandom3(); myrand = true; } if (myrand) { delete rnjesus; } NUIS_ABORT("NIMPLEMENTED"); return 0; } TVectorD SVDInverseSolve(TVectorD *inp, TMatrixD *mapping) { TDecompSVD svd(*mapping); bool ok; TVectorD c_svd = svd.Solve(*inp, ok); if (!ok) { NUIS_ABORT("Failed to solve SVD matrix equation."); } return c_svd; } TVectorD SVDInverseSolve(TH1D *inp, TMatrixD *mapping) { TVectorD inp_v = GetVector(inp); return SVDInverseSolve(&inp_v, mapping); } TVectorD SVDInverseSolve(TH1D *inp, TH2D *mapping) { TMatrixD mat(mapping->GetXaxis()->GetNbins(), mapping->GetYaxis()->GetNbins()); for (Int_t xb_it = 0; xb_it < mapping->GetXaxis()->GetNbins(); ++xb_it) { for (Int_t yb_it = 0; yb_it < mapping->GetYaxis()->GetNbins(); ++yb_it) { mat[xb_it][yb_it] = mapping->GetBinContent(xb_it + 1, yb_it + 1); } } return SVDInverseSolve(inp, &mat); } TH2D *SVDGetInverse(TH2D *mapping, int NToTruncate) { TMatrixD mat = GetMatrix(mapping); if (mat.GetNcols() > mat.GetNrows()) { NUIS_ABORT("Trying to invert a " << mat.GetNrows() << "x" << mat.GetNcols() << " matrix."); } TH2D *inverse = dynamic_cast(mapping->Clone()); inverse->SetName("inverse"); inverse->Reset(); TDecompSVD svd(mat); svd.Decompose(); if (NToTruncate) { TVectorD Sig(svd.GetSig()); TMatrixD U(svd.GetU()); TMatrixD V(svd.GetV()); if (svd.GetV().TestBit(TMatrixD::kTransposed)) { NUIS_ABORT("ARGHH"); } TMatrixD V_T = V.Transpose(V); TMatrixD Sig_TruncM(U.GetNrows(), V.GetNrows()); for (Int_t i = 0; i < U.GetNrows(); ++i) { for (Int_t j = 0; j < V.GetNrows(); ++j) { Sig_TruncM[i][j] = ((i != j) || (i >= (Sig.GetNrows() - NToTruncate))) ? 0 : Sig[i]; } } TMatrixD Trunc = U * Sig_TruncM * V_T; svd.~TDecompSVD(); new (&svd) TDecompSVD(Trunc); } TMatrixD inv = svd.Invert(); if (fabs(inv[mapping->GetXaxis()->GetNbins() / 2] [mapping->GetXaxis()->GetNbins() / 2] - mat[mapping->GetXaxis()->GetNbins() / 2] [mapping->GetXaxis()->GetNbins() / 2]) < std::numeric_limits::epsilon()) { NUIS_ABORT("Failed to SVD invert matrix."); } for (Int_t xb_it = 0; xb_it < inverse->GetXaxis()->GetNbins(); ++xb_it) { for (Int_t yb_it = 0; yb_it < inverse->GetYaxis()->GetNbins(); ++yb_it) { inverse->SetBinContent(xb_it + 1, yb_it + 1, inv[yb_it][xb_it]); } } return inverse; } void GetSVDDecomp(TH2D *mapping, TVectorD &Sig, TMatrixD &U, TMatrixD &V) { TMatrixD mat = GetMatrix(mapping); TDecompSVD svd(mat); U.ResizeTo(svd.GetU()); U = svd.GetU(); V.ResizeTo(svd.GetV()); V = svd.GetU(); Sig.ResizeTo(svd.GetSig()); Sig = svd.GetSig(); } TVectorD GetVector(TH1D *inp) { TVectorD vec(inp->GetXaxis()->GetNbins()); for (Int_t xb_it = 0; xb_it < inp->GetXaxis()->GetNbins(); ++xb_it) { vec[xb_it] = inp->GetBinContent(xb_it + 1); } return vec; } TVectorD GetErrorVector(TH1D *inp) { TVectorD vec(inp->GetXaxis()->GetNbins()); for (Int_t xb_it = 0; xb_it < inp->GetXaxis()->GetNbins(); ++xb_it) { vec[xb_it] = inp->GetBinError(xb_it + 1); } return vec; } TMatrixD GetMatrix(TH2D *inp) { TMatrixD mat(inp->GetYaxis()->GetNbins(), inp->GetXaxis()->GetNbins()); for (Int_t xb_it = 0; xb_it < inp->GetXaxis()->GetNbins(); ++xb_it) { for (Int_t yb_it = 0; yb_it < inp->GetYaxis()->GetNbins(); ++yb_it) { mat[yb_it][xb_it] = inp->GetBinContent(xb_it + 1, yb_it + 1); } } return mat; } TH1D *GetTH1FromVector(TVectorD const &inp, TH1D *templ) { TH1D *hist; if (templ) { hist = static_cast(templ->Clone()); hist->Reset(); hist->SetName("vectHist"); } else { hist = new TH1D("vectHist", "", inp.GetNrows(), 0, inp.GetNrows()); } hist->SetDirectory(NULL); for (Int_t xb_it = 0; xb_it < inp.GetNrows(); ++xb_it) { hist->SetBinContent(xb_it + 1, inp[xb_it]); } return hist; } TH2D *GetTH2FromMatrix(TMatrixD const &inp, TH2D *templ) { TH2D *hist; if (templ) { hist = static_cast(templ->Clone()); hist->Reset(); hist->SetName("matHist"); } else { hist = new TH2D("matHist", "", inp.GetNcols(), 0, inp.GetNcols(), inp.GetNrows(), 0, inp.GetNrows()); } hist->SetDirectory(NULL); for (Int_t xb_it = 0; xb_it < inp.GetNcols(); ++xb_it) { for (Int_t yb_it = 0; yb_it < inp.GetNrows(); ++yb_it) { hist->SetBinContent(xb_it + 1, yb_it + 1, inp[yb_it][xb_it]); } } return hist; } TVectorD ThrowVectFromHist(TH1D *inp, TRandom3 *rnjesus, bool allowNeg) { TVectorD vec(inp->GetXaxis()->GetNbins()); for (Int_t xb_it = 0; xb_it < inp->GetXaxis()->GetNbins(); ++xb_it) { size_t attempt = 0; do { if (attempt > 1000) { NUIS_ABORT("Looks like we aren't getting anywhere with this bin: " << inp->GetBinContent(xb_it + 1) << " +- " << inp->GetBinError(xb_it + 1)); } vec[xb_it] = inp->GetBinContent(xb_it + 1) + inp->GetBinError(xb_it + 1) * rnjesus->Gaus(); attempt++; } while ((!allowNeg) && (vec[xb_it] < 0)); } return vec; } void PushTH1ThroughMatrixWithErrors(TH1D *inp, TH1D *oup, TMatrixD &response, size_t NToys, bool allowNeg) { TRandom3 rnjesus; oup->Reset(); TVectorD Mean(oup->GetXaxis()->GetNbins()); TVectorD RMS(oup->GetXaxis()->GetNbins()); std::vector Toys; Toys.reserve(NToys); double NToysFact = 1.0 / double(NToys); for (size_t t_it = 0; t_it < NToys; ++t_it) { TVectorD Toy = ThrowVectFromHist(inp, &rnjesus, allowNeg); TVectorD UnfoldToy = response * Toy; for (Int_t bi_it = 0; bi_it < oup->GetXaxis()->GetNbins(); ++bi_it) { Mean[bi_it] += UnfoldToy[bi_it] * NToysFact; } Toys.push_back(UnfoldToy); } for (size_t t_it = 0; t_it < NToys; ++t_it) { for (Int_t bi_it = 0; bi_it < oup->GetXaxis()->GetNbins(); ++bi_it) { RMS[bi_it] += (Mean[bi_it] - Toys[t_it][bi_it]) * (Mean[bi_it] - Toys[t_it][bi_it]) * NToysFact; } } for (Int_t bi_it = 0; bi_it < oup->GetXaxis()->GetNbins(); ++bi_it) { oup->SetBinContent(bi_it + 1, Mean[bi_it]); oup->SetBinError(bi_it + 1, sqrt(RMS[bi_it])); } } TH2D * SwapXYTH2D(TH2D *templ) { TH2D *Swapped = new TH2D( (std::string(templ->GetName()) + "_c").c_str(), "", templ->GetYaxis()->GetNbins(), templ->GetYaxis()->GetXbins()->GetArray(), templ->GetXaxis()->GetNbins(), templ->GetXaxis()->GetXbins()->GetArray()); Swapped->Reset(); Swapped->SetDirectory(NULL); std::string title = ";"; title += templ->GetYaxis()->GetTitle(); title += ";"; title += templ->GetXaxis()->GetTitle(); Swapped->SetTitle(title.c_str()); for (Int_t x_it = 0; x_it < templ->GetXaxis()->GetNbins() + 2; ++x_it) { for (Int_t y_it = 0; y_it < templ->GetYaxis()->GetNbins() + 2; ++y_it) { Swapped->SetBinContent(y_it, x_it, templ->GetBinContent(x_it, y_it)); Swapped->SetBinError(y_it, x_it, templ->GetBinError(x_it, y_it)); } } return Swapped; } } diff --git a/src/Smearceptance/SmearceptanceUtils.h b/src/Smearceptance/SmearceptanceUtils.h index 0f67848..c0eed8c 100644 --- a/src/Smearceptance/SmearceptanceUtils.h +++ b/src/Smearceptance/SmearceptanceUtils.h @@ -1,46 +1,46 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "TH2D.h" #include "TMatrixD.h" #include "TRandom3.h" #include "TVectorD.h" namespace SmearceptanceUtils { double Smear1DProp(TH2D *, double TrueProp, TRandom3 *rand = NULL); TVectorD SVDInverseSolve(TVectorD *inp, TMatrixD *mapping); TVectorD SVDInverseSolve(TH1D *inp, TMatrixD *mapping); TVectorD SVDInverseSolve(TH1D *inp, TH2D *mapping); TH2D *SVDGetInverse(TH2D *mapping, int NToTruncate=0); void GetSVDDecomp(TH2D *mapping, TVectorD &Sig, TMatrixD &U, TMatrixD &V); TVectorD GetVector(TH1D *inp); TVectorD GetErrorVector(TH1D *inp); TMatrixD GetMatrix(TH2D *inp); TH1D *GetTH1FromVector(TVectorD const &inp, TH1D *templ = NULL); TH2D *GetTH2FromMatrix(TMatrixD const &inp, TH2D *templ = NULL); TVectorD ThrowVectFromHist(TH1D *inp, TRandom3 *rnjesus, bool allowNeg); void PushTH1ThroughMatrixWithErrors(TH1D *inp, TH1D *oup, TMatrixD &response, size_t NToys, bool allowNeg); TH2D *SwapXYTH2D(TH2D *templ); } diff --git a/src/Smearceptance/Smearcepterton.cxx b/src/Smearceptance/Smearcepterton.cxx index 36db754..d81210d 100644 --- a/src/Smearceptance/Smearcepterton.cxx +++ b/src/Smearceptance/Smearcepterton.cxx @@ -1,352 +1,352 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "Smearcepterton.h" #include "EfficiencyApplicator.h" #include "GaussianSmearer.h" #include "MetaSimpleSmearcepter.h" #include "ThresholdAccepter.h" #include "TrackedMomentumMatrixSmearer.h" #include "VisECoalescer.h" #include #ifdef __USE_DYNSAMPLES__ #include "TRegexp.h" #include // linux #include DynamicSmearceptorFactory::DynamicSmearceptorFactory() : NSmearceptors(0), NManifests(0) { LoadPlugins(); NUIS_LOG(FIT, "Loaded " << NSmearceptors << " from " << NManifests << " shared object libraries."); } DynamicSmearceptorFactory* DynamicSmearceptorFactory::glblDSF = NULL; DynamicSmearceptorFactory::PluginManifest::~PluginManifest() { for (size_t i_it = 0; i_it < Instances.size(); ++i_it) { (*(DSF_DestroySmearceptor))(Instances[i_it]); } } std::string EnsureTrailingSlash(std::string const& inp) { if (!inp.length()) { return "/"; } if (inp[inp.length() - 1] == '/') { return inp; } return inp + "/"; } void DynamicSmearceptorFactory::LoadPlugins() { std::vector SearchDirectories; if (Config::HasPar("dynamic_smearceptor.path")) { SearchDirectories = GeneralUtils::ParseToStr( Config::GetParS("dynamic_smearceptor.path"), ":"); } char const* envPath = getenv("NUISANCE_DS_PATH"); if (envPath) { std::vector envPaths = GeneralUtils::ParseToStr(envPath, ":"); for (size_t ep_it = 0; ep_it < envPaths.size(); ++ep_it) { SearchDirectories.push_back(envPaths[ep_it]); } } if (!SearchDirectories.size()) { char const* pwdPath = getenv("PWD"); if (pwdPath) { SearchDirectories.push_back(pwdPath); } } for (size_t sp_it = 0; sp_it < SearchDirectories.size(); ++sp_it) { std::string dirpath = EnsureTrailingSlash(SearchDirectories[sp_it]); NUIS_LOG(FIT, "Searching for dynamic smearceptor manifests in: " << dirpath); Ssiz_t len = 0; DIR* dir; struct dirent* ent; dir = opendir(dirpath.c_str()); if (dir != NULL) { TRegexp matchExp("*.so", true); while ((ent = readdir(dir)) != NULL) { if (matchExp.Index(TString(ent->d_name), &len) != Ssiz_t(-1)) { NUIS_LOG(FIT, "\tFound shared object: " << ent->d_name << " checking for relevant methods..."); void* dlobj = dlopen((dirpath + ent->d_name).c_str(), RTLD_NOW | RTLD_GLOBAL); char const* dlerr_cstr = dlerror(); std::string dlerr; if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tDL Load Error: " << dlerr); continue; } PluginManifest plgManif; plgManif.dllib = dlobj; plgManif.soloc = (dirpath + ent->d_name); plgManif.DSF_NSmearceptors = reinterpret_cast( dlsym(dlobj, "DSF_NSmearceptors")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_NSmearceptors\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.DSF_GetSmearceptorName = reinterpret_cast( dlsym(dlobj, "DSF_GetSmearceptorName")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_GetSmearceptorName\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.DSF_GetSmearceptor = reinterpret_cast( dlsym(dlobj, "DSF_GetSmearceptor")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "\tFailed to load symbol \"DSF_GetSmearceptor\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.DSF_DestroySmearceptor = reinterpret_cast( dlsym(dlobj, "DSF_DestroySmearceptor")); dlerr = ""; dlerr_cstr = dlerror(); if (dlerr_cstr) { dlerr = dlerr_cstr; } if (dlerr.length()) { NUIS_ERR(WRN, "Failed to load symbol \"DSF_DestroySmearceptor\" from " << (dirpath + ent->d_name) << ": " << dlerr); dlclose(dlobj); continue; } plgManif.NSmearceptors = (*(plgManif.DSF_NSmearceptors))(); NUIS_LOG(FIT, "\tSuccessfully loaded dynamic smearceptor manifest: " << plgManif.soloc << ". Contains " << plgManif.NSmearceptors << " smearceptors."); for (size_t smp_it = 0; smp_it < plgManif.NSmearceptors; ++smp_it) { char const* smp_name = (*(plgManif.DSF_GetSmearceptorName))(smp_it); if (!smp_name) { NUIS_ABORT("Could not load smearceptor " << smp_it << " / " << plgManif.NSmearceptors << " from " << plgManif.soloc); } if (Smearceptors.count(smp_name)) { NUIS_ERR(WRN, "Already loaded a smearceptor named: \"" << smp_name << "\". cannot load duplciates. This " "smearceptor will be skipped."); continue; } plgManif.SmearceptorsProvided.push_back(smp_name); Smearceptors[smp_name] = std::make_pair(plgManif.soloc, smp_it); NUIS_LOG(FIT, "\t\t" << smp_name); } if (plgManif.SmearceptorsProvided.size()) { Manifests[plgManif.soloc] = plgManif; NSmearceptors += plgManif.SmearceptorsProvided.size(); NManifests++; } else { dlclose(dlobj); } } } closedir(dir); } else { NUIS_ERR(WRN, "Tried to open non-existant directory."); } } } DynamicSmearceptorFactory& DynamicSmearceptorFactory::Get() { if (!glblDSF) { glblDSF = new DynamicSmearceptorFactory(); } return *glblDSF; } void DynamicSmearceptorFactory::Print() { std::map > ManifestSmearceptors; for (std::map >::iterator smp_it = Smearceptors.begin(); smp_it != Smearceptors.end(); ++smp_it) { if (!ManifestSmearceptors.count(smp_it->second.first)) { ManifestSmearceptors[smp_it->second.first] = std::vector(); } ManifestSmearceptors[smp_it->second.first].push_back(smp_it->first); } NUIS_LOG(FIT, "Dynamic smearceptor manifest: "); for (std::map >::iterator m_it = ManifestSmearceptors.begin(); m_it != ManifestSmearceptors.end(); ++m_it) { NUIS_LOG(FIT, "\tLibrary " << m_it->first << " contains: "); for (size_t s_it = 0; s_it < m_it->second.size(); ++s_it) { NUIS_LOG(FIT, "\t\t" << m_it->second[s_it]); } } } bool DynamicSmearceptorFactory::HasSmearceptor(std::string const& name) { return Smearceptors.count(name); } bool DynamicSmearceptorFactory::HasSmearceptor(nuiskey& smearceptorkey) { return HasSmearceptor(smearceptorkey.GetElementName()); } ISmearcepter* DynamicSmearceptorFactory::CreateSmearceptor( nuiskey& smearceptorkey) { if (!HasSmearceptor(smearceptorkey)) { NUIS_ERR(WRN, "Asked to load unknown smearceptor: \"" << smearceptorkey.GetElementName() << "\"."); return NULL; } std::pair smearceptor = Smearceptors[smearceptorkey.GetElementName()]; NUIS_LOG(SAM, "\tLoading smearceptor " << smearceptor.second << " from " << smearceptor.first); ISmearcepter* smear = (*(Manifests[smearceptor.first].DSF_GetSmearceptor))( smearceptor.second, &smearceptorkey); return smear; } DynamicSmearceptorFactory::~DynamicSmearceptorFactory() { Manifests.clear(); } #endif Smearcepterton* Smearcepterton::_inst = NULL; Smearcepterton& Smearcepterton::Get() { if (!_inst) { _inst = new Smearcepterton(); } return *_inst; } Smearcepterton::Smearcepterton() { InitialiserSmearcepters(); } void Smearcepterton::InitialiserSmearcepters() { // hard coded list of tag name -> smearcepter factories, add here to add your // own. std::map factories; factories["ThresholdAccepter"] = &BuildSmearcepter; factories["EfficiencyApplicator"] = &BuildSmearcepter; factories["GaussianSmearer"] = &BuildSmearcepter; factories["TrackedMomentumMatrixSmearer"] = &BuildSmearcepter; factories["VisECoalescer"] = &BuildSmearcepter; factories["MetaSimpleSmearcepter"] = &BuildSmearcepter; Config::Get().PrintXML(NULL); std::vector smearcepterBlocks = Config::QueryKeys("smearcepters"); // std::cout << "[INFO]: " << nodelist.size() << " smearcepter nodes." << std::endl; // for(size_t i = 0; i < nodelist.size(); ++i){ // Config::Get().PrintXML(nodelist[i]); // } for (size_t smearB_it = 0; smearB_it < smearcepterBlocks.size(); ++smearB_it) { std::vector smearcepters = smearcepterBlocks[smearB_it].GetListOfChildNodes(); for (size_t smear_it = 0; smear_it < smearcepters.size(); ++smear_it) { std::string const& smearType = smearcepters[smear_it].GetElementName(); ISmearcepter* smearer = NULL; #ifdef __USE_DYNSAMPLES__ if (DynamicSmearceptorFactory::Get().HasSmearceptor(smearType)) { smearer = DynamicSmearceptorFactory::Get().CreateSmearceptor( smearcepters[smear_it]); } else #endif { if (!factories.count(smearType)) { NUIS_ERR(WRN, "No known smearer accepts elements named: \"" << smearType << "\""); continue; } smearer = factories[smearType](smearcepters[smear_it]); } if (!smearer) { NUIS_ABORT("Failed to load smearceptor."); } if (!smearer->GetName().length()) { NUIS_ABORT("Smearcepter type " << smearer->GetElementName() << " had no instance name."); } Smearcepters[smearer->GetName()] = smearer; NUIS_LOG(FIT, "Configured smearer named: " << smearer->GetName() << " of type: " << smearer->GetElementName()); } } } diff --git a/src/Smearceptance/Smearcepterton.h b/src/Smearceptance/Smearcepterton.h index 1e6c6f6..bec24d6 100644 --- a/src/Smearceptance/Smearcepterton.h +++ b/src/Smearceptance/Smearcepterton.h @@ -1,112 +1,112 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SMEARCEPTERTON_HXX_SEEN #define SMEARCEPTERTON_HXX_SEEN #include "FitLogger.h" #include "ISmearcepter.h" #include #include #ifdef __USE_DYNSAMPLES__ /// Expect each .so containing smearceptors to supply 4 c-style methods. /// int DSF_NSmearceptors(); /// char const * DSF_GetSmearceptorName(int); /// ISmearcepter* DSF_GetSmearceptor(int, nuiskey *); /// void DSF_DestroySmearceptor(ISmearcepter *); class DynamicSmearceptorFactory { size_t NSmearceptors; size_t NManifests; DynamicSmearceptorFactory(); static DynamicSmearceptorFactory* glblDSF; typedef int (*DSF_NSmearceptors_ptr)(void); typedef char const* (*DSF_GetSmearceptorName_ptr)(int); typedef ISmearcepter* (*DSF_GetSmearceptor_ptr)(int, nuiskey *); typedef void (*DSF_DestroySmearceptor_ptr)(ISmearcepter*); struct PluginManifest { void* dllib; DSF_NSmearceptors_ptr DSF_NSmearceptors; DSF_GetSmearceptorName_ptr DSF_GetSmearceptorName; DSF_GetSmearceptor_ptr DSF_GetSmearceptor; DSF_DestroySmearceptor_ptr DSF_DestroySmearceptor; std::string soloc; std::vector Instances; std::vector SmearceptorsProvided; size_t NSmearceptors; ~PluginManifest(); }; std::map Manifests; std::map > Smearceptors; void LoadPlugins(); public: static DynamicSmearceptorFactory& Get(); void Print(); bool HasSmearceptor(std::string const& name); bool HasSmearceptor(nuiskey& smearceptorkey); ISmearcepter* CreateSmearceptor(nuiskey& smearceptorkey); ~DynamicSmearceptorFactory(); }; #endif /// Singleton handling the loading and configuring of known smearcepters. class Smearcepterton { Smearcepterton(); void InitialiserSmearcepters(); static Smearcepterton *_inst; std::map Smearcepters; public: static Smearcepterton &Get(); ISmearcepter &GetSmearcepter(std::string const &name) { if (!Smearcepters.count(name) || !Smearcepters[name]) { NUIS_ERR(FTL, "Known smearcepters:"); for (std::map::iterator sm_it = Smearcepters.begin(); sm_it != Smearcepters.end(); ++sm_it) { NUIS_ERR(FTL, "\t" << sm_it->first); } NUIS_ABORT("No smearcepter named: \"" << name << "\" defined."); } return *Smearcepters[name]; } }; #endif diff --git a/src/Smearceptance/ThresholdAccepter.cxx b/src/Smearceptance/ThresholdAccepter.cxx index f2e8e44..e3d5298 100644 --- a/src/Smearceptance/ThresholdAccepter.cxx +++ b/src/Smearceptance/ThresholdAccepter.cxx @@ -1,330 +1,330 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "ThresholdAccepter.h" namespace { ThresholdAccepter::KineVar GetKineType(nuiskey &nk) { if (nk.Has("RecoThresholdMomentum_MeV")) { return ThresholdAccepter::kMomentum; } else if (nk.Has("RecoThresholdKE_MeV")) { return ThresholdAccepter::kKE; } else if (nk.Has("RecoThresholdCosTheta_Max")) { return ThresholdAccepter::kCosTheta_Max; } else if (nk.Has("RecoThresholdCosTheta_Min")) { return ThresholdAccepter::kCosTheta_Min; } else if (nk.Has("RecoThresholdAbsCosTheta_Max")) { return ThresholdAccepter::kAbsCosTheta_Max; } else if (nk.Has("RecoThresholdAbsCosTheta_Min")) { return ThresholdAccepter::kAbsCosTheta_Min; } else { NUIS_ABORT("Cannot determine the threshold type for Smearcepter element."); } return ThresholdAccepter::kNoVar; } std::string GetKineTypeName(ThresholdAccepter::KineVar kv) { switch (kv) { case ThresholdAccepter::kMomentum: return "Momentum"; case ThresholdAccepter::kKE: return "KE"; case ThresholdAccepter::kCosTheta_Max: return "CosTheta_Max"; case ThresholdAccepter::kCosTheta_Min: return "CosTheta_Min"; case ThresholdAccepter::kAbsCosTheta_Max: return "AbsCosTheta_Max"; case ThresholdAccepter::kAbsCosTheta_Min: return "CosTheta_Min"; default: return "NoVar"; } } double GetKineThreshold(nuiskey &nk, ThresholdAccepter::KineVar kv) { switch (kv) { case ThresholdAccepter::kMomentum: return nk.GetD("RecoThresholdMomentum_MeV"); case ThresholdAccepter::kKE: return nk.GetD("RecoThresholdKE_MeV"); case ThresholdAccepter::kCosTheta_Max: return nk.GetD("RecoThresholdCosTheta_Max"); case ThresholdAccepter::kCosTheta_Min: return nk.GetD("RecoThresholdCosTheta_Min"); case ThresholdAccepter::kAbsCosTheta_Max: return nk.GetD("RecoThresholdAbsCosTheta_Max"); case ThresholdAccepter::kAbsCosTheta_Min: return nk.GetD("RecoThresholdAbsCosTheta_Min"); default: return 0; } } double GetKineVal(FitParticle *fp, ThresholdAccepter::Thresh &rt) { switch (rt.ThresholdType) { case ThresholdAccepter::kMomentum: return fp->P3().Mag(); case ThresholdAccepter::kKE: return fp->KE(); case ThresholdAccepter::kCosTheta_Max: return fp->P3().CosTheta(); case ThresholdAccepter::kCosTheta_Min: return fp->P3().CosTheta(); case ThresholdAccepter::kAbsCosTheta_Max: return fabs(fp->P3().CosTheta()); case ThresholdAccepter::kAbsCosTheta_Min: return fabs(fp->P3().CosTheta()); default: return 0; } } bool PassesThreshold(FitParticle *fp, ThresholdAccepter::Thresh &rt) { switch (rt.ThresholdType) { case ThresholdAccepter::kMomentum: return (fp->P3().Mag() > rt.ThresholdVal); case ThresholdAccepter::kKE: return (fp->KE() > rt.ThresholdVal); case ThresholdAccepter::kCosTheta_Max: return (fp->P3().CosTheta() < rt.ThresholdVal); case ThresholdAccepter::kCosTheta_Min: return (fp->P3().CosTheta() > rt.ThresholdVal); case ThresholdAccepter::kAbsCosTheta_Max: return (fabs(fp->P3().CosTheta()) < rt.ThresholdVal); case ThresholdAccepter::kAbsCosTheta_Min: return (fabs(fp->P3().CosTheta()) > rt.ThresholdVal); default: return 0; } } } /// Reads particle threshold nodes /// /// Nodes look like: /// /// /// /// /// /// /// /// void ThresholdAccepter::SpecifcSetup(nuiskey &nk) { std::vector recoThresholdDescriptors = nk.GetListOfChildNodes("RecoThreshold"); for (size_t t_it = 0; t_it < recoThresholdDescriptors.size(); ++t_it) { std::string pdgs_s = recoThresholdDescriptors[t_it].GetS("PDG"); std::vector pdgs_i = GeneralUtils::ParseToInt(pdgs_s, ","); for (size_t pdg_it = 0; pdg_it < pdgs_i.size(); ++pdg_it) { Thresh t; t.ThresholdType = GetKineType(recoThresholdDescriptors[t_it]); t.ThresholdVal = GetKineThreshold(recoThresholdDescriptors[t_it], t.ThresholdType); ReconThresholds[pdgs_i[pdg_it]].push_back(t); NUIS_LOG(FIT, "Added reconstruction threshold of type: " << ReconThresholds[pdgs_i[pdg_it]].back().ThresholdVal << " " << GetKineTypeName( ReconThresholds[pdgs_i[pdg_it]].back().ThresholdType) << ", for PDG: " << pdgs_i[pdg_it]); } } std::vector visThresholdDescriptors = nk.GetListOfChildNodes("VisThreshold"); for (size_t t_it = 0; t_it < visThresholdDescriptors.size(); ++t_it) { std::string pdgs_s = visThresholdDescriptors[t_it].GetS("PDG"); std::vector pdgs_i = GeneralUtils::ParseToInt(pdgs_s, ","); for (size_t pdg_it = 0; pdg_it < pdgs_i.size(); ++pdg_it) { if (VisThresholds.count(pdgs_i[pdg_it])) { NUIS_ERR(WRN, "Smearceptor " << ElementName << ":" << InstanceName << " already has a threshold for PDG: " << pdgs_i[pdg_it]); } VisThresh vt; vt.UseKE = visThresholdDescriptors[t_it].Has("Contrib") ? (visThresholdDescriptors[t_it].GetS("Contrib") == "K") : false; vt.Fraction = visThresholdDescriptors[t_it].Has("Fraction") ? visThresholdDescriptors[t_it].GetD("Fraction") : 1; if (visThresholdDescriptors[t_it].Has("VisThresholdKE_MeV")) { vt.ThresholdType = ThresholdAccepter::kKE; vt.ThresholdVal = visThresholdDescriptors[t_it].GetD("VisThresholdKE_MeV"); } else if (visThresholdDescriptors[t_it].Has( "VisThresholdMomentum_MeV")) { vt.ThresholdType = ThresholdAccepter::kMomentum; vt.ThresholdVal = visThresholdDescriptors[t_it].GetD("VisThresholdMomentum_MeV"); ; } else { NUIS_ERR(WRN, "Smearceptor " << ElementName << ":" << InstanceName << " cannot find threshold information for PDG: " << pdgs_i[pdg_it]); continue; } VisThresholds[pdgs_i[pdg_it]] = vt; NUIS_LOG(FIT, "Added visibility threshold of MeV " << VisThresholds[pdgs_i[pdg_it]].ThresholdVal << " " << GetKineTypeName(VisThresholds[pdgs_i[pdg_it]].ThresholdType) << ", for PDG: " << pdgs_i[pdg_it] << ". If visible, particle deposits: " << (VisThresholds[pdgs_i[pdg_it]].UseKE ? "KE" : "TE")); } } } void ThresholdAccepter::SmearceptOneParticle(RecoInfo *ri, FitParticle *fp #ifdef DEBUG_THRESACCEPT , size_t p_it #endif ) { #ifdef DEBUG_THRESACCEPT std::cout << std::endl; std::cout << "[" << p_it << " = " << fp << "]: " << fp->PDG() << ", " << fp->Status() << ", " << fp->E() << " -- KE:" << fp->KE() << " Mom: " << fp->P3().Mag() << std::flush; #endif if (fp->Status() != kFinalState) { #ifdef DEBUG_THRESACCEPT std::cout << " -- Not final state." << std::flush; #endif return; } if ((ReconThresholds.count(fp->PDG()) + VisThresholds.count(fp->PDG())) == 0) { #ifdef DEBUG_THRESACCEPT std::cout << " -- Undetectable." << std::flush; #endif return; } // If no reco thresholds it should fall through to EVis bool Passes = ReconThresholds[fp->PDG()].size(); bool FailEnergyThresh = !ReconThresholds[fp->PDG()].size(); for (size_t rt_it = 0; rt_it < ReconThresholds[fp->PDG()].size(); ++rt_it) { bool Passed = PassesThreshold(fp, ReconThresholds[fp->PDG()][rt_it]); if (!Passed) { #ifdef DEBUG_THRESACCEPT std::cout << "\n\t -- Rejected. (" << GetKineTypeName( ReconThresholds[fp->PDG()][rt_it].ThresholdType) << " Threshold: " << ReconThresholds[fp->PDG()][rt_it].ThresholdVal << " | " << GetKineVal(fp, ReconThresholds[fp->PDG()][rt_it]) << ")" << std::flush; #endif if ((ReconThresholds[fp->PDG()][rt_it].ThresholdType == ThresholdAccepter::kMomentum) || (ReconThresholds[fp->PDG()][rt_it].ThresholdType == ThresholdAccepter::kKE)) { FailEnergyThresh = true; } } else { #ifdef DEBUG_THRESACCEPT std::cout << "\n\t -- Accepted. (" << GetKineTypeName( ReconThresholds[fp->PDG()][rt_it].ThresholdType) << " Threshold: " << ReconThresholds[fp->PDG()][rt_it].ThresholdVal << " | " << GetKineVal(fp, ReconThresholds[fp->PDG()][rt_it]) << ")" << std::flush; #endif } Passes = Passes && Passed; } if (Passes) { #ifdef DEBUG_THRESACCEPT std::cout << " -- Reconstructed." << std::flush; #endif ri->RecObjMom.push_back(fp->P3()); ri->RecObjClass.push_back(fp->PDG()); return; } else if (!FailEnergyThresh) { #ifdef DEBUG_THRESACCEPT std::cout << " -- Failed non-Energy threshold, no chance for EVis." << std::flush; #endif return; } if (((VisThresholds[fp->PDG()].ThresholdType == ThresholdAccepter::kKE) && (VisThresholds[fp->PDG()].ThresholdVal < fp->KE())) // Above KE-style threshold || ((VisThresholds[fp->PDG()].ThresholdType == ThresholdAccepter::kMomentum) && (VisThresholds[fp->PDG()].ThresholdVal < fp->P3().Mag())) // Above mom-style threshold ) { #ifdef DEBUG_THRESACCEPT std::cout << " -- Contributed to VisE. (" << GetKineTypeName(VisThresholds[fp->PDG()].ThresholdType) << ": " << VisThresholds[fp->PDG()].ThresholdVal << ")" << std::flush; #endif ri->RecVisibleEnergy.push_back( VisThresholds[fp->PDG()].Fraction * (VisThresholds[fp->PDG()].UseKE ? fp->KE() : fp->E())); ri->TrueContribPDGs.push_back(fp->PDG()); return; } else { #ifdef DEBUG_THRESACCEPT std::cout << " -- Rejected. " << " Vis: (" << GetKineTypeName(VisThresholds[fp->PDG()].ThresholdType) << ": " << VisThresholds[fp->PDG()].ThresholdVal << ")" << std::flush; #endif } } RecoInfo *ThresholdAccepter::Smearcept(FitEvent *fe) { RecoInfo *ri = new RecoInfo(); for (size_t p_it = 0; p_it < fe->NParticles(); ++p_it) { FitParticle *fp = fe->GetParticle(p_it); SmearceptOneParticle(ri, fp #ifdef DEBUG_THRESACCEPT , p_it #endif ); } #ifdef DEBUG_THRESACCEPT std::cout << std::endl; #endif return ri; } diff --git a/src/Smearceptance/ThresholdAccepter.h b/src/Smearceptance/ThresholdAccepter.h index cefc33e..92b580b 100644 --- a/src/Smearceptance/ThresholdAccepter.h +++ b/src/Smearceptance/ThresholdAccepter.h @@ -1,66 +1,66 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef THRESHOLDACCEPTER_HXX_SEEN #define THRESHOLDACCEPTER_HXX_SEEN // #define DEBUG_THRESACCEPT #include "ISmearcepter.h" #include class ThresholdAccepter : public ISmearcepter { public: enum KineVar { kMomentum, kKE, kCosTheta_Max, kCosTheta_Min, kAbsCosTheta_Max, kAbsCosTheta_Min, kNoVar }; struct Thresh { KineVar ThresholdType; double ThresholdVal; }; struct VisThresh : public Thresh { bool UseKE; double Fraction; }; private: std::map > ReconThresholds; std::map VisThresholds; void SpecifcSetup(nuiskey &); public: void SmearceptOneParticle(RecoInfo *ri, FitParticle *fp #ifdef DEBUG_THRESACCEPT , size_t p_it #endif ); RecoInfo *Smearcept(FitEvent *); }; #endif diff --git a/src/Smearceptance/TrackedMomentumMatrixSmearer.cxx b/src/Smearceptance/TrackedMomentumMatrixSmearer.cxx index 7b0993b..bcfda35 100644 --- a/src/Smearceptance/TrackedMomentumMatrixSmearer.cxx +++ b/src/Smearceptance/TrackedMomentumMatrixSmearer.cxx @@ -1,416 +1,416 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "TrackedMomentumMatrixSmearer.h" namespace { TrackedMomentumMatrixSmearer::DependVar GetVarType(std::string const &axisvar) { if (axisvar == "Momentum") { return TrackedMomentumMatrixSmearer::kMomentum; } else if (axisvar == "KE") { return TrackedMomentumMatrixSmearer::kKE; } else if (axisvar == "TE") { return TrackedMomentumMatrixSmearer::kTE; } return TrackedMomentumMatrixSmearer::kNoVar; } } TH1D const *TrackedMomentumMatrixSmearer::SmearMap::GetRecoSlice(double val) { if ((val < RecoSlices.front().first.first) || (val > RecoSlices.back().first.second)) { NUIS_ERR(WRN, "Kinematic property: " << val << ", not within smearable range: [" << RecoSlices.front().first.first << " -- " << RecoSlices.back().first.second << "]."); return NULL; } int L = 0, U = RecoSlices.size(); while (true) { if (U == L) { return RecoSlices[L].second; } int R = (U - L); int m = L + (R / 2); if (val <= RecoSlices[m].first.first) { U = m - 1; continue; } if (val > RecoSlices[m].first.second) { L = m + 1; continue; } if ((val > RecoSlices[m].first.first) && (val <= RecoSlices[m].first.second)) { return RecoSlices[m].second; } NUIS_ABORT("Binary smearing search failed. Check logic."); } } TH1D *GetMapSlice(TH2D *mp, int SliceBin, bool AlongX) { int NBins = (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetNbins(); int NOtherBins = (AlongX ? mp->GetYaxis() : mp->GetXaxis())->GetNbins(); if (SliceBin >= NOtherBins) { NUIS_ABORT("Asked for slice " << SliceBin << " but the " << (AlongX ? 'Y' : 'X') << " axis only has " << NOtherBins); } if ((AlongX ? mp->GetXaxis() : mp->GetYaxis())->IsVariableBinSize() && ((NBins + 1) != (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXbins()->GetSize())) { NUIS_ABORT( "Attemping to take binning slice of variable binning, but NBins+1 != " "NBinEdges: " << (NBins + 1) << " != " << (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXbins()->GetSize()); } std::stringstream ss(""); ss << mp->GetName() << (AlongX ? 'Y' : 'X') << "Slice_" << SliceBin; std::stringstream st(""); st << mp->GetTitle() << ";" << (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetTitle() << ";" << "Count"; TH1D *Ret; if ((AlongX ? mp->GetXaxis() : mp->GetYaxis())->IsVariableBinSize()) { Ret = new TH1D( ss.str().c_str(), st.str().c_str(), NBins, (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXbins()->GetArray()); } else { Ret = new TH1D(ss.str().c_str(), st.str().c_str(), NBins, (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXmin(), (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXmax()); } for (int bi_it = 0; bi_it < NBins + 2; ++bi_it) { int X = AlongX ? bi_it : SliceBin + 1; int Y = AlongX ? SliceBin + 1 : bi_it; int GBin = mp->GetBin(X, Y); Ret->SetBinContent(bi_it, mp->GetBinContent(GBin)); Ret->SetBinError(bi_it, mp->GetBinError(GBin)); } #ifdef DEBUG_MATSMEAR std::cout << "Took slice: " << SliceBin << " spanning [" << Ret->GetXaxis()->GetBinLowEdge(1) << " -- " << Ret->GetXaxis()->GetBinUpEdge(Ret->GetXaxis()->GetNbins()) << "] (Orignal span [" << (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetBinLowEdge(1) << " -- " << (AlongX ? mp->GetXaxis() : mp->GetYaxis()) ->GetBinUpEdge( (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetNbins()) << "]) " << (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXmin() << " -- " << (AlongX ? mp->GetXaxis() : mp->GetYaxis())->GetXmax() << " IsVBin: " << (AlongX ? mp->GetXaxis() : mp->GetYaxis())->IsVariableBinSize() << std::endl; #endif Ret->SetDirectory(NULL); return Ret; } void TrackedMomentumMatrixSmearer::SmearMap::SetSlicesFromMap(TH2D *map, bool TruthIsY) { int NSlices = (TruthIsY ? map->GetYaxis() : map->GetXaxis())->GetNbins(); for (Int_t TrueSlice_it = 0; TrueSlice_it < NSlices; ++TrueSlice_it) { std::pair BinEdges; BinEdges.first = (TruthIsY ? map->GetYaxis() : map->GetXaxis()) ->GetBinLowEdge(TrueSlice_it + 1); BinEdges.second = (TruthIsY ? map->GetYaxis() : map->GetXaxis()) ->GetBinUpEdge(TrueSlice_it + 1); TH1D *slice = GetMapSlice(map, TrueSlice_it, TruthIsY); RecoSlices.push_back(std::make_pair(BinEdges, slice)); } NUIS_LOG(FIT, "\tAdded " << RecoSlices.size() << " reco slices."); } /// Reads particle efficiency nodes /// /// Nodes look like: /// /// /// void TrackedMomentumMatrixSmearer::SpecifcSetup(nuiskey &nk) { std::vector effDescriptors = nk.GetListOfChildNodes("SmearMatrix"); for (size_t t_it = 0; t_it < effDescriptors.size(); ++t_it) { std::string inputFileName = effDescriptors[t_it].GetS("InputFile"); std::string HistName = effDescriptors[t_it].GetS("HistName"); bool YIsTrue = effDescriptors[t_it].Has("YIsTrue") ? effDescriptors[t_it].GetI("YIsTrue") : true; double UnitsScale = effDescriptors[t_it].Has("MatrixToInternal") ? effDescriptors[t_it].GetD("MatrixToInternal") : 1; TFile inputFile(inputFileName.c_str()); if (!inputFile.IsOpen()) { NUIS_ABORT("Couldn't open specified input root file: " << inputFileName); } TH2D *inpHist = dynamic_cast(inputFile.Get(HistName.c_str())); if (!inpHist) { NUIS_ABORT("Couldn't get TH2D named: " << HistName << " from input root file: " << inputFileName); } TrackedMomentumMatrixSmearer::DependVar var = GetVarType(effDescriptors[t_it].GetS("Kinematics")); std::string pdgs_s = effDescriptors[t_it].GetS("PDG"); std::vector pdgs_i = GeneralUtils::ParseToInt(pdgs_s, ","); for (size_t pdg_it = 0; pdg_it < pdgs_i.size(); ++pdg_it) { if (ParticleMappings.count(pdgs_i[pdg_it])) { NUIS_ERR(WRN, "Smearceptor " << ElementName << ":" << InstanceName << " already has a smearing for PDG: " << pdgs_i[pdg_it]); } SmearMap sm; sm.SetSlicesFromMap(inpHist, YIsTrue); sm.SmearVar = var; sm.UnitsScale = UnitsScale; ParticleMappings[pdgs_i[pdg_it]] = sm; NUIS_LOG(FIT, "Added smearing map for PDG: " << pdgs_i[pdg_it]); } } SlaveGS.Setup(nk); } RecoInfo *TrackedMomentumMatrixSmearer::Smearcept(FitEvent *fe) { RecoInfo *ri = new RecoInfo(); for (size_t p_it = 0; p_it < fe->NParticles(); ++p_it) { FitParticle *fp = fe->GetParticle(p_it); #ifdef DEBUG_MATSMEAR std::cout << std::endl; std::cout << "[" << p_it << "]: " << fp->PDG() << ", " << fp->Status() << ", " << fp->E() << " -- KE:" << fp->KE() << " Mom: " << fp->P3().Mag() << std::flush; #endif if (fp->Status() != kFinalState) { #ifdef DEBUG_MATSMEAR std::cout << " -- Not final state." << std::flush; #endif continue; } if (!ParticleMappings.count(fp->PDG())) { SlaveGS.SmearceptOneParticle(ri, fp #ifdef DEBUG_GAUSSSMEAR , p_it #endif ); continue; } SmearMap &sm = ParticleMappings[fp->PDG()]; double kineProp = 0; switch (sm.SmearVar) { case kMomentum: { kineProp = fp->P3().Mag(); break; } case kKE: { kineProp = fp->KE(); break; } case kTE: { kineProp = fp->E(); break; } default: { NUIS_ABORT("Trying to find particle value for a kNoAxis."); } } TH1 const *recoDistrib = sm.GetRecoSlice(kineProp / sm.UnitsScale); #ifdef DEBUG_MATSMEAR std::cout << " -- Got slice spanning [" << recoDistrib->GetXaxis()->GetBinLowEdge(1) << " -- " << recoDistrib->GetXaxis()->GetBinUpEdge( recoDistrib->GetXaxis()->GetNbins()) << "]" << std::endl; #endif if (!recoDistrib) { #ifdef DEBUG_MATSMEAR std::cout << " -- outside smearable range." << std::flush; #endif continue; } if (recoDistrib->Integral() == 0) { NUIS_ERR(WRN, "True slice has no reconstructed events. Not smearing.") continue; } double Smeared = recoDistrib->GetRandom() * sm.UnitsScale; #ifdef DEBUG_MATSMEAR std::cout << "GotRandom: " << Smeared << ", MPV: " << recoDistrib->GetXaxis()->GetBinCenter( recoDistrib->GetMaximumBin()) * sm.UnitsScale << std::endl; #endif switch (sm.SmearVar) { case kMomentum: { ri->RecObjMom.push_back(fp->P3().Unit() * Smeared); #ifdef DEBUG_MATSMEAR std::cout << " -- Smeared: " << fp->p() << " -> " << Smeared << "." << std::flush; #endif break; } case kKE: { double mass = fp->P4().M(); double TE = mass + Smeared; double magP = sqrt(TE * TE - mass * mass); ri->RecObjMom.push_back(fp->P3().Unit() * magP); #ifdef DEBUG_MATSMEAR std::cout << " -- Smeared: " << fp->KE() << " (mass: " << mass << ") -> " << Smeared << ". Smear Mom: " << ri->RecObjMom.back().Mag() << "." << std::flush; #endif break; } case kTE: { double mass = fp->P4().M(); double TE = Smeared; double magP = sqrt(TE * TE - mass * mass); ri->RecObjMom.push_back(fp->P3().Unit() * magP); #ifdef DEBUG_MATSMEAR std::cout << " -- Smeared: " << fp->E() << " (mass: " << mass << ") -> " << Smeared << ". Smear Mom: " << ri->RecObjMom.back().Mag() << "." << std::flush; #endif break; } default: {} } #ifdef DEBUG_MATSMEAR std::cout << " -- momentum reconstructed as " << ri->RecObjMom.back().Mag() << "." << std::endl; #endif if (ri->RecObjMom.back().Mag() != ri->RecObjMom.back().Mag()) { NUIS_ERR(WRN, "Invalid particle built."); ri->RecObjMom.pop_back(); #include "TCanvas.h" TCanvas *Test = new TCanvas("c1", ""); static_cast(recoDistrib->Clone())->Draw(); Test->SaveAs("Fail.png"); delete Test; NUIS_ABORT("ARGH"); } else { ri->RecObjClass.push_back(fp->PDG()); } } #ifdef DEBUG_MATSMEAR std::cout << std::endl; #endif return ri; } void TrackedMomentumMatrixSmearer::SmearRecoInfo(RecoInfo *ri) { for (size_t p_it = 0; p_it < ri->RecObjMom.size(); ++p_it) { if (!ParticleMappings.count(ri->RecObjClass[p_it])) { SlaveGS.SmearceptOneParticle(ri->RecObjMom[p_it], ri->RecObjClass[p_it]); continue; } SmearMap &sm = ParticleMappings[ri->RecObjClass[p_it]]; double kineProp = 0; switch (sm.SmearVar) { case kMomentum: { kineProp = ri->RecObjMom[p_it].Mag(); break; } case kKE: { double mass = PhysConst::GetMass(ri->RecObjClass[p_it]) * 1E3; kineProp = sqrt(ri->RecObjMom[p_it].Mag2() + mass * mass) - mass; break; } case kTE: { double mass = PhysConst::GetMass(ri->RecObjClass[p_it]) * 1E3; kineProp = sqrt(ri->RecObjMom[p_it].Mag2() + mass * mass); break; } default: { NUIS_ABORT("Trying to find particle value for a kNoAxis."); } } TH1 const *recoDistrib = sm.GetRecoSlice(kineProp / sm.UnitsScale); if (!recoDistrib) { continue; } if (recoDistrib->Integral() == 0) { NUIS_ERR(WRN, "True slice has no reconstructed events. Not smearing.") continue; } double Smeared = recoDistrib->GetRandom() * sm.UnitsScale; switch (sm.SmearVar) { case kMomentum: { ri->RecObjMom[p_it] = ri->RecObjMom[p_it].Unit() * Smeared; break; } case kKE: { double mass = PhysConst::GetMass(ri->RecObjClass[p_it]) * 1E3; double TE = mass + Smeared; double magP = sqrt(TE * TE - mass * mass); ri->RecObjMom[p_it] = ri->RecObjMom[p_it].Unit() * magP; break; } case kTE: { double mass = PhysConst::GetMass(ri->RecObjClass[p_it]) * 1E3; double TE = Smeared; double magP = sqrt(TE * TE - mass * mass); ri->RecObjMom[p_it] = ri->RecObjMom[p_it].Unit() * magP; break; } default: {} } } } diff --git a/src/Smearceptance/TrackedMomentumMatrixSmearer.h b/src/Smearceptance/TrackedMomentumMatrixSmearer.h index c84698c..f277e74 100644 --- a/src/Smearceptance/TrackedMomentumMatrixSmearer.h +++ b/src/Smearceptance/TrackedMomentumMatrixSmearer.h @@ -1,72 +1,72 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef TRACKEDMOMENTUMMATRIXSMEARER_HXX_SEEN #define TRACKEDMOMENTUMMATRIXSMEARER_HXX_SEEN #include "ISmearcepter.h" #include "GaussianSmearer.h" #include "TRandom3.h" #include "TH2D.h" #include "TH1D.h" #include #include // #define DEBUG_MATSMEAR class TrackedMomentumMatrixSmearer : public ISmearcepter { public: enum DependVar { kMomentum, kKE, kTE, kNoVar }; private: class SmearMap { /// Input True -> Reco mapping. std::vector, TH1D *> > RecoSlices; public: TH1D const *GetRecoSlice(double val); void SetSlicesFromMap(TH2D *, bool TruthIsY); /// Particle variable to smear: Momentum/KE /// /// In the future should be able to smear multi-kinematic property /// distributions, but requires the definition of axis mappings that I /// cannot be bothered with at this second. TrackedMomentumMatrixSmearer::DependVar SmearVar; double UnitsScale; }; std::map ParticleMappings; GaussianSmearer SlaveGS; void SpecifcSetup(nuiskey &); public: /// Will reject any particle that is not known about. RecoInfo *Smearcept(FitEvent *); /// Helper method for using this class as a component in a more complex /// smearer void SmearRecoInfo(RecoInfo *); ~TrackedMomentumMatrixSmearer(); }; #endif diff --git a/src/Smearceptance/VisECoalescer.h b/src/Smearceptance/VisECoalescer.h index a1a8158..d41a4b7 100644 --- a/src/Smearceptance/VisECoalescer.h +++ b/src/Smearceptance/VisECoalescer.h @@ -1,61 +1,61 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef VISECOALESCER_HXX_SEEN #define VISECOALESCER_HXX_SEEN #include "ISmearcepter.h" #include ///Stacks all VisE deposits from particles of the same PDG class VisECoalescer : public ISmearcepter { private: void SpecifcSetup(nuiskey &) {} public: RecoInfo *Smearcept(FitEvent *) { NUIS_ABORT("VisECoalescer cannot act as an accepter"); } /// Helper method for using this class as a component in a more complex /// smearer void SmearRecoInfo(RecoInfo *ri) { std::map TotalSpeciesVisE; for (size_t ve_it = 0; ve_it < ri->RecVisibleEnergy.size(); ++ve_it) { if (!TotalSpeciesVisE.count(ri->TrueContribPDGs[ve_it])) { TotalSpeciesVisE[ri->TrueContribPDGs[ve_it]] = 0; } TotalSpeciesVisE[ri->TrueContribPDGs[ve_it]] += ri->RecVisibleEnergy[ve_it]; } ri->RecVisibleEnergy.clear(); ri->TrueContribPDGs.clear(); for (std::map::iterator ve_it = TotalSpeciesVisE.begin(); ve_it != TotalSpeciesVisE.end(); ++ve_it) { ri->TrueContribPDGs.push_back(ve_it->first); ri->RecVisibleEnergy.push_back(ve_it->second); } } }; #endif diff --git a/src/Splines/CMakeLists.txt b/src/Splines/CMakeLists.txt index e02dd6a..ff1a257 100644 --- a/src/Splines/CMakeLists.txt +++ b/src/Splines/CMakeLists.txt @@ -1,56 +1,56 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES SplineReader.cxx SplineWriter.cxx SplineMerger.cxx SplineUtils.cxx Spline.cxx ) set(HEADERFILES SplineReader.h SplineWriter.h SplineUtils.h SplineMerger.h Spline.h ) set(LIBNAME Splines) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Splines) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Splines/FitSpline.cxx b/src/Splines/FitSpline.cxx index d141944..288f8d9 100644 --- a/src/Splines/FitSpline.cxx +++ b/src/Splines/FitSpline.cxx @@ -1,411 +1,411 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitSpline.h" // TODO (P.Stowell) ReWrite Spline Classes to be more efficient. Make // inheritance system. // Form etc, //************************************************* FitSpline::FitSpline() { //************************************************* this->id = ""; this->form = ""; this->npar = 0; this->ndim = 0; this->spline = 0; this->offset = 1; this->needs_fit = false; } //************************************************* FitSpline::FitSpline(std::string ident, std::string dist, std::vector list_enums, std::string points_def) { //************************************************* this->id = ident; this->form = dist; this->var_enums = list_enums; // this->x_vals = FitBase::FillScanPoints(points_def); this->npar = 0; this->ndim = 0; this->spline = 0; this->offset = 1; this->points = points_def; // Point DEF is given as TYPEA:1,2,3;TYPEB:1,2,3 // ETC std::vector parsed_points = GeneralUtils::ParseToStr(points_def, ";"); for (UInt_t i = 0; i < parsed_points.size(); i++) { std::string temp = parsed_points.at(i); std::vector split_temp = GeneralUtils::ParseToStr(temp, ":"); std::string choose_type = split_temp.at(0); std::string choose_points = split_temp.at(1); std::vector points_temp = GeneralUtils::ParseToDbl(choose_points, ","); std::vector points_final; if (!choose_type.compare("PNTS")) points_final = points_temp; else if (!choose_type.compare("SCAN")) { NUIS_LOG(FIT, "RUNNING SCAN"); int npoints = int(points_temp[0]); double low = double(points_temp[1]); double high = double(points_temp[2]); NUIS_LOG(FIT, "Npoints " << npoints << " " << low << " " << high); for (int i = 0; i < npoints; i++) { NUIS_LOG(FIT, "Pushing back " << low + (i + 0.) * (high - low) / (npoints - 1.0 + 0.)); points_final.push_back(low + (i + 0.) * (high - low) / (npoints - 1.0 + 0.)); } } this->x.push_back(0.0); this->x_vals.push_back(points_final); this->x_low.push_back(points_final[0]); this->x_high.push_back(points_final[points_final.size() - 1]); } this->SetType(dist); } //************************************************* void FitSpline::ReconfigureSpline(std::vector dial_enums, std::vector dial_values) { //************************************************* for (unsigned int i = 0; i < var_enums.size(); i++) { for (unsigned int j = 0; j < dial_enums.size(); j++) { if (var_enums[i] == dial_enums[j]) { x[i] = dial_values[j]; if (x[i] > x_high[i]) x[i] = x_high[i]; else if (x[i] < x_low[i]) x[i] = x_low[i]; } } } }; //************************************************* double FitSpline::operator()(const Double_t *x, const Double_t *par) const { //************************************************* double weight = this->DoEval(x, par, false); if (weight <= 0.0) weight = 0.0; return weight; }; //************************************************* double FitSpline::DoEval(const double *par) const { //************************************************* double weight = this->DoEval(&x[0], &par[0]); if (weight <= 0.0) weight = 0.0; return weight; }; //************************************************* void FitSpline::SetType(int t, int p, int d, bool f) { //************************************************* spline = t; npar = p; ndim = d; needs_fit = f; } //************************************************* // Adding new spline functions // 1. Add a new value to the enumeration in the header. // 2. Setup a string comparison call here using // SetType( enum, ndim, npar ); // 3. Implement the function evaluation in the DoEval function. //************************************************* void FitSpline::SetType(std::string type) { //************************************************* if (!type.compare("1Dpol1")) { SetType(k1DPol1, 1, 1); } else if (!type.compare("1Dpol2")) { SetType(k1DPol2, 2, 1); } else if (!type.compare("1Dpol3")) { SetType(k1DPol3, 3, 1); } else if (!type.compare("1Dpol4")) { SetType(k1DPol4, 4, 1); } else if (!type.compare("1Dpol5")) { SetType(k1DPol5, 5, 1); } else if (!type.compare("1Dpol6")) { SetType(k1DPol6, 6, 1); } else if (!type.compare("1Dpol1C")) { SetType(k1DPol1C, 2, 1); } else if (!type.compare("1Dpol2C")) { SetType(k1DPol2C, 3, 1); } else if (!type.compare("1Dpol3C")) { SetType(k1DPol3C, 4, 1); } else if (!type.compare("1Dpol4C")) { SetType(k1DPol4C, 5, 1); } else if (!type.compare("1Dpol5C")) { SetType(k1DPol5C, 6, 1); } else if (!type.compare("1Dpol5C_LX")) { SetType(k1DPol5C_LX, 7, 1); } else if (!type.compare("1Dpol10")) { SetType(k1DPol10, 10, 1); } else if (!type.compare("1Dpol25")) { SetType(k1DPol25, 25, 1); } else if (!type.compare("2Dpol6")) { SetType(k2DPol6, 9, 2); } else if (!type.compare("1DTSpline3")) { SetType(k1DTSpline3, x_vals[0].size() * 4, 1, false); } else { NUIS_ABORT("Unkown dial value: " << type); } return; } //************************************************* double FitSpline::DoEval(const double *x, const double *par, const bool use_offset) const { //************************************************* // Fill Vector with limits std::vector y = std::vector(this->ndim, 0); for (UInt_t i = 0; i < ndim; i++) { y[i] = x[i]; if (x[i] < x_low[i]) y[i] = x_low[i]; else if (x[i] > x_high[i]) y[i] = x_high[i]; } // Get Offset in array int off = 0; if (use_offset) off = this->offset; if (par[0 + off] <= -998) { return 1.0; } switch (this->spline) { // N Polynomial sets without constant case (k1DPol1): { NUIS_LOG(DEB, "Calcing pol1 with " << y[0] << " " << par[0 + off]); return (1.0 + par[0 + off] * y[0]); } case (k1DPol2): { return (1.0 + par[0 + off] * y[0] + par[1 + off] * y[0] * y[0]); } case (k1DPol3): { return (1.0 + par[0 + off] * y[0] + par[1 + off] * y[0] * y[0] + par[2 + off] * y[0] * y[0] * y[0]); } case (k1DPol4): { return (1.0 + par[0 + off] * y[0] + par[1 + off] * y[0] * y[0] + par[2 + off] * y[0] * y[0] * y[0] + par[3 + off] * pow(y[0], 4)); } case (k1DPol5): { return (1.0 + par[0 + off] * y[0] + par[1 + off] * y[0] * y[0] + par[2 + off] * y[0] * y[0] * y[0] + par[3 + off] * pow(y[0], 4) + par[4 + off] * pow(y[0], 5)); } case (k1DPol6): { NUIS_LOG(DEB, "Calcing 1Dpol6 with " << y[0]); NUIS_LOG(DEB, "Par 0 " << par[0 + off]); NUIS_LOG(DEB, "Par 1 " << par[1 + off]); NUIS_LOG(DEB, "Par 2 " << par[2 + off]); double val = (1.0 + par[0 + off] * y[0] + par[1 + off] * y[0] * y[0] + par[2 + off] * y[0] * y[0] * y[0] + par[3 + off] * pow(y[0], 4) + par[4 + off] * pow(y[0], 5) + par[5 + off] * pow(y[0], 6)); NUIS_LOG(DEB, "VAL = " << val); return val; } // N Polynomial sets (with constant) case (k1DPol1C): { return (par[0 + off] + par[1 + off] * y[0]); } case (k1DPol2C): { return (par[0 + off] + par[1 + off] * y[0] + par[2 + off] * y[0] * y[0]); } case (k1DPol3C): { return (par[0 + off] + par[1 + off] * y[0] + par[2 + off] * y[0] * y[0] + par[3 + off] * y[0] * y[0] * y[0]); } case (k1DPol4C): { return (par[0 + off] + par[1 + off] * y[0] + par[2 + off] * y[0] * y[0] + par[3 + off] * y[0] * y[0] * y[0] + par[4 + off] * pow(y[0], 4)); } case (k1DPol5C): { return (par[0 + off] + par[1 + off] * y[0] + par[2 + off] * y[0] * y[0] + par[3 + off] * y[0] * y[0] * y[0] + par[4 + off] * pow(y[0], 4) + par[5 + off] * pow(y[0], 5)); } case (k1DPol5C_LX): { return ((par[0 + off] + par[1 + off] * y[0] + par[2 + off] * y[0] * y[0] + par[3 + off] * y[0] * y[0] * y[0] + par[4 + off] * pow(y[0], 4) + par[5 + off] * pow(y[0], 5)) * double(y[0] > par[6 + off] - 4.0)); } case (k1DPol10): { return ((par[0 + off] + par[1 + off] * y[0] + par[2 + off] * y[0] * y[0] + par[3 + off] * y[0] * y[0] * y[0] + par[4 + off] * pow(y[0], 4) + par[5 + off] * pow(y[0], 5) + par[6 + off] * pow(y[0], 6) + par[7 + off] * pow(y[0], 7) + par[8 + off] * pow(y[0], 8) + par[9 + off] * pow(y[0], 9))); } // Silly 25th order polynomial (ROOT can't fit this anyway) case (k1DPol25): { double weight = par[0 + off]; for (UInt_t i = 1; i < npar; i++) { weight += par[i + off] * pow(y[0], i); } return weight; } case (k2DPol6): { double weight = 1.0; return weight; } // TSpline3 --- REQUIRES COEFF BE FILLED into spline3 case (k1DTSpline3): { // iterator over knot values and find width std::vector::iterator iter_low = x_vals[0].begin(); std::vector::iterator iter_high = x_vals[0].begin(); iter_high++; int count = off; while (iter_high != x_vals[0].end()) { if (y[0] >= (*iter_low) and y[0] < (*iter_high)) { break; } count += 4; iter_low++; iter_high++; } double dx = y[0] - (*iter_low); double weight = (par[count] + dx * (par[count + 1] + dx * (par[count + 2] + dx * par[count + 3]))); if (weight != weight) weight = 0.0; return weight; } // DEFAULT OPTION default: NUIS_ABORT("Evaluating function enum not found!"); } }; std::vector FitSpline::GetSplineCoeff(double *weights) { std::vector coeff; switch (this->spline) { // TSPLINE 3 DIAL COEFFICIENT SET ----------------- case (k1DTSpline3): { std::vector xval; std::vector yval; // CREATE TEMP OBJECT TSpline3 temp_spline = TSpline3("temp_spline", &((x_vals[0])[0]), weights, x_vals[0].size()); for (UInt_t i = 0; i < x_vals[0].size(); i++) { /// EXTRA ZERO SUPPRESSION, we must save co-effecients for each point /// scanned to remain consistent across events. (-1) flag is used if (weights[i] <= 0.0 and i < x_vals[0].size() - 1 and weights[i + 1] <= 0.0) { coeff.push_back(0.0); coeff.push_back(0.0); coeff.push_back(0.0); coeff.push_back(0.0); /// Get Normal Coefficients for the point } else { coeff.push_back(weights[i]); double x, y, b, c, d; temp_spline.GetCoeff(i, x, y, b, c, d); coeff.push_back(b); coeff.push_back(c); coeff.push_back(d); } } break; } /// DEFAULT default: NUIS_ERR(FTL, "DIAL HAS NO COEFFICIENT SET Implementation"); NUIS_ABORT("Dial Enum = " << this->spline); } if (coeff.empty()) { NUIS_ABORT("Error no dial coefficients saved from GetDialCoeff()"); } return coeff; } diff --git a/src/Splines/FitSpline.h b/src/Splines/FitSpline.h index 8185ccd..82264af 100644 --- a/src/Splines/FitSpline.h +++ b/src/Splines/FitSpline.h @@ -1,99 +1,99 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FIT_SPLINE_H #define FIT_SPLINE_H #include "TObject.h" #include "PlotUtils.h" #include "FitUtils.h" #include "stdint.h" #include "stdlib.h" #include class FitSpline{ public: // Constructors FitSpline(); ~FitSpline(){}; FitSpline(std::string ident, std::string dist, std::vector list_enums, std::string points_def ); void ReconfigureSpline(std::vector dial_enums, std::vector dial_values); double operator()(const Double_t* x, const Double_t* par) const; double DoEval(const double* par) const; double DoEval(const double* x, const double* par, const bool use_offset=true) const; void SetType(std::string type); void SetType(int t, int p, int d, bool f=true); void SetOffset(int i){ offset = i; }; inline std::string GetIdent(){return id;}; inline std::string GetDist(){return form;}; inline std::string GetPoints(){return points;}; inline std::vector GetEnums(){return var_enums;}; std::vector GetSplineCoeff(double* weights); // Public Access Spline Variables std::vector var_enums; std::vector x; mutable std::vector< std::vector > x_vals; std::vector x_low; std::vector x_high; bool needs_fit; UInt_t offset; UInt_t npar; UInt_t ndim; UInt_t spline; std::string id; std::string form; std::string points; enum spline_types { k1DPol1 = 1, k1DPol2, k1DPol3, k1DPol4, k1DPol5, k1DPol6, k1DPol1C, k1DPol2C, k1DPol3C, k1DPol4C, k1DPol5C, k1DPol5C_LX, k1DPol10, k1DTSpline3, k1DPol25, k2DPol6 }; }; #endif diff --git a/src/Splines/FitSplineHead.cxx b/src/Splines/FitSplineHead.cxx index dd15e6c..d3bdd98 100644 --- a/src/Splines/FitSplineHead.cxx +++ b/src/Splines/FitSplineHead.cxx @@ -1,135 +1,135 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitSplineHead.h" FitSplineHead::FitSplineHead(TFile* infile, std::string name){ current_offset = 1; Read((TTree*) infile->Get(name.c_str())); } double FitSplineHead::CalcWeight(const Double_t* incoeff){ double weight = incoeff[0]; double nom = weight; for (std::list::iterator iter = SplineObjects.begin(); iter != SplineObjects.end(); iter++){ weight *= (*iter)->DoEval(incoeff) * nom; } return weight; }; void FitSplineHead::Reconfigure(std::vector dial_enums, std::vector dial_values){ for (std::list::iterator iter = SplineObjects.begin(); iter != SplineObjects.end(); iter++){ (*iter)->ReconfigureSpline(dial_enums, dial_values); } }; void FitSplineHead::SetupEventWeights(BaseFitEvt* event){ int ncoeff = 1; for (std::list::iterator iter = SplineObjects.begin(); iter != SplineObjects.end(); iter++){ ncoeff += (*iter)->npar; } event->ResetDialCoeff(); event->CreateDialCoeff(ncoeff); } void FitSplineHead::AddSpline(FitSpline* spl){ spl->SetOffset( this->current_offset ); this->SplineObjects.push_back(spl); this->current_offset += spl->npar; } int FitSplineHead::GetCurrentOffset(){ int ncoeff = 1; for (std::list::iterator iter = SplineObjects.begin(); iter != SplineObjects.end(); iter++){ ncoeff += (*iter)->npar; } return ncoeff; } void FitSplineHead::Write(std::string inname){ TTree* headtree = new TTree(inname.c_str(),inname.c_str()); std::string ident = ""; std::string dist = ""; int nenums = 0; int enumlist[1000]; std::string points = ""; headtree->Branch("ident",&ident); headtree->Branch("dist",&dist); headtree->Branch("nenums",&nenums,"nenums/I"); headtree->Branch("enums",&enumlist,"enums[nenums]/I"); headtree->Branch("points",&points); for (std::list::iterator iter = SplineObjects.begin(); iter != SplineObjects.end(); iter++){ FitSpline* spl = (*iter); ident = spl->GetIdent(); dist = spl->GetDist(); points = spl->GetPoints(); std::vector tempenums = spl->GetEnums(); nenums = tempenums.size(); for (int j = 0; j < nenums; j++){ enumlist[j] = tempenums[j]; } headtree->Fill(); } headtree->Write(); } void FitSplineHead::Read(TTree* tn){ std::string* ident = new std::string(); std::string* dist = new std::string(); int nenums = 0; int enumlist[1000]; std::string* points = new std::string(); tn->SetBranchAddress("ident", &ident); tn->SetBranchAddress("dist", &dist); tn->SetBranchAddress("nenums", &nenums); tn->SetBranchAddress("enums", &enumlist); tn->SetBranchAddress("points", &points); for (int i = 0; i < tn->GetEntries(); i++){ tn->GetEntry(i); std::vector enumvect; for (int j = 0; j < nenums; j++){ enumvect.push_back(enumlist[j]); } FitSpline* spl = new FitSpline(*ident, *dist, enumvect, *points); AddSpline(spl); } } diff --git a/src/Splines/FitSplineHead.h b/src/Splines/FitSplineHead.h index ca43c8c..288045b 100644 --- a/src/Splines/FitSplineHead.h +++ b/src/Splines/FitSplineHead.h @@ -1,54 +1,54 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef SPLINES_HEAD_H #define SPLINES_HEAD_H #include "TObject.h" #include "PlotUtils.h" #include "FitUtils.h" #include "stdint.h" #include "stdlib.h" #include "FitSpline.h" #include class FitSplineHead { public: FitSplineHead(){current_offset = 1;}; ~FitSplineHead(){}; // Function Reconf (Given current dial values and names set the values for each function) double CalcWeight(const Double_t* incoeff); void Reconfigure(std::vector dial_enums, std::vector dial_values); void SetupEventWeights(BaseFitEvt* event); void AddSpline(FitSpline* spl); void Write(std::string name="FitSplineHead"); FitSplineHead(TFile* infile, std::string name); void Read(TTree* tn); int GetCurrentOffset(); int ngen_events; // Number of events in the tree these were generated with (needed for scaling) int current_offset; std::list SplineObjects; }; #endif diff --git a/src/Statistical/CMakeLists.txt b/src/Statistical/CMakeLists.txt index 5acd985..1a2c6f0 100644 --- a/src/Statistical/CMakeLists.txt +++ b/src/Statistical/CMakeLists.txt @@ -1,50 +1,50 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(HEADERFILES StatUtils.h ) set(IMPLFILES StatUtils.cxx ) set(LIBNAME Statistical) 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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Statistical) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/Statistical/StatUtils.cxx b/src/Statistical/StatUtils.cxx index 8b57374..5f4914e 100644 --- a/src/Statistical/StatUtils.cxx +++ b/src/Statistical/StatUtils.cxx @@ -1,1621 +1,1698 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "StatUtils.h" #include "GeneralUtils.h" #include "NuisConfig.h" #include "TH1D.h" //******************************************************************* Double_t StatUtils::GetChi2FromDiag(TH1D *data, TH1D *mc, TH1I *mask) { //******************************************************************* Double_t Chi2 = 0.0; TH1D *calc_data = (TH1D *)data->Clone("calc_data"); calc_data->SetDirectory(NULL); TH1D *calc_mc = (TH1D *)mc->Clone("calc_mc"); calc_mc->SetDirectory(NULL); // Add MC Error to data if required if (FitPar::Config().GetParB("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_data->SetDirectory(NULL); calc_mc = ApplyHistogramMasking(mc, mask); calc_mc->SetDirectory(NULL); } // 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 bool made_map = false; if (!map) { map = GenerateMap(data); made_map = true; } // 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; if (made_map) { delete map; } return Chi2; }; //******************************************************************* Double_t StatUtils::GetChi2FromCov(TH1D *data, TH1D *mc, TMatrixDSym *invcov, TH1I *mask, double data_scale, double covar_scale, TH1D *outchi2perbin) { //******************************************************************* static bool first = true; static bool UseSVDDecomp = false; if (first) { UseSVDDecomp = FitPar::Config().GetParB("UseSVDInverse"); first = false; } Double_t Chi2 = 0.0; TMatrixDSym *calc_cov = (TMatrixDSym *)invcov->Clone("local_invcov"); TH1D *calc_data = (TH1D *)data->Clone("local_data"); TH1D *calc_mc = (TH1D *)mc->Clone("local_mc"); calc_data->SetDirectory(NULL); calc_mc->SetDirectory(NULL); // 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); } if (data->GetNbinsX() != invcov->GetNcols()) { NUIS_ERR(WRN, "Inconsistent matrix and data histogram passed to " "StatUtils::GetChi2FromCov!"); NUIS_ABORT("data_hist has " << data->GetNbinsX() << " matrix has " - << invcov->GetNcols() << "bins"); + << invcov->GetNcols() << " bins"); } // Add MC Error to data if required if (FitPar::Config().GetParB("statutils.addmcerror")) { // Make temp cov TMatrixDSym *newcov = StatUtils::GetInvert(calc_cov, true); // Add MC err to diag for (int i = 0; i < calc_data->GetNbinsX(); i++) { double mcerr = calc_mc->GetBinError(i + 1) * sqrt(covar_scale); double oldval = (*newcov)(i, i); NUIS_LOG(FIT, "Adding cov stat " << mcerr * mcerr << " to " << (*newcov)(i, i)); (*newcov)(i, i) = oldval + mcerr * mcerr; } // Reset the calc_cov to new invert delete calc_cov; calc_cov = GetInvert(newcov, true); // Delete the tempcov delete newcov; } calc_data->Scale(data_scale); calc_mc->Scale(data_scale); (*calc_cov) *= covar_scale; // iterate over bins in X (i,j) NUIS_LOG(DEB, "START Chi2 Calculation================="); for (int i = 0; i < calc_data->GetNbinsX(); i++) { double ibin_contrib = 0; NUIS_LOG(DEB, "[CHI2] i = " << i << " [" << calc_data->GetXaxis()->GetBinLowEdge(i + 1) << " -- " << calc_data->GetXaxis()->GetBinUpEdge(i + 1) << "]."); for (int j = 0; j < calc_data->GetNbinsX(); j++) { NUIS_LOG(DEB, "[CHI2]\t j = " << i << " [" << calc_data->GetXaxis()->GetBinLowEdge(j + 1) << " -- " << calc_data->GetXaxis()->GetBinUpEdge(j + 1) << "]."); if (((calc_data->GetBinContent(i + 1) != 0) && (calc_mc->GetBinContent(i + 1) != 0)) && ((*calc_cov)(i, j) != 0)) { NUIS_LOG(DEB, "[CHI2]\t\t Chi2 contribution (i,j) = (" << i << "," << j << ")"); NUIS_LOG(DEB, "[CHI2]\t\t Data - MC(i) = " << calc_data->GetBinContent(i + 1) << " - " << calc_mc->GetBinContent(i + 1) << " = " << (calc_data->GetBinContent(i + 1) - calc_mc->GetBinContent(i + 1))); NUIS_LOG(DEB, "[CHI2]\t\t Data - MC(j) = " << calc_data->GetBinContent(j + 1) << " - " << calc_mc->GetBinContent(j + 1) << " = " << (calc_data->GetBinContent(j + 1) - calc_mc->GetBinContent(j + 1))); NUIS_LOG(DEB, "[CHI2]\t\t Covar = " << (*calc_cov)(i, j)); NUIS_LOG(DEB, "[CHI2]\t\t Cont chi2 = " << ((calc_data->GetBinContent(i + 1) - calc_mc->GetBinContent(i + 1)) * (*calc_cov)(i, j) * (calc_data->GetBinContent(j + 1) - calc_mc->GetBinContent(j + 1))) << " " << Chi2); double bin_cont = ((calc_data->GetBinContent(i + 1) - calc_mc->GetBinContent(i + 1)) * (*calc_cov)(i, j) * (calc_data->GetBinContent(j + 1) - calc_mc->GetBinContent(j + 1))); if (!UseSVDDecomp && (i == j) && ((*calc_cov)(i, j) < 0)) { NUIS_ABORT("Found negative diagonal covariance element: Covar(" << i << ", " << j << ") = " << ((*calc_cov)[i][j]) << ", data = " << calc_data->GetBinContent(i + 1) << ", mc = " << calc_mc->GetBinContent(i + 1) << " would contribute: " << bin_cont << " on top of: " << Chi2); } Chi2 += bin_cont; ibin_contrib += bin_cont; } else { NUIS_LOG(DEB, "Skipping chi2 contribution (i,j) = (" << i << "," << j << "), Data = " << calc_data->GetBinContent(i + 1) << ", MC = " << calc_mc->GetBinContent(i + 1) << ", Cov = " << (*calc_cov)(i, j)); Chi2 += 0.; } } if (outchi2perbin) { outchi2perbin->SetBinContent(i + 1, ibin_contrib); } } // 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, TH2D *outchi2perbin) { //******************************************************************* // Generate a simple map bool made_map = false; if (!map) { map = StatUtils::GenerateMap(data); made_map = true; } // Convert to 1D Histograms TH1D *data_1D = MapToTH1D(data, map); TH1D *mc_1D = MapToTH1D(mc, map); TH1I *mask_1D = MapToMask(mask, map); TH1D *outchi2perbin_1D = outchi2perbin ? MapToTH1D(outchi2perbin, map) : NULL; NUIS_LOG(DEB, "Calculating 2D covariance: got map ? " << (!made_map) << ", Ndata bins: " << (data->GetNbinsX() * data->GetNbinsY()) << ", ncovbins: " << invcov->GetNcols() << ", mapped 1D hist NBins: " << data_1D->GetNbinsX()); // Calculate 1D chi2 from 1D Plots Double_t Chi2 = StatUtils::GetChi2FromCov(data_1D, mc_1D, invcov, mask_1D, 1, 1E76, outchi2perbin_1D); if (outchi2perbin && outchi2perbin_1D) { MapFromTH1D(outchi2perbin, outchi2perbin_1D, map); } // CleanUp delete data_1D; delete mc_1D; delete mask_1D; delete outchi2perbin_1D; if (made_map) { delete map; } 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 bool made_map = false; if (!map) { made_map = true; 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; if (made_map) { delete map; } 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 (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))); } /* LOG(REC)<<"Evt Chi2 cont = "<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; bool made_map = false; if (!map) { made_map = true; 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++; } } if (made_map) { delete map; } 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 rand_val; TMatrixDSym *decomp_cov = NULL; 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)) { NUIS_LOG(DEB, "Applying mask to bin " << i + 1 << " " << hist->GetName()); 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) { //******************************************************************* bool made_map = false; if (!map) { made_map = true; map = StatUtils::GenerateMap(data); } TH1I *mask_1D = StatUtils::MapToMask(mask, map); TMatrixDSym *newmat = StatUtils::ApplyMatrixMasking(mat, mask_1D); if (made_map) { delete map; } delete mask_1D; return newmat; } //******************************************************************* TMatrixDSym *StatUtils::ApplyInvertedMatrixMasking(TMatrixDSym *mat, TH1I *mask) { //******************************************************************* //TMatrixDSym *new_mat = GetInvert(mat, true); // Don't rescale the inverted matrix which multiplies the mask! TMatrixDSym *new_mat = GetInvert(mat); TMatrixDSym *masked_mat = ApplyMatrixMasking(new_mat, mask); TMatrixDSym *inverted_mat = GetInvert(masked_mat, true); delete masked_mat; delete new_mat; return inverted_mat; }; //******************************************************************* TMatrixDSym *StatUtils::ApplyInvertedMatrixMasking(TMatrixDSym *mat, TH2D *data, TH2I *mask, TH2I *map) { //******************************************************************* bool made_map = false; if (!map) { made_map = true; map = StatUtils::GenerateMap(data); } TH1I *mask_1D = StatUtils::MapToMask(mask, map); TMatrixDSym *newmat = ApplyInvertedMatrixMasking(mat, mask_1D); if (made_map) { delete map; } delete mask_1D; return newmat; } +// Check whether this matrix can be inverted +bool StatUtils::IsMatrixWellBehaved(TMatrixDSym* mat) { + + bool wellBehaved = true; + StopTalking(); + TDecompChol mat_decomp(*mat); + + double d1, d2; + mat_decomp.Det(d1, d2); + + // Check if the matrix is singular + if (d1*TMath::Power(2.,d2) < mat_decomp.GetTol()){ + wellBehaved = false; + } + // Check if the matrix can be decomposed + // Oddly, there are fringe cases which pass one of these conditions + // But if either fail, the inversion won't work + if (!mat_decomp.Decompose()) { + wellBehaved = false; + } + + StartTalking(); + return wellBehaved; +} + //******************************************************************* // bool rescale rescales the matrix when using Cholesky decomp to ensure good decomposition TMatrixDSym *StatUtils::GetInvert(TMatrixDSym *mat, bool rescale) { //******************************************************************* 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; } static bool first = true; static bool UseSVDDecomp = false; if (first) { UseSVDDecomp = FitPar::Config().GetParB("UseSVDInverse"); first = false; + if (UseSVDDecomp){ + NUIS_ERR(WRN, "Allowing SVD inverse if matrices are singular, use with extreme caution!"); + } } - if (UseSVDDecomp) { - // Invert full matrix - TDecompSVD mat_decomp(*new_mat); - if (!mat_decomp.Decompose()) { - NUIS_ABORT("Decomposition failed, matrix singular ?"); - } else { - int nrows = new_mat->GetNrows(); - delete new_mat; - new_mat = - new TMatrixDSym(nrows, mat_decomp.Invert().GetMatrixArray(), ""); - } + // Check if this matrix is singular/positive-definite + bool isWellBehaved = StatUtils::IsMatrixWellBehaved(new_mat); - // Use Cholesky decomp - } else { + // If the matrix isn't singular, use Cholesky + if (isWellBehaved) { // Check the entries of the Matrix and scale it to be within range double scaling = 1; if (rescale) { double smallest = 999; for (int i = 0; i < new_mat->GetNrows(); ++i) { for (int j = 0; j < new_mat->GetNcols(); ++j) { if (fabs((*new_mat)(i,j)) < smallest && (*new_mat)(i,j) != 0) smallest = fabs((*new_mat)(i,j)); } } // Now scale the matrix so the smallest entry is 1e-5 scaling = smallest; (*new_mat) *= 1./scaling; } - + // Invert full matrix - TDecompChol mat_decomp(*new_mat); - if (!mat_decomp.Decompose()) { - NUIS_ERR(FTL, "Decomposition failed, matrix singular ?"); - NUIS_ABORT("If you want to use SVD decomposition set in your card file."); - } else { - int nrows = new_mat->GetNrows(); - delete new_mat; - new_mat = - new TMatrixDSym(nrows, mat_decomp.Invert().GetMatrixArray(), ""); + if (!StatUtils::IsMatrixWellBehaved(new_mat)){ + NUIS_ERR(WRN, "Problem with rescaled matrix"); } + TDecompChol mat_decomp(*new_mat); + int nrows = new_mat->GetNrows(); + delete new_mat; + new_mat = + new TMatrixDSym(nrows, mat_decomp.Invert().GetMatrixArray(), ""); + // then scale the matrix back if (rescale) { (*new_mat) *= 1./scaling; } + } else { + + // if Matrix singular, but UseSVDDecomp not set, abort + if (!UseSVDDecomp){ + NUIS_ERR(FTL, "Cannot invert covariance, giving up"); + NUIS_ABORT("If you want to force matters using SVD decomposition set in your card file."); + } + + // Do the SVD decomp + TDecompSVD mat_decomp(*new_mat); + if (!mat_decomp.Decompose()) { + NUIS_ABORT("SVD decomposition failed, something strange has happened"); + } + + int nrows = new_mat->GetNrows(); + delete new_mat; + new_mat = + new TMatrixDSym(nrows, mat_decomp.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; } + // Test if we can decompose the matrix before trying + bool isWellBehaved = StatUtils::IsMatrixWellBehaved(new_mat); + + if (!isWellBehaved) { + NUIS_ERR(WRN, "Cannot decompose the covariance matrix"); + + // This is dumb, but just flip the diagonals and remove everything else + for (int i = 0; i < nrows; ++i){ + for(int j = 0; j 0.0) + (*new_mat)(i, j) = sqrt((*new_mat)(i, j)); + else + (*new_mat)(i, j) = 0.0; + } + } + } + return new_mat; + } + + // Okay, try to decompose... 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) { //******************************************************************* bool made_map = false; if (!map) { made_map = true; map = StatUtils::GenerateMap(data); } TH1D *data_1D = MapToTH1D(data, map); StatUtils::ForceNormIntoCovar(mat, data_1D, norm); delete data_1D; if (made_map) { delete map; } 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) { //******************************************************************* bool made_map = false; if (!map) { made_map = true; map = StatUtils::GenerateMap(data); } TH1D *data_1D = MapToTH1D(data, map); if (made_map) { delete map; } return StatUtils::MakeDiagonalCovarMatrix(data_1D, scaleF); }; //******************************************************************* void StatUtils::SetDataErrorFromCov(TH1D *DataHist, TMatrixDSym *cov, double scale, bool ErrorCheck) { //******************************************************************* // Check if (ErrorCheck) { if (cov->GetNrows() != DataHist->GetNbinsX()) { NUIS_ERR( FTL, "Nrows in cov don't match nbins in DataHist for SetDataErrorFromCov"); NUIS_ERR(FTL, "Nrows = " << cov->GetNrows()); NUIS_ABORT("Nbins = " << DataHist->GetNbinsX()); } } // Set bin errors form cov diag // Check if the errors are set bool ErrorsSet = false; for (int i = 0; i < DataHist->GetNbinsX(); i++) { if (ErrorsSet == true) break; if (DataHist->GetBinError(i + 1) != 0 && DataHist->GetBinContent(i + 1) > 0) ErrorsSet = true; } // Now loop over if (ErrorsSet && ErrorCheck) { for (int i = 0; i < DataHist->GetNbinsX(); i++) { double DataHisterr = DataHist->GetBinError(i + 1); double coverr = sqrt((*cov)(i, i)) * scale; // Check that the errors are within 1% of eachother if (fabs(DataHisterr - coverr) / DataHisterr > 0.01) { NUIS_ERR(WRN, "Data error does not match covariance error for bin " << i + 1 << " (" << DataHist->GetXaxis()->GetBinLowEdge(i + 1) << "-" << DataHist->GetXaxis()->GetBinLowEdge(i + 2) << ")"); NUIS_ERR(WRN, "Data error: " << DataHisterr); NUIS_ERR(WRN, "Cov error: " << coverr); } } // Else blindly trust the covariance } else { for (int i = 0; i < DataHist->GetNbinsX(); i++) { DataHist->SetBinError(i + 1, sqrt((*cov)(i, i)) * scale); } } return; } //******************************************************************* void StatUtils::SetDataErrorFromCov(TH2D *data, TMatrixDSym *cov, TH2I *map, double scale, bool ErrorCheck) { //******************************************************************* // Check if (ErrorCheck) { if (cov->GetNrows() != data->GetNbinsX() * data->GetNbinsY()) { NUIS_ERR(FTL, "Nrows in cov don't match nbins in data for " "SetDataNUIS_ERRorFromCov"); NUIS_ERR(FTL, "Nrows = " << cov->GetNrows()); NUIS_ABORT("Nbins = " << data->GetNbinsX()); } } // Set bin errors form cov diag // Check if the errors are set bool ErrorsSet = false; for (int i = 0; i < data->GetNbinsX(); i++) { for (int j = 0; j < data->GetNbinsX(); j++) { if (ErrorsSet == true) break; if (data->GetBinError(i + 1, j + 1) != 0) ErrorsSet = true; } } // Create map if required bool made_map = false; if (!map) { made_map = true; 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; // If we have errors on our histogram the map is good count = map->GetBinContent(i + 1, j + 1) - 1; double dataerr = data->GetBinError(i + 1, j + 1); double coverr = sqrt((*cov)(count, count)) * scale; // Check that the errors are within 1% of eachother if (ErrorsSet && ErrorCheck) { if (fabs(dataerr - coverr) / dataerr > 0.01) { NUIS_ERR(WRN, "Data error does not match covariance error for bin " << i + 1 << " (" << data->GetXaxis()->GetBinLowEdge(i + 1) << "-" << data->GetXaxis()->GetBinLowEdge(i + 2) << ")"); NUIS_ERR(WRN, "Data error: " << dataerr); NUIS_ERR(WRN, "Cov error: " << coverr); } } else { data->SetBinError(i + 1, j + 1, sqrt((*cov)(count, count)) * scale); } } } if (made_map) { delete map; } } TMatrixDSym *StatUtils::ExtractShapeOnlyCovar(TMatrixDSym *full_covar, TH1D *data_hist, double data_scale) { int nbins = full_covar->GetNrows(); TMatrixDSym *shape_covar = new TMatrixDSym(nbins); // Check nobody is being silly if (data_hist->GetNbinsX() != nbins) { NUIS_ERR(WRN, "Inconsistent matrix and data histogram passed to " "StatUtils::ExtractShapeOnlyCovar!"); NUIS_ABORT("data_hist has " << data_hist->GetNbinsX() << " matrix has " << nbins << "bins"); int err_bins = data_hist->GetNbinsX(); if (nbins > err_bins) err_bins = nbins; for (int i = 0; i < err_bins; ++i) { NUIS_ERR(WRN, "Matrix diag. = " << (*full_covar)(i, i) << " data = " << data_hist->GetBinContent(i + 1)); } return NULL; } double total_data = 0; double total_covar = 0; // Initial loop to calculate some constants for (int i = 0; i < nbins; ++i) { total_data += data_hist->GetBinContent(i + 1) * data_scale; for (int j = 0; j < nbins; ++j) { total_covar += (*full_covar)(i, j); } } if (total_data == 0 || total_covar == 0) { NUIS_ERR(WRN, "Stupid matrix or data histogram passed to " "StatUtils::ExtractShapeOnlyCovar! Ignoring..."); return NULL; } - NUIS_LOG(SAM, "Norm error = " << sqrt(total_covar) / total_data); + NUIS_LOG(DEB, "Norm error = " << sqrt(total_covar) / total_data); // Now loop over and calculate the shape-only matrix for (int i = 0; i < nbins; ++i) { double data_i = data_hist->GetBinContent(i + 1) * data_scale; for (int j = 0; j < nbins; ++j) { double data_j = data_hist->GetBinContent(j + 1) * data_scale; double norm_term = data_i * data_j * total_covar / total_data / total_data; double mix_sum1 = 0; double mix_sum2 = 0; for (int k = 0; k < nbins; ++k) { mix_sum1 += (*full_covar)(k, j); mix_sum2 += (*full_covar)(i, k); } double mix_term1 = data_i * (mix_sum1 / total_data - total_covar * data_j / total_data / total_data); double mix_term2 = data_j * (mix_sum2 / total_data - total_covar * data_i / total_data / total_data); (*shape_covar)(i, j) = (*full_covar)(i, j) - mix_term1 - mix_term2 - norm_term; } } return shape_covar; } TMatrixDSym *StatUtils::ExtractShapeOnlyCovar(TMatrixDSym *full_covar, TH2D *data_hist, TH2I *map, double data_scale) { // Generate a simple map bool made_map = false; if (!map) { map = StatUtils::GenerateMap(data_hist); made_map = true; } // Convert to 1D Histograms TH1D *data_1D = MapToTH1D(data_hist, map); // Calculate from 1D TMatrixDSym *rtn = StatUtils::ExtractShapeOnlyCovar(full_covar, data_1D, data_scale); delete data_1D; if (made_map) { delete map; } return rtn; } //******************************************************************* 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) { 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; + // Check how many bins are omitted from the map + int nskip = 0; + for (int i = 0; i < map->GetNbinsX(); i++) { + for (int j = 0; j < map->GetNbinsY(); j++) { + if (map->GetBinContent(i + 1, j + 1) <= 0) + nskip++; + } + } + // Get N bins for 1D plot - Int_t Nbins = map->GetXaxis()->GetNbins()*map->GetYaxis()->GetNbins(); + Int_t Nbins = map->GetXaxis()->GetNbins()*map->GetYaxis()->GetNbins() - nskip; 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); + newhist->GetYaxis()->SetTitle(hist->GetZaxis()->GetTitle()); + newhist->GetXaxis()->SetTitle(Form("%s-%s",hist->GetXaxis()->GetTitle(),hist->GetYaxis()->GetTitle())); // 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) + 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 newhist; } void StatUtils::MapFromTH1D(TH2 *fillhist, TH1 *fromhist, TH2I *map) { fillhist->Reset(); for (int i = 0; i < map->GetNbinsX(); i++) { for (int j = 0; j < map->GetNbinsY(); j++) { - if (map->GetBinContent(i + 1, j + 1) == 0) + if (map->GetBinContent(i + 1, j + 1) <= 0) continue; int gb = map->GetBinContent(i + 1, j + 1); fillhist->SetBinContent(i + 1, j + 1, fromhist->GetBinContent(gb)); fillhist->SetBinError(i + 1, j + 1, fromhist->GetBinError(gb)); } } } //******************************************************************* TH1I *StatUtils::MapToMask(TH2I *hist, TH2I *map) { //******************************************************************* TH1I *newhist = NULL; if (!hist) return newhist; + // Check how many bins are omitted from the map + int nskip = 0; + for (int i = 0; i < map->GetNbinsX(); i++) { + for (int j = 0; j < map->GetNbinsY(); j++) { + if (map->GetBinContent(i + 1, j + 1) <= 0) + nskip++; + } + } + // Get N bins for 1D plot - Int_t Nbins = map->GetXaxis()->GetNbins()*map->GetYaxis()->GetNbins(); + Int_t Nbins = map->GetXaxis()->GetNbins()*map->GetYaxis()->GetNbins()-nskip; 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) + if (map->GetBinContent(i + 1, j + 1) <= 0) continue; newhist->SetBinContent(map->GetBinContent(i + 1, j + 1), hist->GetBinContent(i + 1, j + 1)); } } 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; } //******************************************************************* TMatrixD *StatUtils::GetMatrixFromTextFile(std::string covfile, int dimx, int dimy) { //******************************************************************* // Determine dim if (dimx == -1 and dimy == -1) { std::string line; std::ifstream covar(covfile.c_str(), std::ifstream::in); int row = 0; while (std::getline(covar >> std::ws, line, '\n')) { int column = 0; std::vector entries = GeneralUtils::ParseToDbl(line, " "); if (entries.size() <= 1) { NUIS_ERR(WRN, "StatUtils::GetMatrixFromTextFile, matrix only has <= 1 " "entries on this line: " << row); } for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { column++; if (column > dimx) dimx = column; } row++; if (row > dimy) dimy = row; } } // Or assume symmetric if (dimx != -1 and dimy == -1) { dimy = dimx; } assert(dimy != -1 && " matrix dimy not set."); // Make new matrix TMatrixD *mat = new TMatrixD(dimx, dimy); std::string line; std::ifstream covar(covfile.c_str(), std::ifstream::in); int row = 0; while (std::getline(covar >> std::ws, line, '\n')) { int column = 0; std::vector entries = GeneralUtils::ParseToDbl(line, " "); if (entries.size() <= 1) { NUIS_ERR(WRN, "StatUtils::GetMatrixFromTextFile, matrix only has <= 1 " "entries on this line: " << row); } for (std::vector::iterator iter = entries.begin(); iter != entries.end(); iter++) { // Check Rows // assert(row > mat->GetNrows() && " covar rows doesn't match matrix // rows."); // assert(column > mat->GetNcols() && " covar cols doesn't match matrix // cols."); // Fill Matrix (*mat)(row, column) = (*iter); column++; } row++; } return mat; } //******************************************************************* TMatrixD *StatUtils::GetMatrixFromRootFile(std::string covfile, std::string histname) { //******************************************************************* std::string inputfile = covfile + ";" + histname; std::vector splitfile = GeneralUtils::ParseToStr(inputfile, ";"); if (splitfile.size() < 2) { NUIS_ABORT("No object name given!"); } // Get file TFile *tempfile = new TFile(splitfile[0].c_str(), "READ"); // Get Object + StopTalking(); TObject *obj = tempfile->Get(splitfile[1].c_str()); + StartTalking(); if (!obj) { NUIS_ABORT("Object " << splitfile[1] << " doesn't exist!"); } // Try casting TMatrixD *mat = dynamic_cast(obj); if (mat) { TMatrixD *newmat = (TMatrixD *)mat->Clone(); delete mat; tempfile->Close(); return newmat; } TMatrixDSym *matsym = dynamic_cast(obj); if (matsym) { TMatrixD *newmat = new TMatrixD(matsym->GetNrows(), matsym->GetNrows()); for (int i = 0; i < matsym->GetNrows(); i++) { for (int j = 0; j < matsym->GetNrows(); j++) { (*newmat)(i, j) = (*matsym)(i, j); } } delete matsym; tempfile->Close(); return newmat; } TH2D *mathist = dynamic_cast(obj); if (mathist) { TMatrixD *newmat = new TMatrixD(mathist->GetNbinsX(), mathist->GetNbinsX()); for (int i = 0; i < mathist->GetNbinsX(); i++) { for (int j = 0; j < mathist->GetNbinsX(); j++) { (*newmat)(i, j) = mathist->GetBinContent(i + 1, j + 1); } } delete mathist; tempfile->Close(); return newmat; } return NULL; } //******************************************************************* TMatrixDSym *StatUtils::GetCovarFromTextFile(std::string covfile, int dim) { //******************************************************************* // Delete TempMat TMatrixD *tempmat = GetMatrixFromTextFile(covfile, dim, dim); // Make a symmetric covariance TMatrixDSym *newmat = new TMatrixDSym(tempmat->GetNrows()); for (int i = 0; i < tempmat->GetNrows(); i++) { for (int j = 0; j < tempmat->GetNrows(); j++) { (*newmat)(i, j) = (*tempmat)(i, j); } } delete tempmat; return newmat; } //******************************************************************* TMatrixDSym *StatUtils::GetCovarFromRootFile(std::string covfile, std::string histname) { //******************************************************************* TMatrixD *tempmat = GetMatrixFromRootFile(covfile, histname); TMatrixDSym *newmat = new TMatrixDSym(tempmat->GetNrows()); for (int i = 0; i < tempmat->GetNrows(); i++) { for (int j = 0; j < tempmat->GetNrows(); j++) { (*newmat)(i, j) = (*tempmat)(i, j); } } delete tempmat; return newmat; } diff --git a/src/Statistical/StatUtils.h b/src/Statistical/StatUtils.h index 485beae..fdf7bd9 100644 --- a/src/Statistical/StatUtils.h +++ b/src/Statistical/StatUtils.h @@ -1,294 +1,297 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef STATUTILS_H #define STATUTILS_H // C Includes #include "assert.h" #include #include #include #include #include #include #include #include // Root Includes #include "TDecompChol.h" #include "TDecompSVD.h" #include "TFile.h" #include "TGraphErrors.h" #include "TH1D.h" #include "TH2D.h" #include "TH2I.h" #include "TMath.h" #include "TMatrixDSym.h" #include "TRandom3.h" // Fit Includes #include "FitLogger.h" /*! * \addtogroup Utils * @{ */ //! Functions for handling statistics calculations namespace StatUtils { /* Chi2 Functions */ //! Get Chi2 using diagonal bin errors from the histogram. Masking applied //! before calculation if mask provided. Double_t GetChi2FromDiag(TH1D *data, TH1D *mc, TH1I *mask = NULL); //! Get Chi2 using diagonal bin errors from the histogram. //! Plots converted to 1D histograms before using 1D calculation. Double_t GetChi2FromDiag(TH2D *data, TH2D *mc, TH2I *map = NULL, TH2I *mask = NULL); //! Get Chi2 using an inverted covariance for the data Double_t GetChi2FromCov(TH1D *data, TH1D *mc, TMatrixDSym *invcov, TH1I *mask = NULL, double data_scale = 1, double covar_scale = 1E76, TH1D *outchi2perbin = NULL); //! Get Chi2 using an inverted covariance for the data //! Plots converted to 1D histograms before using 1D calculation. Double_t GetChi2FromCov(TH2D *data, TH2D *mc, TMatrixDSym *invcov, TH2I *map = NULL, TH2I *mask = NULL, TH2D *outchi2perbin = NULL); //! Get Chi2 using an SVD method on the covariance before calculation. //! Method suggested by Rex at MiniBooNE. Shown that it doesn't actually work. Double_t GetChi2FromSVD(TH1D *data, TH1D *mc, TMatrixDSym *cov, TH1I *mask = NULL); //! Get Chi2 using an SVD method on the covariance before calculation. //! Method suggested by Rex at MiniBooNE. Shown that it doesn't actually work. //! Plots converted to 1D histograms before using 1D calculation. Double_t GetChi2FromSVD(TH2D *data, TH2D *mc, TMatrixDSym *cov, TH2I *map = NULL, TH2I *mask = NULL); //! Get Chi2 using only the raw event rates given in each bin using a -2LL //! method. Double_t GetChi2FromEventRate(TH1D *data, TH1D *mc, TH1I *mask = NULL); //! Get Chi2 using only the raw event rates given in each bin using a -2LL //! method. Plots converted to 1D histograms before using 1D calculation. Double_t GetChi2FromEventRate(TH2D *data, TH2D *mc, TH2I *map = NULL, TH2I *mask = NULL); // Likelihood Functions //! Placeholder for 1D binned likelihood method Double_t GetLikelihoodFromDiag(TH1D *data, TH1D *mc, TH1I *mask = NULL); //! Placeholder for 2D binned likelihood method Double_t GetLikelihoodFromDiag(TH2D *data, TH2D *mc, TH2I *map = NULL, TH2I *mask = NULL); //! Placeholder for 1D binned likelihood method Double_t GetLikelihoodFromCov(TH1D *data, TH1D *mc, TMatrixDSym *invcov, TH1I *mask = NULL); //! Placeholder for 2D binned likelihood method Double_t GetLikelihoodFromCov(TH2D *data, TH2D *mc, TMatrixDSym *invcov, TH2I *map = NULL, TH2I *mask = NULL); //! Placeholder for 1D binned likelihood method Double_t GetLikelihoodFromSVD(TH1D *data, TH1D *mc, TMatrixDSym *cov, TH1I *mask = NULL); //! Placeholder for 2D binned likelihood method Double_t GetLikelihoodFromSVD(TH2D *data, TH2D *mc, TMatrixDSym *cov, TH2I *map = NULL, TH2I *mask = NULL); //! Placeholder for 1D binned likelihood method Double_t GetLikelihoodFromEventRate(TH1D *data, TH1D *mc, TH1I *mask = NULL); //! Placeholder for 2D binned likelihood method Double_t GetLikelihoodFromEventRate(TH2D *data, TH2D *mc, TH2I *map = NULL, TH2I *mask = NULL); /* NDOF Functions */ //! Return 1D Histogram NDOF considering masking and empty bins Int_t GetNDOF(TH1D *hist, TH1I *mask = NULL); //! Return 2D Histogram NDOF considering masking and empty bins Int_t GetNDOF(TH2D *hist, TH2I *map = NULL, TH2I *mask = NULL); /* Fake Data Functions */ //! Given a full covariance for a 1D data set throw the decomposition to //! generate fake data. throwdiag determines whether diagonal statistical errors //! are thrown. If no covariance is provided only statistical errors are thrown. TH1D *ThrowHistogram(TH1D *hist, TMatrixDSym *cov, bool throwdiag = true, TH1I *mask = NULL); //! Given a full covariance for a 2D data set throw the decomposition to //! generate fake data. Plots are converted to 1D histograms and the 1D //! ThrowHistogram is used, before being converted back to 2D histograms. TH2D *ThrowHistogram(TH2D *hist, TMatrixDSym *cov, TH2I *map = NULL, bool throwdiag = true, TH2I *mask = NULL); /* Masking Functions */ //! Given a mask histogram, mask out any bins in hist with non zero entries in //! mask. TH1D *ApplyHistogramMasking(TH1D *hist, TH1I *mask); //! Given a mask histogram, mask out any bins in hist with non zero entries in //! mask. TH2D *ApplyHistogramMasking(TH2D *hist, TH2I *mask); //! Given a mask histogram apply the masking procedure to each of the //! rows/columns in a covariance, before recalculating its inverse. TMatrixDSym *ApplyInvertedMatrixMasking(TMatrixDSym *mat, TH1I *mask); //! Given a mask histogram apply the masking procedure to each of the //! rows/columns in a covariance, before recalculating its inverse. Converts to //! 1D data before using the 1D ApplyInvertedMatrixMasking function and //! converting back to 2D. TMatrixDSym *ApplyInvertedMatrixMasking(TMatrixDSym *mat, TH2D *data, TH2I *mask, TH2I *map = NULL); //! Given a mask histogram apply the masking procedure to each of the //! rows/columns in a covariance TMatrixDSym *ApplyMatrixMasking(TMatrixDSym *mat, TH1I *mask); //! Given a mask histogram apply the masking procedure to each of the //! rows/columns in a covariance Converts to 1D data before using the 1D //! ApplyInvertedMatrixMasking function and converting back to 2D. TMatrixDSym *ApplyMatrixMasking(TMatrixDSym *mat, TH2D *data, TH2I *mask, TH2I *map = NULL); /* Covariance Handling Functions */ +//! Check if a matrix can be inverted with cholesky method +bool IsMatrixWellBehaved(TMatrixDSym* mat); + //! Return inverted matrix of TMatrixDSym TMatrixDSym *GetInvert(TMatrixDSym *mat, bool rescale = false); //! Return Cholesky Decomposed matrix of TMatrixDSym TMatrixDSym *GetDecomp(TMatrixDSym *mat); //! Return full covariances TMatrixDSym *GetCovarFromCorrel(TMatrixDSym *correl, TH1D *data); //! Given a normalisation factor for a dataset add in a new normalisation term //! to the covariance. void ForceNormIntoCovar(TMatrixDSym *&mat, TH1D *data, double norm); //! Given a normalisation factor for a dataset add in a new normalisation term //! to the covariance. Convertes 2D to 1D, before using 1D ForceNormIntoCovar void ForceNormIntoCovar(TMatrixDSym *mat, TH2D *data, double norm, TH2I *map = NULL); //! Given a dataset generate an uncorrelated covariance matrix using the bin //! errors. TMatrixDSym *MakeDiagonalCovarMatrix(TH1D *data, double scaleF = 1E38); //! Given a dataset generate an uncorrelated covariance matrix using the bin //! errors. TMatrixDSym *MakeDiagonalCovarMatrix(TH2D *data, TH2I *map = NULL, double scaleF = 1E38); //! Given a covariance set the errors in each bin on the data from the //! covariance diagonals. void SetDataErrorFromCov(TH1D *data, TMatrixDSym *cov, double scale = 1.0, bool ErrorCheck = true); //! Given a covariance set the errors in each bin on the data from the //! covariance diagonals. void SetDataErrorFromCov(TH2D *data, TMatrixDSym *cov, TH2I *map = NULL, double scale = 1.0, bool ErrorCheck = true); //! Given a covariance, extracts the shape-only matrix using the method from the //! MiniBooNE TN TMatrixDSym *ExtractShapeOnlyCovar(TMatrixDSym *full_covar, TH1D *data_hist, double data_scale = 1E38); TMatrixDSym *ExtractShapeOnlyCovar(TMatrixDSym *full_covar, TH2D *data_hist, TH2I *map = NULL, double data_scale = 1E38); /* Mapping Functions */ //! If no map is provided for the 2D histogram, generate one by counting up //! through the bins along x and y. TH2I *GenerateMap(TH2D *hist); //! Apply a map to a 2D histogram converting it into a 1D histogram. TH1D *MapToTH1D(TH2D *hist, TH2I *map); //! Apply a map to fill a TH2D from a TH1D; void MapFromTH1D(TH2 *fillhist, TH1 *fromhist, TH2I *map); //! Apply a map to a 2D mask convering it into a 1D mask. TH1I *MapToMask(TH2I *hist, TH2I *map); /// \brief Read TMatrixD from a text file /// /// - covfile = full path to text file /// - dimx = x dimensions of matrix /// - dimy = y dimensions of matrix /// /// Format of textfile should be: \n /// cov_11 cov_12 ... cov_1N \n /// cov_21 cov_22 ... cov_2N \n /// ... ... ... ... \n /// cov_N1 ... ... cov_NN \n /// /// If no dimensions are given, dimx and dimy are determined from rows/columns /// inside textfile. /// /// If only dimx is given a symmetric matrix is assumed. TMatrixD *GetMatrixFromTextFile(std::string covfile, int dimx = -1, int dimy = -1); /// \brief Read TMatrixD from a ROOT file /// /// - covfile = full path to root file (+';histogram') /// - histname = histogram name /// /// If no histogram name is given function assumes it has been appended /// covfile path as: \n /// 'covfile.root;histname' /// /// histname can point to a TMatrixD object, a TMatrixDSym object, or /// a TH2D object. TMatrixD *GetMatrixFromRootFile(std::string covfile, std::string histname = ""); /// \brief Calls GetMatrixFromTextFile and turns it into a TMatrixDSym TMatrixDSym *GetCovarFromTextFile(std::string covfile, int dim); /// \brief Calls GetMatrixFromRootFile and turns it into a TMatrixDSym TMatrixDSym *GetCovarFromRootFile(std::string covfile, std::string histname); }; // namespace StatUtils /*! @} */ #endif diff --git a/src/T2K/CMakeLists.txt b/src/T2K/CMakeLists.txt index f0955f1..e41ad31 100644 --- a/src/T2K/CMakeLists.txt +++ b/src/T2K/CMakeLists.txt @@ -1,122 +1,122 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(IMPLFILES T2K_CC0pi_XSec_H2O_2DPcos_anu.cxx T2K_NuMu_CC0pi_OC_XSec_2DPcos.cxx T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.cxx T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.cxx T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.cxx T2K_CC0pi_XSec_2DPcos_nu_I.cxx T2K_CC0pi_XSec_2DPcos_nu_II.cxx T2K_CCinc_XSec_2DPcos_nu_nonuniform.cxx T2K_nueCCinc_XSec_1Dpe.cxx T2K_nueCCinc_XSec_1Dthe.cxx T2K_nueCCinc_XSec_1Dpe_joint.cxx T2K_nueCCinc_XSec_1Dthe_joint.cxx T2K_nueCCinc_XSec_joint.cxx T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.cxx T2K_CC1pip_CH_XSec_1Dppi_nu.cxx T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx T2K_CC1pip_CH_XSec_1DQ2_nu.cxx T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.cxx T2K_CC1pip_CH_XSec_1DCosThAdler_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_CC0pinp_STV_XSec_1Ddphit_nu.cxx T2K_CC0pinp_STV_XSec_1Ddat_nu.cxx T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.cxx T2K_CC0pinp_ifk_XSec_3Dinfp_nu.cxx T2K_CC0pinp_ifk_XSec_3Dinfa_nu.cxx T2K_CC0pinp_ifk_XSec_3Dinfip_nu.cxx T2K_SignalDef.cxx ) set(HEADERFILES T2K_CC0pi_XSec_H2O_2DPcos_anu.h T2K_NuMu_CC0pi_OC_XSec_2DPcos.h T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.h T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.h T2K_CC0pi_XSec_2DPcos_nu_I.h T2K_CC0pi_XSec_2DPcos_nu_II.h T2K_CCinc_XSec_2DPcos_nu_nonuniform.h T2K_nueCCinc_XSec_1Dpe.h T2K_nueCCinc_XSec_1Dthe.h T2K_nueCCinc_XSec_1Dpe_joint.h T2K_nueCCinc_XSec_1Dthe_joint.h T2K_nueCCinc_XSec_joint.h T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.h T2K_CC1pip_CH_XSec_1Dppi_nu.h T2K_CC1pip_CH_XSec_1Dthpi_nu.h T2K_CC1pip_CH_XSec_1Dthmupi_nu.h T2K_CC1pip_CH_XSec_1DQ2_nu.h T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.h T2K_CC1pip_CH_XSec_1DCosThAdler_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_CC0pinp_STV_XSec_1Ddphit_nu.h T2K_CC0pinp_STV_XSec_1Ddat_nu.h T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h T2K_CC0pinp_ifk_XSec_3Dinfip_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(${MINIMUM_INCLUDE_DIRECTORIES}) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/T2K) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) diff --git a/src/T2K/SAMPLEREADME b/src/T2K/SAMPLEREADME deleted file mode 100644 index c8bfb08..0000000 --- a/src/T2K/SAMPLEREADME +++ /dev/null @@ -1 +0,0 @@ -./T2K_CC0pi_XSec_2DPcos_nu.cxx diff --git a/src/T2K/SubMakefile.backup b/src/T2K/SubMakefile.backup deleted file mode 100755 index ceedc38..0000000 --- a/src/T2K/SubMakefile.backup +++ /dev/null @@ -1,25 +0,0 @@ -# Author: Callum Wilkinson - -SHELL = /bin/sh -NAME = all -MAKEFILE = Makefile - -# Include machine specific flags and locations (inc. files & libs) -# -include $(EXT_FIT)/make/Make.include - -PACKAGE = externalDataFit_base -DICTIONARY = $(EXT_FIT)/src/FitBase/_ROOT_DICT_ExternalDataFit_base -LIBNAME = libExternalDataFit_base -EXTRA_EXT_LIBS = - - -all : rootcint lib -install : install-inc install-lib - -# Include standard package makefile targets -# -include $(EXT_FIT)/make/Make.std-package-targets - -FORCE: - diff --git a/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.cxx b/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.cxx index d7be3af..87ae0d0 100644 --- a/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.cxx +++ b/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.cxx @@ -1,651 +1,616 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h" //******************************************************************** T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np:: T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0piNp (N>=0) with p_p>500MeV \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n" "Data release: https://t2k-experiment.org/results/2018-transverse-cc0pi/ \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Bin number"); - // fSettings.SetYTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetYTitle("d^{3}#sigma/dN_{pr}dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fAnalysis = 1; // CCQELike plot information fSettings.SetTitle(fName); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Set useCC0pi0p, useCC0pi1p, and useCC0piNp, first initialize to false; useCC0pi0p = false; useCC0pi1p = false; useCC0piNp = false; if (fName == "T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np"){ useCC0pi0p = true; useCC0pi1p = true; useCC0piNp = true; + fSettings.SetXTitle("N_{pr}-p_{#mu}-cos#theta_{#mu}"); + } else if (fName == "T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p"){ useCC0pi0p = true; useCC0pi1p = true; + fSettings.SetXTitle("N_{pr}-p_{#mu}-cos#theta_{#mu}"); } else if (fName == "T2K_CC0piWithProtons_XSec_2018_multidif_0p"){ useCC0pi0p = true; + fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); } else if (fName == "T2K_CC0piWithProtons_XSec_2018_multidif_1p"){ useCC0pi1p = true; + fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); } // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon // fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * // 1E-38 / (TotalIntegratedFlux())); fScaleFactor = ((GetEventHistogram()->Integral("width") / (fNEvents + 0.)) * 10 / (TotalIntegratedFlux())); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; bool T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::isSignal(FitEvent *event) { // If looking at all subsamples, only requirement is that this is a CC0pi event if (useCC0pi0p && useCC0pi1p && useCC0piNp) return SignalDef::isCC0pi(event, 14, EnuMin, EnuMax); // Otherwise, evaluate each relevant signal definition separately if (useCC0pi0p && SignalDef::isT2K_CC0pi0p(event, EnuMin, EnuMax)) return true; if (useCC0pi1p && SignalDef::isT2K_CC0pi1p(event, EnuMin, EnuMax)) return true; if (useCC0piNp && SignalDef::isT2K_CC0piNp(event, EnuMin, EnuMax)) return true; // If you get here, the event has failed and is not signal return false; }; void T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::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())); // Dummy proton variables if we don't have a proton double pp = -999; double CosThetaP = -999; // Check if we do have a proton and fill variables if (event->NumFSParticle(2212) > 0){ TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; pp = Pp.Vect().Mag() / 1000.; CosThetaP = cos(Pnu.Vect().Angle(Pp.Vect())); } // How many protons above threshold? std::vector protons = event->GetAllFSProton(); int nProtonsAboveThresh = 0; for (size_t i = 0; i < protons.size(); i++) { if (protons[i]->p() > 500) nProtonsAboveThresh++; } // Get bin number in total 1D histogram int binnumber = Get1DBin(nProtonsAboveThresh, pmu, CosThetaMu, pp, CosThetaP); // I'm hacking this to fit in the Measurement1D framework, but it's going to be super ugly - apologies... // The 1D histogram handled by NUISANCE is defined in terms of bin number, so that has to be fXVar // Actually needs to be binnumber-0.5 because it's treating it as a variable fXVar = binnumber-0.5; // Then fill variables so I can use them to fill the slice histograms in FillHistograms() fPP = pp; fPMu = pmu; fCosThetaP = CosThetaP; fCosThetaMu = CosThetaMu; fNp = nProtonsAboveThresh; // Also set mode so the mode histogram works Mode = event->Mode; return; }; void T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::FillHistograms() { Measurement1D::FillHistograms(); if (Signal) { - // fMCHist_Fine2D->Fill(fXVar, fYVar, Weight); if (useCC0pi0p && fNp == 0){ fMCHist_CC0pi0pCosTheta->Fill(fCosThetaMu, Weight); } else if (useCC0pi1p && fNp == 1){ fMCHist_CC0pi1pCosTheta->Fill(fCosThetaMu, Weight); } FillMCSlice(fNp, fPMu, fCosThetaMu, fPP, fCosThetaP, Weight); } } void T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::FillMCSlice(int nProtonsAboveThresh, double pmu, double CosThetaMu, double pp, double CosThetaP, double w) { // Get slice number for 1D CosThetaMu slice int CosThetaMuSliceNo = GetCosThetaMuSlice(nProtonsAboveThresh, CosThetaMu); // If sliceno is valid (not negative), fill the relevant slice if (CosThetaMuSliceNo < 0) return; // CC0pi0p slices: fill with pmu if (useCC0pi0p && nProtonsAboveThresh == 0 && CosThetaMuSliceNo < 10){ fMCHist_Slices[CosThetaMuSliceNo]->Fill(pmu, w); } // CC0pi1p slices: fill with CosThetaP if (useCC0pi1p && nProtonsAboveThresh == 1){ fMCHist_Slices[CosThetaMuSliceNo]->Fill(CosThetaP, w); // If we're looking at CC0pi1p, also fill the CosThetaMu-CosThetaP slices with PP int CC0pi1p2DSliceNo = GetCC0pi1p2DSlice(nProtonsAboveThresh, CosThetaMu, CosThetaP); if (CC0pi1p2DSliceNo < 0) return; fMCHist_Slices[CC0pi1p2DSliceNo]->Fill(pp, w); } } void T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::SetHistograms() { + std::string name = fSettings.GetName(); + // Read in 1D Data Histograms fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/STV/multidif_results.root") - .c_str(), - "READ"); - // fInputFile->ls(); + .c_str(), "READ"); // Read in 1D Data - TH1D *tempDataHist = (TH1D *)fInputFile->Get("Result"); + TH1D *tempDataHist = (TH1D*)fInputFile->Get("Result"); + // tempDataHist->Scale(1e-38); // Read in covariance matrix - TH2D *tempcov = (TH2D *)fInputFile->Get("CovarianceMatrix"); + TH2D *tempcov = (TH2D*)fInputFile->Get("CovarianceMatrix"); // The input data and covariance matrix include bins for CC0pi0p, CC0pi1p, and CC0piNp. We may not want them all if we only want to look at one or two of the sub-samples, so go through and only keep the bins we want // CC0pi0p: bins 1-60 -> 60 bins // CC0pi1p: bins 61-92 -> 32 bins // CC0piNp: bin 93 -> 1 bin int n_binskeep = 0; if (useCC0pi0p) n_binskeep += 60; if (useCC0pi1p) n_binskeep += 32; if (useCC0piNp) n_binskeep += 1; - fDataHist = new TH1D("DataHist", tempDataHist->GetTitle(),n_binskeep,0,n_binskeep); + fDataHist = new TH1D(Form("%s_data", name.c_str()), + Form("%s_data%s", name.c_str(), fSettings.GetFullTitles().c_str()), + n_binskeep,0,n_binskeep); fFullCovar = new TMatrixDSym(n_binskeep); int i_binskeep = 1; for (int i_allbins=1; i_allbinsGetNbinsX()+1; i_allbins++){ if ((i_allbins >=1 && i_allbins <=60) && !useCC0pi0p) continue; if ((i_allbins >= 61 && i_allbins <=92) && !useCC0pi1p) continue; if ((i_allbins == 93) && !useCC0piNp) continue; fDataHist->SetBinContent(i_binskeep,tempDataHist->GetBinContent(i_allbins)); fDataHist->SetBinError(i_binskeep,tempDataHist->GetBinError(i_allbins)); int j_binskeep = 1; for (int j_allbins = 1; j_allbins < tempDataHist->GetNbinsX()+1; j_allbins++){ if ((j_allbins >=1 && j_allbins <=60) && !useCC0pi0p) continue; if ((j_allbins >= 61 && j_allbins <=92) && !useCC0pi1p) continue; if ((j_allbins == 93) && !useCC0piNp) continue; - // std::cout << i_allbins << ", " << j_allbins << " -- " << i_binskeep-1 << ", " << j_binskeep-1 << " -- " << tempcov->GetBinContent(i_allbins, j_allbins) << std::endl; - (*fFullCovar)(i_binskeep-1,j_binskeep-1) = tempcov->GetBinContent(i_allbins, j_allbins)*1e38*1e38; j_binskeep++; } // end loop over j_allbins i_binskeep++; } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); - // Make 1D data histogram - TH1D *linearResult = new TH1D(*fDataHist); - // Set name based on what subsamples we are looking at - if (useCC0pi0p && useCC0pi1p && useCC0piNp){ - linearResult->SetName("T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np_data"); - } - else if (useCC0pi0p && useCC0pi1p && !useCC0piNp){ - linearResult->SetName("T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_data"); - } - else if (useCC0pi0p && !useCC0pi1p && !useCC0piNp){ - linearResult->SetName("T2K_CC0piWithProtons_XSec_2018_multidif_0p_data"); - } - else if (!useCC0pi0p && useCC0pi1p && !useCC0piNp){ - linearResult->SetName("T2K_CC0piWithProtons_XSec_2018_multidif_1p_data"); - } - else{ - linearResult->SetName("T2K_CC0piWithProtons_XSec_2018_multidif_data"); - } - SetAutoProcessTH1(linearResult, kCMD_Write); - - - // Fine histograms - don't implement for now (this is copied from T2K_CC0pi1p_XSec_3DPcoscos_nu) - // fMCHist_Fine2D = new TH2D("T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np_Fine2D", - // "T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np_Fine2D", - // 400, 0.0, 30.0, 100, -1.0, 1.0); - // SetAutoProcessTH1(fMCHist_Fine2D); - - - // The code below converts a relative covariance matrix to an absolute one. I think the input is absolute so we don't need it, but come back to this if the results look weird - // for (int i = 0; i < fDataHist->GetNbinsX(); i++) { - // for (int j = 0; j < fDataHist->GetNbinsX(); j++) { - // //(*fFullCovar)(i,j) = tempcov->GetBinContent(i+1, j+1); - // (*fFullCovar)(i, j) = tempcov->GetBinContent(i + 1, j + 1) * - // fDataHist->GetBinContent(i + 1) * - // fDataHist->GetBinContent(j + 1); - // if (i == j) - // fDataHist->SetBinError(i + 1, sqrt((*fFullCovar)(i, j))); - // // if(i==j) std::cout << "For bin " << i+1 << ", relative covariance was " - // // << tempcov->GetBinContent(i+1,j+1); if(i==j) std::cout << ". Absolute - // // covariance is now " << (*fFullCovar)(i,j) << ", linear xsec is: " << - // // fDataHist->GetBinContent(i+1) << std::endl; - // } - // } - - // Read in data slice histograms and make MC slices // Slices are stored in slightly different ways for 0p and 1p samples // CC0pi0p: folder NoProtonsAbove500MeV // -> TH1D ResultInMuonCosTheta // -> TH1D MuonCosThetaSlice_i where i = 0 to 9 // CC0pi1p: folder OneProtonAbove500MeV // -> TH1D ResultInMuonCosTheta // -> TH1D MuonCosThetaSlice_1D_i where i = 0 to 3 // -> TH1D MuCThSlice_1_PCthSlice_0 // -> TH1D MuCThSlice_2_PCthSlice_0 // -> TH1D MuCThSlice_2_PCthSlice_1 // -> TH1D MuCThSlice_3_PCthSlice_0 // We also have proton multiplicity, in folder ProtonMultiplicity // -> TH1D Result // -> TH2D CovarianceMatrix - // TODO add this as a separate sample? Don't implement here // CC0pi0p slices if (useCC0pi0p){ - fDataHist_CC0pi0pCosTheta = (TH1D*)fInputFile->Get("NoProtonsAbove500MeV/ResultInMuonCosTheta")->Clone("T2K_CC0pi0p_XSec_2018_MuonCosTheta_data"); - fMCHist_CC0pi0pCosTheta = (TH1D*)fDataHist_CC0pi0pCosTheta->Clone("T2K_CC0pi0p_XSec_2018_MuonCosTheta_MC"); - fMCHist_CC0pi0pCosTheta->Reset(); + std::string temp_name = "T2K_CC0piWithProtons_XSec_2018_multidif_0p"; + fDataHist_CC0pi0pCosTheta = (TH1D*)fInputFile->Get("NoProtonsAbove500MeV/ResultInMuonCosTheta")->Clone(); + fDataHist_CC0pi0pCosTheta ->SetName(Form("%s_MuonCosTheta_data", temp_name.c_str())); + + fMCHist_CC0pi0pCosTheta = (TH1D*)fDataHist_CC0pi0pCosTheta->Clone(); + fMCHist_CC0pi0pCosTheta ->SetName(Form("%s_MuonCosTheta_MC", temp_name.c_str())), + fMCHist_CC0pi0pCosTheta ->Reset(); SetAutoProcessTH1(fDataHist_CC0pi0pCosTheta, kCMD_Write); SetAutoProcessTH1(fMCHist_CC0pi0pCosTheta, kCMD_Reset, kCMD_Scale, kCMD_Write); for (int i=0; i<=9; i++){ - fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("NoProtonsAbove500MeV/MuonCosThetaSlice_%i", i))->Clone(Form("T2K_CC0pi0p_XSec_2018_Data_Slice%i", i))); - fMCHist_Slices.push_back((TH1D*)fInputFile->Get(Form("NoProtonsAbove500MeV/MuonCosThetaSlice_%i", i))->Clone(Form("T2K_CC0pi0p_XSec_2018_MC_Slice%i", i))); + fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("NoProtonsAbove500MeV/MuonCosThetaSlice_%i", i))->Clone()); + fDataHist_Slices.back()->SetName(Form("%s_MuonCosTheta_data_Slice%i", temp_name.c_str(), i)); + fMCHist_Slices .push_back((TH1D*)fInputFile->Get(Form("NoProtonsAbove500MeV/MuonCosThetaSlice_%i", i))->Clone()); + fMCHist_Slices .back()->SetName(Form("%s_MuonCosTheta_MC_Slice%i", temp_name.c_str(), i)); } // end loop over i } // CC0pi1p slices if (useCC0pi1p){ - fDataHist_CC0pi1pCosTheta = (TH1D*)fInputFile->Get("OneProtonAbove500MeV/ResultInMuonCosTheta")->Clone("T2K_CC0pi1p_XSec_2018_MuonCosTheta_data"); - fMCHist_CC0pi1pCosTheta = (TH1D*)fDataHist_CC0pi1pCosTheta->Clone("T2K_CC0pi1p_XSec_2018_MuonCosTheta_MC"); - fMCHist_CC0pi1pCosTheta->Reset(); + std::string temp_name = "T2K_CC0piWithProtons_XSec_2018_multidif_1p"; + fDataHist_CC0pi1pCosTheta = (TH1D*)fInputFile->Get("OneProtonAbove500MeV/ResultInMuonCosTheta")->Clone(); + fDataHist_CC0pi1pCosTheta ->SetName(Form("%s_MuonCosTheta_data", temp_name.c_str())); + fMCHist_CC0pi1pCosTheta = (TH1D*)fDataHist_CC0pi1pCosTheta->Clone(); + fMCHist_CC0pi1pCosTheta ->SetName(Form("%s_MuonCosTheta_MC", temp_name.c_str())); + fMCHist_CC0pi1pCosTheta ->Reset(); SetAutoProcessTH1(fDataHist_CC0pi1pCosTheta, kCMD_Write); SetAutoProcessTH1(fMCHist_CC0pi1pCosTheta, kCMD_Reset, kCMD_Scale, kCMD_Write); for (int i=0; i<=3; i++){ - fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("OneProtonAbove500MeV/MuonCosThetaSlice_1D_%i", i))->Clone(Form("T2K_CC0pi1p_XSec_2018_Data_MuonCosTh1DSlice%i", i))); - fMCHist_Slices.push_back((TH1D*)fInputFile->Get(Form("OneProtonAbove500MeV/MuonCosThetaSlice_1D_%i", i))->Clone(Form("T2K_CC0pi1p_XSec_2018_MC_MuonCosTh1DSlice%i", i))); + fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("OneProtonAbove500MeV/MuonCosThetaSlice_1D_%i", i))->Clone()); + fDataHist_Slices.back()->SetName(Form("%s_MuonCosTh_data_Slice%i", temp_name.c_str(), i)); + fMCHist_Slices .push_back((TH1D*)fInputFile->Get(Form("OneProtonAbove500MeV/MuonCosThetaSlice_1D_%i", i))->Clone()); + fMCHist_Slices .back()->SetName(Form("%s_MuonCosTh_MC_Slice%i", temp_name.c_str(), i)); } // Add in the muon costh-p costh slices (which aren't as nicely numbered) // -> TH1D MuCThSlice_1_PCthSlice_0 - fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_1_PCthSlice_0")->Clone("T2K_CC0pi1p_XSec_2018_Data_MuCThSlice_1_PCthSlice_0")); - fMCHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_1_PCthSlice_0")->Clone("T2K_CC0pi1p_XSec_2018_MC_MuCThSlice_1_PCthSlice_0")); + fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_1_PCthSlice_0")->Clone()); + fDataHist_Slices.back()->SetName(Form("%s_data_MuCThSlice_1_PCthSlice_0", temp_name.c_str())); + fMCHist_Slices .push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_1_PCthSlice_0")->Clone()); + fMCHist_Slices .back()->SetName(Form("%s_MC_MuCThSlice_1_PCthSlice_0", temp_name.c_str())); // -> TH1D MuCThSlice_2_PCthSlice_0 - fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_0")->Clone("T2K_CC0pi1p_XSec_2018_Data_MuCThSlice_2_PCthSlice_0")); - fMCHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_0")->Clone("T2K_CC0pi1p_XSec_2018_MC_MuCThSlice_2_PCthSlice_0")); + fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_0")->Clone()); + fDataHist_Slices.back()->SetName(Form("%s_data_MuCThSlice_2_PCthSlice_0", temp_name.c_str())); + fMCHist_Slices .push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_0")->Clone()); + fMCHist_Slices .back()->SetName(Form("%s_MC_MuCThSlice_2_PCthSlice_0", temp_name.c_str())); // -> TH1D MuCThSlice_2_PCthSlice_1 - fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_1")->Clone("T2K_CC0pi1p_XSec_2018_Data_MuCThSlice_2_PCthSlice_1")); - fMCHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_1")->Clone("T2K_CC0pi1p_XSec_2018_MC_MuCThSlice_2_PCthSlice_1")); + fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_1")->Clone()); + fDataHist_Slices.back()->SetName(Form("%s_data_MuCThSlice_2_PCthSlice_1", temp_name.c_str())); + fMCHist_Slices .push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_2_PCthSlice_1")->Clone()); + fMCHist_Slices .back()->SetName(Form("%s_MC_MuCThSlice_2_PCthSlice_1", temp_name.c_str())); // -> TH1D MuCThSlice_3_PCthSlice_0 - fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_3_PCthSlice_0")->Clone("T2K_CC0pi1p_XSec_2018_Data_MuCThSlice_3_PCthSlice_0")); - fMCHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_3_PCthSlice_0")->Clone("T2K_CC0pi1p_XSec_2018_MC_MuCThSlice_3_PCthSlice_0")); + fDataHist_Slices.push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_3_PCthSlice_0")->Clone()); + fDataHist_Slices.back()->SetName(Form("%s_data_MuCThSlice_3_PCthSlice_0", temp_name.c_str())); + fMCHist_Slices .push_back((TH1D*)fInputFile->Get("OneProtonAbove500MeV/MuCThSlice_3_PCthSlice_0")->Clone()); + fMCHist_Slices .back()->SetName(Form("%s_MC_MuCThSlice_3_PCthSlice_0", temp_name.c_str())); } // Set all slice histograms to auto-process and reset MC histograms for (size_t i=0; iReset(); SetAutoProcessTH1(fDataHist_Slices[i], kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i], kCMD_Reset, kCMD_Scale, kCMD_Write); } return; }; // Yay hardcoding // Taken from multidif_binMap.txt in data release int T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::Get1DBin(int nProtonsAboveThresh, double pmu, double CosThetaMu, double pp, double CosThetaP) { int binnumber = -999; // If you're looking at a sample you don't want to look at, return -999 if (nProtonsAboveThresh == 0 && !useCC0pi0p){return binnumber;} if (nProtonsAboveThresh == 1 && !useCC0pi1p){return binnumber;} if (nProtonsAboveThresh >= 2 && !useCC0piNp){return binnumber;} // Calculate bin number (check that we want to use this sample before looking for the correct bin to save computation -- probably redundant because of the checks above but I like to be careful) if (nProtonsAboveThresh == 0 && useCC0pi0p){ //CC0pi0p: 2D binning in CosThetaMu--pmu if (CosThetaMu >= -1 && CosThetaMu <= -0.3) {binnumber = 1;} else if (CosThetaMu > -0.3 && CosThetaMu <= 0.3){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.3) {binnumber = 2;} else if (pmu > 0.3 && pmu <= 0.4){binnumber = 3;} else if (pmu > 0.4 && pmu <= 30){binnumber = 4;} } // end if (CosThetaMu > -0.3 && CosThetaMu <= 0.3) else if (CosThetaMu > 0.3 && CosThetaMu <= 0.6){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.3){binnumber = 5;} else if (pmu > 0.3 && pmu <= 0.4){binnumber = 6;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 7;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 8;} else if (pmu > 0.6 && pmu <= 30){binnumber = 9;} } // end if (CosThetaMu > 0.3 && CosThetaMu <= 0.6) else if (CosThetaMu > 0.6 && CosThetaMu <= 0.7){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.3){binnumber = 10;} else if (pmu > 0.3 && pmu <= 0.4){binnumber = 11;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 12;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 13;} else if (pmu > 0.6 && pmu <= 30){binnumber = 14;} } // end if (CosThetaMu > 0.6 && CosThetaMu <= 0.7) else if (CosThetaMu > 0.7 && CosThetaMu <= 0.8){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.3){binnumber = 15;} else if (pmu > 0.3 && pmu <= 0.4){binnumber = 16;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 17;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 18;} else if (pmu > 0.6 && pmu <= 0.7){binnumber = 19;} else if (pmu > 0.7 && pmu <= 0.8){binnumber = 20;} else if (pmu > 0.8 && pmu <= 30){binnumber = 21;} } // end if (CosThetaMu > 0.7 && CosThetaMu <= 0.8) else if (CosThetaMu > 0.8 && CosThetaMu <= 0.85){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.4){binnumber = 22;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 23;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 24;} else if (pmu > 0.6 && pmu <= 0.7){binnumber = 25;} else if (pmu > 0.7 && pmu <= 0.8){binnumber = 26;} else if (pmu > 0.8 && pmu <= 30){binnumber = 27;} } // end if (CosThetaMu > 0.8 && CosThetaMu <= 0.85) else if (CosThetaMu > 0.85 && CosThetaMu <= 0.9){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.3){binnumber = 28;} else if (pmu > 0.3 && pmu <= 0.4){binnumber = 29;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 30;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 31;} else if (pmu > 0.6 && pmu <= 0.7){binnumber = 32;} else if (pmu > 0.7 && pmu <= 0.8){binnumber = 33;} else if (pmu > 0.8 && pmu <= 1){binnumber = 34;} else if (pmu > 1 && pmu <= 30){binnumber = 35;} } // end if (CosThetaMu > 0.85 && CosThetaMu <= 0.9) else if (CosThetaMu > 0.9 && CosThetaMu <= 0.94){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.4){binnumber = 36;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 37;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 38;} else if (pmu > 0.6 && pmu <= 0.7){binnumber = 39;} else if (pmu > 0.7 && pmu <= 0.8){binnumber = 40;} else if (pmu > 0.8 && pmu <= 1.25){binnumber = 41;} else if (pmu > 1.25 && pmu <= 30){binnumber = 42;} } // end if (CosThetaMu > 0.9 && CosThetaMu <= 0.94) else if (CosThetaMu > 0.94 && CosThetaMu <= 0.98){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.4){binnumber = 43;} else if (pmu > 0.4 && pmu <= 0.5){binnumber = 44;} else if (pmu > 0.5 && pmu <= 0.6){binnumber = 45;} else if (pmu > 0.6 && pmu <= 0.7){binnumber = 46;} else if (pmu > 0.7 && pmu <= 0.8){binnumber = 47;} else if (pmu > 0.8 && pmu <= 1){binnumber = 48;} else if (pmu > 1 && pmu <= 1.25){binnumber = 49;} else if (pmu > 1.25 && pmu <= 1.5){binnumber = 50;} else if (pmu > 1.5 && pmu <= 2){binnumber = 51;} else if (pmu > 2 && pmu <= 30){binnumber = 52;} } // end if (CosThetaMu > 0.94 && CosThetaMu <= 0.98) else if (CosThetaMu > 0.98 && CosThetaMu <= 1){ // Now find bin in pmu if (pmu >= 0 && pmu <= 0.5){binnumber = 53;} else if (pmu > 0.5 && pmu <= 0.65){binnumber = 54;} else if (pmu > 0.65 && pmu <= 0.8){binnumber = 55;} else if (pmu > 0.8 && pmu <= 1.25){binnumber = 56;} else if (pmu > 1.25 && pmu <= 2){binnumber = 57;} else if (pmu > 2 && pmu <= 3){binnumber = 58;} else if (pmu > 3 && pmu <= 5){binnumber = 59;} else if (pmu > 5 && pmu <= 30){binnumber = 60;} } // end if (CosThetaMu > 0.98 && CosThetaMu <= 1) } // end (nProtonsAboveThresh == 0) else if (nProtonsAboveThresh == 1 && useCC0pi1p){ if (CosThetaMu >= -1 && CosThetaMu <= -0.3){ // Find bin in CosThetaP if (CosThetaP >= -1 && CosThetaP <= 0.87){binnumber = 61;} else if (CosThetaP > 0.87 && CosThetaP <= 0.94){binnumber = 62;} else if (CosThetaP > 0.94 && CosThetaP <= 0.97){binnumber = 63;} else if (CosThetaP > 0.97 && CosThetaP <= 1){binnumber = 64;} } // end (CosThetaMu >= -1 && CosThetaMu <= -0.3) else if (CosThetaMu > -0.3 && CosThetaMu <= 0.3){ // Find bin in CosThetaP if (CosThetaP >= -1 && CosThetaP <= 0.75){binnumber = 65;} else if (CosThetaP > 0.75 && CosThetaP <= 0.85){binnumber = 66;} else if (CosThetaP > 0.85 && CosThetaP <= 0.94){ // Find bin in pp if (pp >= 0.5 && pp <= 0.68){binnumber = 67;} else if (pp > 0.68 && pp <= 0.78){binnumber = 68;} else if (pp > 0.78 && pp <= 0.9){binnumber = 69;} else if (pp > 0.9 && pp <= 30){binnumber = 70;} } // end if (CosThetaP > 0.85 && CosThetaP <= 0.94) else if (CosThetaP > 0.94 && CosThetaP <= 1){binnumber = 71;} } // end if (CosThetaMu > -0.3 && CosThetaMu <= 0.3) else if (CosThetaMu > 0.3 && CosThetaMu <= 0.8){ // Find bin in CosThetaP if (CosThetaP >= -1 && CosThetaP <= 0.3){binnumber = 72;} else if (CosThetaP > 0.3 && CosThetaP <= 0.5){binnumber = 73;} else if (CosThetaP > 0.5 && CosThetaP <= 0.8){ // find bin in pp if (pp >= 0.5 && pp <= 0.6){binnumber = 74;} else if (pp > 0.6 && pp <= 0.7){binnumber = 75;} else if (pp > 0.7 && pp <= 0.8){binnumber = 76;} else if (pp > 0.8 && pp <= 0.9){binnumber = 77;} else if (pp > 0.9 && pp <= 30){binnumber = 78;} } // end if (CosThetaP > 0.5 && CosThetaP <= 0.8) else if (CosThetaP > 0.8 && CosThetaP <= 1){ // find bin in pp if (pp >= 0.5 && pp <= 0.6){binnumber = 79;} else if (pp > 0.6 && pp <= 0.7){binnumber = 80;} else if (pp > 0.7 && pp <= 0.8){binnumber = 81;} else if (pp > 0.8 && pp <= 1){binnumber = 82;} else if (pp > 1 && pp <= 30){binnumber = 83;} } // end if (CosThetaP > 0.8 && CosThetaP <= 1) } // end if (CosThetaMu > 0.3 && CosThetaMu <= 0.8) else if (CosThetaMu > 0.8 && CosThetaMu <= 1){ // Find bin in CosThetaP if (CosThetaP >= -1 && CosThetaP <= 0){binnumber = 84;} else if (CosThetaP > 0 && CosThetaP <= 0.3){binnumber = 85;} else if (CosThetaP > 0.3 && CosThetaP <= 0.8){ // find bin in pp if (pp >= 0.5 && pp <= 0.6){binnumber = 86;} else if (pp > 0.6 && pp <= 0.7){binnumber = 87;} else if (pp > 0.7 && pp <= 0.8){binnumber = 88;} else if (pp > 0.8 && pp <= 0.9){binnumber = 89;} else if (pp > 0.9 && pp <= 1.1){binnumber = 90;} else if (pp > 1.1 && pp <= 30){binnumber = 91;} } // end if (CosThetaP > 0.3 && CosThetaP <= 0.8) else if (CosThetaP > 0.8 && CosThetaP <= 1){binnumber = 92;} } // end if (CosThetaMu > 0.8 && CosThetaMu <= 1) } // end if (nProtonsAboveThresh == 1) else if (nProtonsAboveThresh > 1 && useCC0piNp){ binnumber = 93; } // If binnumber is still -999, something has gone wrong if (binnumber == -999){ - std::cout << "ERROR did not find correct 1D bin for an event with nProtonsAboveThresh = " << nProtonsAboveThresh << ", pmu = " << pmu << ", CosThetaMu = " << CosThetaMu << ", pp = " << pp << ", CosThetaP = " << CosThetaP << std::endl; + NUIS_ERR(FTL, "Did not find correct 1D bin for an event with nProtonsAboveThresh = " << nProtonsAboveThresh << ", pmu = " << pmu << ", CosThetaMu = " << CosThetaMu << ", pp = " << pp << ", CosThetaP = " << CosThetaP); return -999; } // Now need to work out adjustments for if we don't want to use one or more of the samples // If all samples are wanted, no adjustments required - the binning stands // If only CC0pi0p sample is wanted, no adjustments required - CC0pi0p binning is correct and the other bins won't be assigned // If CC0pi0p and CC0pi1p samples are wanted, no adjustments required // If only CC0pi1p sample is wanted or CC0pi1p and CC0piNp samples are wanted, need to subtract off total number of CC0pi0p bins if (useCC0pi1p && !useCC0pi0p){ binnumber -= 60; } // If only CC0piNp sample is wanted, need to subtract off total number of CC0pi0p and CC0pi1p bins if (useCC0piNp && !useCC0pi0p && !useCC0pi1p){ binnumber =- 92; } // If CC0pi0p and CC0piNp samples are wanted, need to subtract off CC0pi1p bins from CC0piNp bin number if (useCC0piNp && useCC0pi0p && !useCC0pi1p && binnumber == 93){ binnumber = 61; } return binnumber; }; // Yay hardcoding again! // Taken from multidif_binMap.txt in data release int T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::GetCosThetaMuSlice(int nProtonsAboveThresh, double CosThetaMu) { int slicenumber = -999; // if (useCC0pi0p), the first 10 slices will be CC0pi0p slices // -> TH1D MuonCosThetaSlice_i where i = 0 to 9 // -> slices 0 to 9 // if (useCC0pi1p), the next 8 slices will be CC0pi1p slices // -> TH1D MuonCosThetaSlice_1D_i where i = 0 to 3 // -> TH1D MuCThSlice_1_PCthSlice_0 // -> TH1D MuCThSlice_2_PCthSlice_0 // -> TH1D MuCThSlice_2_PCthSlice_1 // -> TH1D MuCThSlice_3_PCthSlice_0 // -> slices 10 to 17 if (useCC0pi0p) // -> slices 0 to 7 if (!useCC0pi0p) // In this code, we just find the costhetamu slices // Calculate bin number (check that we want to use this sample before looking for the correct bin to save computation) if (nProtonsAboveThresh == 0 && useCC0pi0p){ //CC0pi0p: 10 slices in CosThetaMu if (CosThetaMu >= -1 && CosThetaMu <= -0.3) {slicenumber = 0;} else if (CosThetaMu > -0.3 && CosThetaMu <= 0.3){slicenumber = 1;} else if (CosThetaMu > 0.3 && CosThetaMu <= 0.6){slicenumber = 2;} else if (CosThetaMu > 0.6 && CosThetaMu <= 0.7){slicenumber = 3;} else if (CosThetaMu > 0.7 && CosThetaMu <= 0.8){slicenumber = 4;} else if (CosThetaMu > 0.8 && CosThetaMu <= 0.85){slicenumber = 5;} else if (CosThetaMu > 0.85 && CosThetaMu <= 0.9){slicenumber = 6;} else if (CosThetaMu > 0.9 && CosThetaMu <= 0.94){slicenumber = 7;} else if (CosThetaMu > 0.94 && CosThetaMu <= 0.98){slicenumber = 8;} else if (CosThetaMu > 0.98 && CosThetaMu <= 1){slicenumber = 9;} } // end (nProtonsAboveThresh == 0) else if (nProtonsAboveThresh == 1 && useCC0pi1p){ // CC0pi1p: 8 slices, either in CosThetaMu or CosThetaMu-CosThetaP, depending on the slice if (CosThetaMu >= -1 && CosThetaMu <= -0.3){slicenumber = 10;} else if (CosThetaMu > -0.3 && CosThetaMu <= 0.3){slicenumber = 11;} else if (CosThetaMu > 0.3 && CosThetaMu <= 0.8){slicenumber = 12;} else if (CosThetaMu > 0.8 && CosThetaMu <= 1){slicenumber = 13;} } // end if (nProtonsAboveThresh == 1) // slicenumber may be -999 if nProtonsAboveThresh > 1 // otherwise, something has gone wrong if (slicenumber == -999 && nProtonsAboveThresh <= 1){ std::cout << "ERROR did not find correct 1D CosThetaMu slice for an event with nProtonsAboveThresh = " << nProtonsAboveThresh << ", CosThetaMu = " << CosThetaMu << std::endl; return -999; } // If useCC0pi0p is false, adjust slice numbers for CC0pi1p if (useCC0pi1p && !useCC0pi0p){ slicenumber -= 10; } return slicenumber; }; // Hardcoding one more time // Taken from multidif_binMap.txt in data release int T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::GetCC0pi1p2DSlice(int nProtonsAboveThresh, double CosThetaMu, double CosThetaP) { int slicenumber = -999; // Calculate slice number (note: only 2D CC0pi1p slices in CosThetaMu-CosThetaP are handled here) // These slices exist for: // CosThetaMu -0.3 - 0.3, CosThetaP 0.85 - 0.94 // CosThetaMu 0.3 - 0.8, CosThetaP 0.5 - 0.8 // CosThetaMu 0.3 - 0.8, CosThetaP 0.8 - 1.0 // CosThetaMu 0.8 - 1.0, CosThetaP 0.3 - 0.8 // If useCC0pi0p is true, these will be slices 14-17 // If useCC0pi0p is false, these will be slices 4-7 if (nProtonsAboveThresh == 1 && useCC0pi1p){ if (CosThetaMu > -0.3 && CosThetaMu <= 0.3 && CosThetaP > 0.85 && CosThetaP <= 0.94){slicenumber = 14;} else if (CosThetaMu > 0.3 && CosThetaMu <= 0.8){ // Find bin in CosThetaP if (CosThetaP > 0.5 && CosThetaP <= 0.8){slicenumber = 15;} else if (CosThetaP > 0.8 && CosThetaP <= 1){slicenumber = 16;} } // end if (CosThetaMu > 0.3 && CosThetaMu <= 0.8) else if (CosThetaMu > 0.8 && CosThetaMu <= 1 && CosThetaP > 0.3 && CosThetaP <= 0.8){slicenumber = 17;} } // end if (nProtonsAboveThresh == 1) // No check on binnumber = -999 here, because many events won't fall into one of these slices // If useCC0pi0p is false, adjust slice numbers for CC0pi1p if (useCC0pi1p && !useCC0pi0p){ slicenumber -= 10; } return slicenumber; }; - -// // Reimplementation of Measurement1D::Write (calling the original) to also set the slice histograms to have the chi2 of the total 1D histogram -- makes plotting easier -// void T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np::Write(std::string drawOpt){ -// // call Measurement1D::Write -// Measurement1D::Write(drawOpt); -// -// // Now also set slice histogram titles to be equal to the overall chi2 -// std::ostringstream chi2; -// chi2 << std::setprecision(5) << GetLikelihood(); -// for (size_t i=0; iSetTitle(chi2.str().c_str()); -// } -// }; diff --git a/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h b/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h index 734d362..0400b8b 100644 --- a/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h +++ b/src/T2K/T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np.h @@ -1,81 +1,81 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PIWITHPROTONS_XSEC_2018_MULTIDIF_0P_1P_NP_H_SEEN #define T2K_CC0PIWITHPROTONS_XSEC_2018_MULTIDIF_0P_1P_NP_H_SEEN #include "Measurement1D.h" class T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np : public Measurement1D { public: /// Basic Constructor. T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np(nuiskey samplekey); /// Virtual Destructor ~T2K_CC0piWithProtons_XSec_2018_multidif_0p_1p_Np() {}; /// Numu CC0PI Signal Definition /// /// /item bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. /// Read from FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root" void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); private: bool useCC0pi0p; bool useCC0pi1p; bool useCC0piNp; bool only_allowed_particles; bool numu_event; double numu_energy; int particle_pdg; int fAnalysis; double fPP, fCosThetaP, fPMu, fCosThetaMu, fNp; bool fIsSystCov, fIsStatCov, fIsNormCov; TFile* fInputFile; TH2D* fMCHist_Fine2D; TH1D *fMCHist_CC0pi0pCosTheta; TH1D *fDataHist_CC0pi0pCosTheta; TH1D *fMCHist_CC0pi1pCosTheta; TH1D *fDataHist_CC0pi1pCosTheta; std::vector fMCHist_Slices; std::vector fDataHist_Slices; void FillMCSlice(int nProtonsAboveThresh, double pmu, double CosThetaMu, double pp, double CosThetaP, double w); int Get1DBin(int nProtonsAboveThresh, double pmu, double CosThetaMu, double pp, double CosThetaP); int GetCosThetaMuSlice(int nProtonsAboveThresh, double CosThetaMu); int GetCC0pi1p2DSlice(int nProtonsAboveThresh, double CosThetaMu, double CosThetaP); // void Write(std::string drawOpt); }; #endif diff --git a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.cxx b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.cxx index be6e097..a4818f0 100644 --- a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.cxx +++ b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.cxx @@ -1,373 +1,378 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pi_XSec_2DPcos_nu_I.h" static size_t nangbins = 9; static double angular_binning_costheta[] = {-1, 0, 0.6, 0.7, 0.8, 0.85, 0.9, 0.94, 0.98, 1}; //******************************************************************** T2K_CC0pi_XSec_2DPcos_nu_I::T2K_CC0pi_XSec_2DPcos_nu_I(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pi_XSec_2DPcos_nu_I sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "https://journals.aps.org/prd/abstract/10.1103/" "PhysRevD.93.112012 Analysis I"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("P_{#mu} (GeV)"); - fSettings.SetYTitle("cos#theta_{#mu}"); - fSettings.SetZTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetXTitle("cos#theta_{#mu}-p_{#mu} (GeV)"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV", "FIX/FULL"); fSettings.DefineAllowedTargets("C,H"); fSettings.SetEnuRangeFromFlux(fFluxHist); // CCQELike plot information fSettings.SetTitle("T2K_CC0pi_XSec_2DPcos_nu_I"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); fMaskMomOverflow = false; if (samplekey.Has("mask_mom_overflow")) { fMaskMomOverflow = samplekey.GetB("mask_mom_overflow"); } // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width") / (fNEvents + 0.)) * 1E-38 / (TotalIntegratedFlux())); assert(std::isnormal(fScaleFactor)); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; bool T2K_CC0pi_XSec_2DPcos_nu_I::isSignal(FitEvent *event) { return SignalDef::isT2K_CC0pi(event, EnuMin, EnuMax, SignalDef::kAnalysis_I); }; void T2K_CC0pi_XSec_2DPcos_nu_I::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; fMode = event->Mode; return; }; void T2K_CC0pi_XSec_2DPcos_nu_I::FillHistograms() { Measurement1D::FillHistograms(); if (Signal) { fMCHist_Fine2D->Fill(fXVar, fYVar, Weight); FillMCSlice(fXVar, fYVar, Weight); } } // 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_I::ConvertEventRates() { // Do standard conversion. Measurement1D::ConvertEventRates(); // Scale MC slices by their bin area for (size_t i = 0; i < nangbins; ++i) { fMCHist_Slices[i]->Scale(fScaleFactor / (angular_binning_costheta[i + 1] - angular_binning_costheta[i]), "width"); } // Now Convert into 1D list fMCHist->Reset(); int bincount = 0; for (size_t i = 0; i < nangbins; i++) { for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fMCHist->SetBinContent(bincount + 1, fMCHist_Slices[i]->GetBinContent(j + 1)); fMCHist->SetBinError(bincount + 1, fMCHist_Slices[i]->GetBinError(j + 1)); bincount++; } } if (fMCHist_Modes) { fMCHist_Modes->Reset(); for (std::map >::iterator it = fMCModeHists_Slices.begin(); it != fMCModeHists_Slices.end(); ++it) { bincount = 0; for (size_t i = 0; i < nangbins; i++) { it->second[i]->Scale(fScaleFactor / (angular_binning_costheta[i + 1] - angular_binning_costheta[i]), "width"); for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fMCHist_Modes->SetBinContent(it->first, bincount + 1, 0, 0, it->second[i]->GetBinContent(j + 1)); fMCHist_Modes->SetBinError(it->first, bincount + 1, 0, 0, it->second[i]->GetBinError(j + 1)); bincount++; } } } } return; } void T2K_CC0pi_XSec_2DPcos_nu_I::FillMCSlice(double x, double y, double w) { if (fMCHist_Modes && !fMCModeHists_Slices.count(fMode)) { for (size_t i = 0; i < nangbins; ++i) { std::stringstream ss(""); ss << "T2K_CC0pi_XSec_2DPcos_nu_I_MODE_ " << fMode << "_slice" << i << std::endl; fMCModeHists_Slices[fMode].push_back( static_cast(fMCHist_Slices[i]->Clone(ss.str().c_str()))); fMCModeHists_Slices[fMode].back()->Reset(); } } for (size_t i = 0; i < nangbins; ++i) { if ((y >= angular_binning_costheta[i]) && (y < angular_binning_costheta[i + 1])) { fMCHist_Slices[i]->Fill(x, w); if (fMCHist_Modes) { fMCModeHists_Slices[fMode][i]->Fill(x, w); } } } } void T2K_CC0pi_XSec_2DPcos_nu_I::SetHistograms() { // Read in 1D Data Histograms TFile input( (FitPar::GetDataBase() + "/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root") - .c_str(), - "READ"); + .c_str(), "READ"); fMCHist_Fine2D = new TH2D("T2K_CC0pi_XSec_2DPcos_nu_I_Fine2D", - "T2K_CC0pi_XSec_2DPcos_nu_I_Fine2D", 400, 0.0, 30.0, - 100, -1.0, 1.0); + "T2K_CC0pi_XSec_2DPcos_nu_I_Fine2D", + 400, 0.0, 30.0, 100, -1.0, 1.0); + fMCHist_Fine2D->GetXaxis()->SetTitle("p_{#mu} (GeV)"); + fMCHist_Fine2D->GetYaxis()->SetTitle("cos#theta_{#mu}"); + fMCHist_Fine2D->GetZaxis()->SetTitle(fSettings.GetYTitle().c_str()); + fMCHist_Fine2D->SetDirectory(NULL); SetAutoProcessTH1(fMCHist_Fine2D); TH2D *tempcov = (TH2D *)input.Get("analysis1_totcov"); fFullCovar = new TMatrixDSym(tempcov->GetNbinsX()); for (int i = 0; i < tempcov->GetNbinsX(); i++) { for (int j = 0; j < tempcov->GetNbinsX(); j++) { (*fFullCovar)(i, j) = tempcov->GetBinContent(i + 1, j + 1); } } // Read in 2D Data Slices and Make MC Slices int bincount = 0; for (size_t i = 0; i < nangbins; i++) { fDataHist_Slices.push_back( (TH1D *)input.Get(Form("dataslice_%lu", i))->Clone()); fDataHist_Slices[i]->SetNameTitle( Form("T2K_CC0pi_XSec_2DPcos_nu_I_data_Slice%lu", i), (Form("T2K_CC0pi_XSec_2DPcos_nu_I_data_Slice%lu, cos(#theta) [%f,%f] ", i, angular_binning_costheta[i], angular_binning_costheta[i + 1]))); fDataHist_Slices.back()->SetDirectory(NULL); + fDataHist_Slices.back()->GetXaxis()->SetTitle("p_{#mu} (GeV)"); + fDataHist_Slices.back()->GetYaxis()->SetTitle(fSettings.GetYTitle().c_str()); // Loop over nbins and set errors from covar for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fDataHist_Slices[i]->SetBinError( j + 1, sqrt((*fFullCovar)(bincount, bincount)) * 1E-38); bincount++; } } assert(bincount == tempcov->GetNbinsX()); if (fMaskMomOverflow) { MaskMomOverflow(); bincount = fFullCovar->GetNcols(); } std::vector > data_slice_bcbes; for (size_t i = 0; i < nangbins; i++) { for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { data_slice_bcbes.push_back( std::make_pair(fDataHist_Slices[i]->GetBinContent(j + 1), fDataHist_Slices[i]->GetBinError(j + 1))); } } for (size_t i = 0; i < nangbins; i++) { fMCHist_Slices.push_back((TH1D *)fDataHist_Slices[i]->Clone()); fMCHist_Slices.back()->SetDirectory(NULL); fMCHist_Slices.back()->Reset(); fMCHist_Slices.back()->SetLineColor(kRed); fMCHist_Slices[i]->SetNameTitle( Form("T2K_CC0pi_XSec_2DPcos_nu_I_MC_Slice%lu", i), (Form("T2K_CC0pi_XSec_2DPcos_nu_I_MC_Slice%lu, cos(#theta) [%f,%f] ", i, angular_binning_costheta[i], angular_binning_costheta[i + 1]))); } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); - fDataHist = - new TH1D("T2K_CC0pi_XSec_2DPcos_nu_I_DATA_1D", - "T2K_CC0pi_XSec_2DPcos_nu_I_DATA_1D", bincount, 0, bincount); + fDataHist = new TH1D("T2K_CC0pi_XSec_2DPcos_nu_I_data_1D", + ("T2K_CC0pi_XSec_2DPcos_nu_I_data_1D"+fSettings.PlotTitles()).c_str(), + bincount, 0, bincount); fDataHist->SetDirectory(NULL); for (size_t i = 0; i < data_slice_bcbes.size(); ++i) { fDataHist->SetBinContent(i + 1, data_slice_bcbes[i].first); fDataHist->SetBinError(i + 1, data_slice_bcbes[i].second); } SetShapeCovar(); fMCHist = (TH1D *)fDataHist->Clone("T2K_CC0pi_XSec_2DPcos_nu_I_MC_1D"); fMCHist->SetDirectory(NULL); return; } void T2K_CC0pi_XSec_2DPcos_nu_I::MaskMomOverflow() { std::vector bins_to_cut; size_t nallbins = 0; for (size_t i = 0; i < nangbins; i++) { std::vector slice_bin_edges; slice_bin_edges.push_back( fDataHist_Slices[i]->GetXaxis()->GetBinLowEdge(1)); for (int j = 0; j < (fDataHist_Slices[i]->GetNbinsX() - 1); j++) { slice_bin_edges.push_back( fDataHist_Slices[i]->GetXaxis()->GetBinUpEdge(j + 1)); nallbins++; } bins_to_cut.push_back(nallbins++); TH1D *tmp = new TH1D(fDataHist_Slices[i]->GetName(), fDataHist_Slices[i]->GetTitle(), slice_bin_edges.size() - 1, slice_bin_edges.data()); tmp->SetDirectory(NULL); for (int j = 0; j < (fDataHist_Slices[i]->GetNbinsX() - 1); j++) { tmp->SetBinContent(j + 1, fDataHist_Slices[i]->GetBinContent(j + 1)); tmp->SetBinError(j + 1, fDataHist_Slices[i]->GetBinError(j + 1)); } delete fDataHist_Slices[i]; fDataHist_Slices[i] = tmp; } TMatrixDSym *tmpcovar = new TMatrixDSym(nallbins - bins_to_cut.size()); int icut = 0; for (int ifull = 0; ifull < fFullCovar->GetNcols(); ifull++) { if (std::find(bins_to_cut.begin(), bins_to_cut.end(), ifull) != bins_to_cut.end()) { continue; } int jcut = 0; for (int jfull = 0; jfull < fFullCovar->GetNcols(); jfull++) { if (std::find(bins_to_cut.begin(), bins_to_cut.end(), jfull) != bins_to_cut.end()) { continue; } (*tmpcovar)[icut][jcut] = (*fFullCovar)[ifull][jfull]; jcut++; } icut++; } delete fFullCovar; fFullCovar = tmpcovar; } void T2K_CC0pi_XSec_2DPcos_nu_I::Write(std::string drawopt) { this->Measurement1D::Write(drawopt); for (size_t i = 0; i < nangbins; i++) { fMCHist_Slices[i]->Write(); fDataHist_Slices[i]->Write(); } if (fResidualHist) { std::vector MCResidual_Slices; size_t tb_it = 0; for (size_t i = 0; i < fMCHist_Slices.size(); ++i) { std::string name = Form("T2K_CC0pi_XSec_2DPcos_nu_I_RESIDUAL_Slice%lu", i); MCResidual_Slices.push_back( static_cast(fMCHist_Slices[i]->Clone(name.c_str()))); MCResidual_Slices.back()->Reset(); for (int j = 0; j < fMCHist_Slices[i]->GetXaxis()->GetNbins(); ++j) { double bc = fResidualHist->GetBinContent(tb_it + 1); MCResidual_Slices.back()->SetBinContent(j + 1, bc); tb_it++; } MCResidual_Slices.back()->Write(); } } if (fChi2LessBinHist) { std::vector MCChi2LessBin_Slices; size_t tb_it = 0; for (size_t i = 0; i < fMCHist_Slices.size(); ++i) { std::string name = Form("T2K_CC0pi_XSec_2DPcos_nu_I_Chi2NMinusOne_Slice%lu", i); MCChi2LessBin_Slices.push_back( static_cast(fMCHist_Slices[i]->Clone(name.c_str()))); MCChi2LessBin_Slices.back()->Reset(); for (int j = 0; j < fMCHist_Slices[i]->GetXaxis()->GetNbins(); ++j) { double bc = fChi2LessBinHist->GetBinContent(tb_it + 1); MCChi2LessBin_Slices.back()->SetBinContent(j + 1, bc); tb_it++; } MCChi2LessBin_Slices.back()->Write(); } } } diff --git a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.h b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.h index 63f7a26..2f51ab0 100644 --- a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.h +++ b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_I.h @@ -1,74 +1,74 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PI_2DPCOS_NU_NONUNIFORM_H_SEEN #define T2K_CC0PI_2DPCOS_NU_NONUNIFORM_H_SEEN #include "Measurement1D.h" #include "MeasurementVariableBox2D.h" #include "TH2Poly.h" class T2K_CC0pi_XSec_2DPcos_nu_I : public Measurement1D { public: T2K_CC0pi_XSec_2DPcos_nu_I(nuiskey samplekey); /// Virtual Destructor ~T2K_CC0pi_XSec_2DPcos_nu_I(){}; /// Numu CC0PI Signal Definition /// /// /item bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. /// Read from /// FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root" void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent *customEvent); // Fill Histograms void FillHistograms(); /// Have to do a weird event scaling for analysis 1 void ConvertEventRates(); void Write(std::string drawopt); /// \brief Create Q2 Box to save correction info inline MeasurementVariableBox *CreateBox() { return new MeasurementVariableBox2D(); }; private: bool fIsSystCov, fIsStatCov, fIsNormCov; bool fMaskMomOverflow; int fMode; TH2D *fMCHist_Fine2D; std::vector fMCHist_Slices; std::map > fMCModeHists_Slices; std::vector fDataHist_Slices; void FillMCSlice(double x, double y, double w); void MaskMomOverflow(); }; #endif diff --git a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.cxx b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.cxx index ebfaa75..560e282 100644 --- a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.cxx +++ b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.cxx @@ -1,243 +1,137 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pi_XSec_2DPcos_nu_II.h" //******************************************************************** T2K_CC0pi_XSec_2DPcos_nu_II::T2K_CC0pi_XSec_2DPcos_nu_II(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pi_XSec_2DPcos_nu_II sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi with p_mu > 200 MeV\n" " cth_mu > 0 \n" "https://journals.aps.org/prd/abstract/10.1103/" "PhysRevD.93.112012 Analysis II"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("P_{#mu} (GeV)"); + fSettings.SetXTitle("p_{#mu} (GeV)"); fSettings.SetYTitle("cos#theta_{#mu}"); - fSettings.SetZTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetZTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("DIAG,FULL/FREE,SHAPE,FIX/SYSTCOV/STATCOV", "FIX"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("T2K_CC0pi_XSec_2DPcos_nu_II"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width") / (fNEvents + 0.)) * 1E-38 / (TotalIntegratedFlux())); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; bool T2K_CC0pi_XSec_2DPcos_nu_II::isSignal(FitEvent *event) { return SignalDef::isT2K_CC0pi(event, EnuMin, EnuMax, SignalDef::kAnalysis_II); }; void T2K_CC0pi_XSec_2DPcos_nu_II::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; }; void T2K_CC0pi_XSec_2DPcos_nu_II::SetHistograms() { - // fIsSystCov = fSettings.GetS("type").find("SYSTCOV") != std::string::npos; - // fIsStatCov = fSettings.GetS("type").find("STATCOV") != std::string::npos; - // fIsNormCov = fSettings.GetS("type").find("NORMCOV") != std::string::npos; fNDataPointsX = 12; fNDataPointsY = 10; // Open file std::string infile = FitPar::GetDataBase() + "/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root"; TFile *rootfile = new TFile(infile.c_str(), "READ"); TH2D *tempcov = (TH2D *)rootfile->Get("analysis2_totcov");; // Get Data fDataHist = (TH2D *)rootfile->Get("analysis2_data"); fDataHist->SetDirectory(0); fDataHist->SetNameTitle((fName + "_data").c_str(), - (fName + "_data" + fPlotTitles).c_str()); + (fName + "_data" + fSettings.GetFullTitles()).c_str()); // For some reason the error on the data in the data release is 1E-20 // That is wrong, so set it to zero here for (int i = 0; i < fDataHist->GetXaxis()->GetNbins() + 1; ++i) { for (int j = 0; j < fDataHist->GetYaxis()->GetNbins() + 1; ++j) { fDataHist->SetBinError(i + 1, j + 1, 0.0); } } - // Get Syst/Stat Covar - // TH2D *tempsyst = 0; - // rootfile->GetObject("analysis2_systcov", tempsyst); - // TH2D *tempstat = 0; - // rootfile->GetObject("analysis2_statcov", tempstat); - // TH2D *tempnorm = 0; - // rootfile->GetObject("analysis2_normcov", tempnorm); - - // if (!tempsyst) { - // NUIS_ABORT("tempsyst not found"); - // } - - // 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 nothing is set, add them all! - // if (!fIsSystCov && !fIsStatCov && !fIsNormCov) { - // tempcov->Add(tempsyst); - // tempcov->Add(tempstat); - // tempcov->Add(tempnorm); - // } - // Get Map TH2I *InputMap = (TH2I *)rootfile->Get("analysis2_map"); // This map doesn't skip over the 0 data/covar bins fMapHist = (TH2I *)InputMap->Clone(); fMapHist->SetDirectory(NULL); fMapHist->SetNameTitle((fName + "_map").c_str(), (fName + "_map" + fPlotTitles).c_str()); - // int binit = 1; - // for (int j = 0; j < fDataHist->GetYaxis()->GetNbins(); ++j) { - // for (int i = 0; i < fDataHist->GetXaxis()->GetNbins(); ++i) { - // int covarhistbin = InputMap->GetBinContent(i + 1, j + 1); - - // std::cout << "i: " << i << ", j: " << j - // << " -> covarhistbin: " << covarhistbin << " = " - // << tempcov->GetBinContent(covarhistbin, covarhistbin) - // << std::endl; - // if (tempcov->GetBinContent(covarhistbin, covarhistbin) > 0) { - // fMapHist->SetBinContent(i + 1, j + 1, binit++); - // } else { - // fMapHist->SetBinContent(i + 1, j + 1, 0); - // } - // } - // } - int nbins = fMapHist->GetMaximum(); fFullCovar = new TMatrixDSym(nbins); for (int i=0; i< nbins; ++i){ for (int j=0;j< nbins; ++j){ - std::cout << i << " " << j << " " << tempcov->GetBinContent(i+1, j+1) << std::endl; (*fFullCovar)(i, j) = tempcov->GetBinContent(i+1, j+1); } } - // for (int j_1 = 0; j_1 < fDataHist->GetYaxis()->GetNbins(); ++j_1) { - // for (int i_1 = 0; i_1 < fDataHist->GetXaxis()->GetNbins(); ++i_1) { - - // for (int j_2 = 0; j_2 < fDataHist->GetYaxis()->GetNbins(); ++j_2) { - // for (int i_2 = 0; i_2 < fDataHist->GetXaxis()->GetNbins(); ++i_2) { - - // int i = fMapHist->GetBinContent(i_1 + 1, j_1 + 1); - // int j = fMapHist->GetBinContent(i_2 + 1, j_2 + 1); - // if (i == 0 || j == 0) { - // continue; - // } - - // // get the relevant tempcov bin - // int i_input = InputMap->GetBinContent(i_1 + 1, j_1 + 1); - // int j_input = InputMap->GetBinContent(i_2 + 1, j_2 + 1); - - // std::cout << "i: " << i << ", j: " << j << "i_input: " << i_input - // << "j_input: " << j_input - // << ", covar = " << tempcov->GetBinContent(i_input, j_input) - // << std::endl; - - // // Correct for them being 1-offset; - // i -= 1; - // j -= 1; - - // (*fFullCovar)(i, j) = tempcov->GetBinContent(i_input, j_input); - - // if ((i == j) && ((*fFullCovar)(i, j) <= 0)) { - // NUIS_ABORT("Input covariance had a 0/negative diagonal element: " - // << i << ", " << j << ", " << (*fFullCovar)(i, j)); - // } - // } - // } - // } - // } - - // TFile *fout= new TFile("mattest.root","RECREATE"); - // fout->WriteTObject(fFullCovar,"covar"); - // fout->Write(); - // fout->Close(); - // Setup Covar - covar = StatUtils::GetInvert(fFullCovar); - - // for (int i = 0; i < nbins; i++) { - // for (int j = 0; j < nbins; j++) { - // if ((i == j) && ((*covar)(i, j) <= 0)) { - // NUIS_ABORT("Inverse covariance had a 0/negative diagonal element: " - // << i << ", " << j << ", " << (*covar)(i, j)); - // } - // } - // } - fDecomp = StatUtils::GetDecomp(covar); SetShapeCovar(); // Set Data Errors StatUtils::SetDataErrorFromCov(fDataHist, fFullCovar, fMapHist, 1E-38); // Remove root file rootfile->Close(); }; diff --git a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.h b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.h index a0c4503..281d32a 100644 --- a/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.h +++ b/src/T2K/T2K_CC0pi_XSec_2DPcos_nu_II.h @@ -1,49 +1,49 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PI_2DPCOS_NU_H_SEEN #define T2K_CC0PI_2DPCOS_NU_H_SEEN #include "Measurement2D.h" class T2K_CC0pi_XSec_2DPcos_nu_II : public Measurement2D { public: /// Basic Constructor. T2K_CC0pi_XSec_2DPcos_nu_II(nuiskey samplekey); /// Virtual Destructor ~T2K_CC0pi_XSec_2DPcos_nu_II(){}; /// Numu CC0PI Signal Definition /// /// /item bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. /// Read from /// FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root" void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent *customEvent); private: bool fIsSystCov, fIsStatCov, fIsNormCov; }; #endif diff --git a/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.cxx b/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.cxx index ab45c12..5a3ba37 100755 --- a/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.cxx +++ b/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.cxx @@ -1,190 +1,199 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pi_XSec_H2O_2DPcos_anu.h" static size_t nmombins = 7; static double mom_binning[] = { 400., 530., 670., 800., 1000., 1380., 2010., 3410. }; static int ncosbins[] = { 2, 3, 3, 3, 3, 3, 2 }; static double costheta_binning[][7] = { { 0.84, 0.94, 1. }, { 0.85, 0.92, 0.96, 1. }, { 0.88, 0.93, 0.97, 1. }, { 0.90, 0.94, 0.97, 1. }, { 0.91, 0.95, 0.97, 1. }, { 0.92, 0.96, 0.98, 1. }, { 0.95, 0.98, 1. } }; //******************************************************************** T2K_CC0pi_XSec_H2O_2DPcos_anu::T2K_CC0pi_XSec_H2O_2DPcos_anu(nuiskey samplekey) { //******************************************************************** + // Don't use the FINE histogram + fSaveFine = false; + // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pi_XSec_H2O_2DPcos_anu. \n" "Target: H2O \n" "Flux: T2K 2.5 degree off-axis (ND280-P0D) \n" "Signal: CC0pi\n" "arXiv:1908.10249"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("cos#theta_{#mu}-p_{#mu}"); + fSettings.SetXTitle("cos#theta_{#mu}-p_{#mu} (GeV)"); fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV","FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("H,O"); // CCQELike plot information fSettings.SetTitle("T2K_CC0pi_XSec_H2O_2DPcos_anu"); fSettings.DefineAllowedSpecies("numub"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/water molecule fScaleFactor = ((GetEventHistogram()->Integral("weight")/(fNEvents+0.)) * 18E-38 / (TotalIntegratedFlux(""))); // Setup Histograms SetHistograms(); // Final setup FinaliseMeasurement(); }; bool T2K_CC0pi_XSec_H2O_2DPcos_anu::isSignal(FitEvent *event){ return SignalDef::isT2K_CC0piAnuP0D(event, EnuMin, EnuMax); }; void T2K_CC0pi_XSec_H2O_2DPcos_anu::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(); double CosThetaMu = cos(Pnu.Vect().Angle(Pmu.Vect())); fXVar = pmu; fYVar = CosThetaMu; return; }; void T2K_CC0pi_XSec_H2O_2DPcos_anu::FillHistograms(){ Measurement1D::FillHistograms(); if (Signal){ FillMCSlice( fXVar, fYVar, Weight ); } } // 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_H2O_2DPcos_anu::ConvertEventRates(){ for (size_t i = 0; i < nmombins; i++){ fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); for (size_t i = 0; i < nmombins; ++i) { fMCHist_Slices[i]->Scale(1. / (mom_binning[i + 1] - mom_binning[i])); } // Now Convert into 1D list fMCHist->Reset(); int bincount = 0; for (size_t i = 0; i < nmombins; i++){ for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++){ fMCHist->SetBinContent(bincount+1, fMCHist_Slices[i]->GetBinContent(j+1)); bincount++; } } return; } void T2K_CC0pi_XSec_H2O_2DPcos_anu::FillMCSlice(double x, double y, double w){ for (size_t i = 0; i < nmombins; ++i) { if ((x > mom_binning[i]) && (x <= mom_binning[i + 1])) { fMCHist_Slices[i]->Fill(y, w); } } } void T2K_CC0pi_XSec_H2O_2DPcos_anu::SetHistograms(){ // Read in 1D Data Histograms fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/AntiNuMuH2O/AntiNuMuOnH2O_unreg.root").c_str(),"READ"); + fPlotTitles = fSettings.GetFullTitles(); // Read in 1D Data fDataHist = (TH1D*) fInputFile->Get("xsecDataRelease"); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data" + fPlotTitles).c_str()); int Nbins = fDataHist->GetNbinsX(); // Read relative covariance matrix TH2D* tempcov = (TH2D*) fInputFile->Get("covDataRelease"); // Make absolute covariance matrix 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)*fDataHist->GetBinContent(i+1)*fDataHist->GetBinContent(j+1)*1E76; } } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); // Read in 2D Data Slices and Make MC Slices int bincount = 0; for (uint i = 0; i < nmombins; ++i) { - fDataHist_Slices.push_back(new TH1D(Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_data_Slice%u",i),Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_data_Slice%u",i),ncosbins[i],costheta_binning[i])); + fDataHist_Slices.push_back(new TH1D(Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_data_Slice%u",i), + Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_data_Slice%u",i), + ncosbins[i],costheta_binning[i])); + fDataHist_Slices[i]->GetXaxis()->SetTitle("cos#theta_{#mu}"); + fDataHist_Slices[i]->GetYaxis()->SetTitle(fSettings.GetYTitle().c_str()); + for (int j = 0; j < ncosbins[i]; ++j) { fDataHist->SetBinError(bincount+1,sqrt((*fFullCovar)(bincount,bincount))*1E-38); fDataHist_Slices[i]->SetBinContent(j+1, fDataHist->GetBinContent(bincount+1)); fDataHist_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); bincount++; } fMCHist_Slices.push_back((TH1D*) fDataHist_Slices[i]->Clone()); fMCHist_Slices[i]->SetNameTitle(Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_MC_Slice%u",i), - (Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_MC_Slice%u",i))); + (Form("T2K_CC0pi_XSec_H2O_2DPcos_anu_MC_Slice%u",i))); SetAutoProcessTH1(fDataHist_Slices[i],kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); } return; }; diff --git a/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.h b/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.h index 69a4a49..424e3d2 100755 --- a/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.h +++ b/src/T2K/T2K_CC0pi_XSec_H2O_2DPcos_anu.h @@ -1,62 +1,62 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PI_2DPCOS_H2O_ANU_H_SEEN #define T2K_CC0PI_2DPCOS_H2O_ANU_H_SEEN #include "Measurement1D.h" #include "TH2Poly.h" #include "MeasurementVariableBox2D.h" class T2K_CC0pi_XSec_H2O_2DPcos_anu : public Measurement1D { public: // Basic Constructor. T2K_CC0pi_XSec_H2O_2DPcos_anu(nuiskey samplekey); // Virtual Destructor ~T2K_CC0pi_XSec_H2O_2DPcos_anu() {}; // Signal Definition bool isSignal(FitEvent *nvect); // Read histograms void SetHistograms(); // Bin Pmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); /// Event scaling void ConvertEventRates(); private: TFile* fInputFile; std::vector fMCHist_Slices; std::vector fDataHist_Slices; double pmu, CosThetaMu; void FillMCSlice(double x, double y, double w); }; #endif diff --git a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.cxx b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.cxx index 89fedf4..bf7c891 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.cxx +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_STV_XSec_1Ddat_nu.h" //******************************************************************** T2K_CC0pinp_STV_XSec_1Ddat_nu::T2K_CC0pinp_STV_XSec_1Ddat_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pinp_STV_XSec_1Ddpt_nu sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0piNp (N>=1) with 450 MeV < p_p < 1 GeV \n" " p_mu > 250 MeV \n" " cth_p > 0.4 \n" " cth_mu > -0.6 \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#delta#it{#alpha}_{T} (rad.)"); fSettings.SetYTitle( "#frac{d#sigma}{d#delta#it{#alpha}_{T}} (cm^{2} nucleon^{-1} rad.^{-1})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 50.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("T2K_CC0pinp_STV_XSec_1Ddat_nu"); // fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + // "/data/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.dat"); fSettings.SetDataInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/datResults.root;Result"); fSettings.SetCovarInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/datResults.root;Correlation_Matrix"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / (double(fNEvents) * TotalIntegratedFlux("width")); // Plot Setup ------------------------------------------------------- // SetDataFromTextFile( fSettings.GetDataInput() ); // ScaleData(1E-38); // SetCovarFromDiagonal(); SetDataFromRootFile(fSettings.GetDataInput()); SetCorrelationFromRootFile(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void T2K_CC0pinp_STV_XSec_1Ddat_nu::FillEventVariables(FitEvent *event) { fXVar = FitUtils::Get_STV_dalphat_HMProton(event, 14, true); return; }; //******************************************************************** bool T2K_CC0pinp_STV_XSec_1Ddat_nu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isT2K_CC0pi_STV(event, EnuMin, EnuMax); } diff --git a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.h b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.h index 2387936..6ff193a 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.h +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddat_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0pinp_STV_XSec_1Ddat_nu_H_SEEN #define T2K_CC0pinp_STV_XSec_1Ddat_nu_H_SEEN #include "Measurement1D.h" class T2K_CC0pinp_STV_XSec_1Ddat_nu : public Measurement1D { public: T2K_CC0pinp_STV_XSec_1Ddat_nu(nuiskey samplekey); virtual ~T2K_CC0pinp_STV_XSec_1Ddat_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.cxx b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.cxx index e7e88cb..8e126f3 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.cxx +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_STV_XSec_1Ddphit_nu.h" //******************************************************************** T2K_CC0pinp_STV_XSec_1Ddphit_nu::T2K_CC0pinp_STV_XSec_1Ddphit_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pinp_STV_XSec_1Ddpt_nu sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0piNp (N>=1) with 450 MeV < p_p < 1 GeV \n" " p_mu > 250 MeV \n" " cth_p > 0.4 \n" " cth_mu > -0.6 \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#delta#it{#phi}_{T} (rad.)"); fSettings.SetYTitle( "#frac{d#sigma}{d#delta#it{#phi}_{T}} (cm^{2} nucleon^{-1} rad.^{-1})"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 50.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("T2K_CC0pinp_STV_XSec_1Ddphit_nu"); // fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + // "/data/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.dat"); fSettings.SetDataInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/dphitResults.root;Result"); fSettings.SetCovarInput( FitPar::GetDataBase() + "/T2K/CC0pi/STV/dphitResults.root;Correlation_Matrix"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / (double(fNEvents) * TotalIntegratedFlux("width")); // Plot Setup ------------------------------------------------------- // SetDataFromTextFile( fSettings.GetDataInput() ); // ScaleData(1E-38); // SetCovarFromDiagonal(); SetDataFromRootFile(fSettings.GetDataInput()); SetCorrelationFromRootFile(fSettings.GetCovarInput()); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void T2K_CC0pinp_STV_XSec_1Ddphit_nu::FillEventVariables(FitEvent *event) { fXVar = FitUtils::Get_STV_dphit_HMProton(event, 14, true); return; }; //******************************************************************** bool T2K_CC0pinp_STV_XSec_1Ddphit_nu::isSignal(FitEvent *event) //******************************************************************** { return SignalDef::isT2K_CC0pi_STV(event, EnuMin, EnuMax); } diff --git a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.h b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.h index de4ab66..cf3922f 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.h +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddphit_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0pinp_STV_XSec_1Ddphit_nu_H_SEEN #define T2K_CC0pinp_STV_XSec_1Ddphit_nu_H_SEEN #include "Measurement1D.h" class T2K_CC0pinp_STV_XSec_1Ddphit_nu : public Measurement1D { public: T2K_CC0pinp_STV_XSec_1Ddphit_nu(nuiskey samplekey); virtual ~T2K_CC0pinp_STV_XSec_1Ddphit_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx index e61d59b..af82327 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.cxx @@ -1,90 +1,90 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_STV_XSec_1Ddpt_nu.h" //******************************************************************** T2K_CC0pinp_STV_XSec_1Ddpt_nu::T2K_CC0pinp_STV_XSec_1Ddpt_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pinp_STV_XSec_1Ddpt_nu sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0piNp (N>=1) with 450 MeV < p_p < 1 GeV \n" " p_mu > 250 MeV \n" " cth_p > 0.4 \n" " cth_mu > -0.6 \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); fSettings.SetXTitle("#delta#it{p}_{T} (GeV c^{-1})"); fSettings.SetYTitle( "#frac{d#sigma}{d#delta#it{p}_{T}} (cm^{2} nucleon^{-1} GeV^{-1} c)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 50.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("T2K_CC0pinp_STV_XSec_1Ddpt_nu"); // fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + // "/data/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.dat"); fSettings.SetDataInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/dptResults.root;Result"); fSettings.SetCovarInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/dptResults.root;Correlation_Matrix"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * double(1E-38) / (double(fNEvents) * TotalIntegratedFlux("width")); // Plot Setup ------------------------------------------------------- // SetDataFromTextFile( fSettings.GetDataInput() ); // SetCovarFromDiagonal(); // ScaleData(1E-38); SetDataFromRootFile(fSettings.GetDataInput()); SetCorrelationFromRootFile(fSettings.GetCovarInput()); // SetCovarianceFromRootFile(fSettings.GetCovarInput() ); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void T2K_CC0pinp_STV_XSec_1Ddpt_nu::FillEventVariables(FitEvent *event) { fXVar = FitUtils::Get_STV_dpt_HMProton(event, 14, true)*1E-3; 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_CC0pinp_STV_XSec_1Ddpt_nu.h b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.h index a83e260..9912f73 100644 --- a/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.h +++ b/src/T2K/T2K_CC0pinp_STV_XSec_1Ddpt_nu.h @@ -1,35 +1,35 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0pinp_STV_XSec_1Ddpt_nu_H_SEEN #define T2K_CC0pinp_STV_XSec_1Ddpt_nu_H_SEEN #include "Measurement1D.h" class T2K_CC0pinp_STV_XSec_1Ddpt_nu : public Measurement1D { public: T2K_CC0pinp_STV_XSec_1Ddpt_nu(nuiskey samplekey); virtual ~T2K_CC0pinp_STV_XSec_1Ddpt_nu() {}; void FillEventVariables(FitEvent *event); bool isSignal(FitEvent *event); }; #endif diff --git a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.cxx b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.cxx index 93513fe..a2fe748 100644 --- a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.cxx +++ b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.cxx @@ -1,229 +1,205 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h" //******************************************************************** T2K_CC0pinp_ifk_XSec_3Dinfa_nu::T2K_CC0pinp_ifk_XSec_3Dinfa_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pinp_ifk_XSec_3Dinfa_nu sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0piNp (N>=1) with p_p>450MeV and cthp>0.4 \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n"; + // This sample corresponds to the #Delta#theta variable + // #Delta#theta = #theta_{p}^{measured} - #theta_{p}^{inferred} + // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("#Delta #theta"); - fSettings.SetYTitle("p_#mu"); - fSettings.SetZTitle("cos#theta_{#mu}"); - // fSettings.SetZTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetXTitle("#Delta #theta_{p};p_{#mu}-cos#theta_{#mu}"); + fSettings.SetYTitle("d^{2}#sigma/d#Delta#theta dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fAnalysis = 1; outOfBoundsMC = 0.0; // CCQELike plot information fSettings.SetTitle("T2K_CC0pinp_ifk_XSec_3Dinfa_nu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width") / (fNEvents + 0.)) / (TotalIntegratedFlux())); - // fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * 10 - // / (TotalIntegratedFlux())); fSettings.SetDataInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root;result_a"); SetDataFromRootFile(fSettings.GetDataInput()); fSettings.SetCovarInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root;cor_a"); SetCorrelationFromRootFile(fSettings.GetCovarInput()); - // SetCovarFromRootFile(FitPar::GetDataBase() + - // "/T2K/CC0pi/infkResults_origBin.root", "cov_a" ); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; bool T2K_CC0pinp_ifk_XSec_3Dinfa_nu::isSignal(FitEvent *event) { return SignalDef::isT2K_CC0pi_ifk(event, EnuMin, EnuMax); }; void T2K_CC0pinp_ifk_XSec_3Dinfa_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(2212) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double pmu = Pmu.Vect().Mag() / 1000.; - // double pp = Pp.Vect().Mag()/1000.; double CosThetaMu = cos(Pnu.Vect().Angle(Pmu.Vect())); double CosThetaP = cos(Pnu.Vect().Angle(Pp.Vect())); double infp_CosThetaP = FitUtils::cthpInfK(Pmu, CosThetaMu, 25, true); double delta_a = acos(CosThetaP) * 180 / TMath::Pi() - acos(infp_CosThetaP) * 180 / TMath::Pi(); - // std::cout << "CosTheta P is: " << CosThetaP << std::endl; - // std::cout << "Inferred CosTheta P is: " << infp_CosThetaP << std::endl << - // std::endl; - - /* - TVector3 tp_inf = FitUtils::tppInfK(Pmu, CosThetaMu, 25, true); - - //std::cout << "Theta P is: " << (Pp.Vect()).Theta() << std::endl; - //std::cout << "Inferred Theta P is: " << tp_inf.Theta() << std::endl << - std::endl; - - double delta_a = (Pp.Vect()).Theta()*180/TMath::Pi() - - tp_inf.Theta()*180/TMath::Pi(); - - */ - fXVar = delta_a; fYVar = pmu; fZVar = CosThetaMu; return; }; void T2K_CC0pinp_ifk_XSec_3Dinfa_nu::FillHistograms() { Measurement1D::FillHistograms(); if (Signal) { FillMCSlice(fXVar, fYVar, fZVar, Weight); } } void T2K_CC0pinp_ifk_XSec_3Dinfa_nu::ConvertEventRates() { for (int i = 0; i < 7; i++) { fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); // First scale MC slices also by their width in Y and Z // MCHist_Slices[0]->Scale(1.0 / 1.00); // MCHist_Slices[1]->Scale(1.0 / 0.60); // MCHist_Slices[2]->Scale(1.0 / 0.10); // MCHist_Slices[3]->Scale(1.0 / 0.10); // Now Convert into 1D list fMCHist->Reset(); // The first bin in the histogram in underflow, so set this and start bincount // at 1 fMCHist->SetBinContent(1, outOfBoundsMC); int bincount = 1; for (int i = 0; i < 7; i++) { for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fMCHist->SetBinContent(bincount + 1, fMCHist_Slices[i]->GetBinContent(j + 1)); // fMCHist->SetBinError(bincount+1, fMCHist_Slices[i]->GetBinError(j+1)); bincount++; } } return; } void T2K_CC0pinp_ifk_XSec_3Dinfa_nu::FillMCSlice(double x, double y, double z, double w) { // x is delta_a // y is pmu // z is CosThetaMu if (z <= -0.6) fMCHist_Slices[0]->Fill(x, w); else if (z >= -0.6 and z < 0.0 and y < 0.25) fMCHist_Slices[1]->Fill(x, w); else if (z >= -0.6 and z < 0.0 and y > 0.25) fMCHist_Slices[2]->Fill(x, w); else if (z >= 0.0 and y < 0.25) fMCHist_Slices[3]->Fill(x, w); else if (z >= 0.0 and z < 0.8 and y >= 0.25) fMCHist_Slices[4]->Fill(x, w); else if (z >= 0.8 and z < 1.0 and y >= 0.25 and y < 0.75) fMCHist_Slices[5]->Fill(x, w); else if (z >= 0.8 and z < 1.0 and y >= 0.75) fMCHist_Slices[6]->Fill(x, w); else outOfBoundsMC += w; } void T2K_CC0pinp_ifk_XSec_3Dinfa_nu::SetHistograms() { + std::string name = fSettings.GetName(); + // Read in 1D Data Histograms fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root") - .c_str(), - "READ"); - // fInputFile->ls(); - - // Read in 1D Data - fDataHist = (TH1D *)fInputFile->Get("result_a"); - fDataHist->SetNameTitle("T2K_CC0pinp_ifk_XSec_3Dinfa_nu_data", - "T2K_CC0pinp_ifk_XSec_3Dinfa_nu_data"); - SetAutoProcessTH1(fDataHist, kCMD_Write); + .c_str(), "READ"); // Read in 2D Data Slices and Make MC Slices for (int i = 0; i < 7; i++) { // both y and z slices // Get Data Histogram - // fInputFile->ls(); fDataHist_Slices.push_back( (TH1D *)fInputFile->Get(Form("resultBin%i_a", i))->Clone()); fDataHist_Slices[i]->SetNameTitle( - Form("T2K_CC0pinp_ifk_XSec_3Dinfa_nu_data_Slice%i", i), - (Form("T2K_CC0pinp_ifk_XSec_3Dinfa_nu_data_Slice%i", i))); + Form("%s_data_Slice%i", name.c_str(), i), + Form("%s_data_Slice%i;#Delta #theta_{p};%s", + name.c_str(), i, fSettings.GetYTitle().c_str())); // Make MC Clones fMCHist_Slices.push_back((TH1D *)fDataHist_Slices[i]->Clone()); fMCHist_Slices[i]->SetNameTitle( - Form("T2K_CC0pinp_ifk_XSec_3Dinfa_nu_MC_Slice%i", i), - (Form("T2K_CC0pinp_ifk_XSec_3Dinfa_nu_MC_Slice%i", i))); + Form("%s_MC_Slice%i", name.c_str(), i), + Form("%s_MC_Slice%i;#Delta #theta_{p};%s", + name.c_str(), i, fSettings.GetYTitle().c_str())); SetAutoProcessTH1(fDataHist_Slices[i], kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); fMCHist_Slices[i]->Reset(); } return; }; diff --git a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h index e3f48a3..0ef5014 100644 --- a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h +++ b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfa_nu.h @@ -1,73 +1,73 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PINP_IFK_XSEC_3DINFA_NU_H_SEEN #define T2K_CC0PINP_IFK_XSEC_3DINFA_NU_H_SEEN #include "Measurement1D.h" class T2K_CC0pinp_ifk_XSec_3Dinfa_nu : public Measurement1D { public: /// Basic Constructor. T2K_CC0pinp_ifk_XSec_3Dinfa_nu(nuiskey samplekey); /// Virtual Destructor ~T2K_CC0pinp_ifk_XSec_3Dinfa_nu() {}; /// Numu CC0PI Signal Definition /// /// /item bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. /// Read from FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root" void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); /// Have to do a weird event scaling for analysis 1 void ConvertEventRates(); private: bool only_allowed_particles; bool numu_event; double numu_energy; int particle_pdg; double pmu, CosThetaMu; int fAnalysis; double outOfBoundsMC; bool fIsSystCov, fIsStatCov, fIsNormCov; TFile* fInputFile; std::vector fMCHist_Slices; std::vector fDataHist_Slices; void FillMCSlice(double x, double y, double z, double w); }; #endif diff --git a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.cxx b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.cxx index 701aa3f..438fe8b 100644 --- a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.cxx +++ b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.cxx @@ -1,217 +1,203 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h" //******************************************************************** T2K_CC0pinp_ifk_XSec_3Dinfip_nu::T2K_CC0pinp_ifk_XSec_3Dinfip_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pinp_ifk_XSec_3Dinfip_nu sample. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0piNp (N>=1) with p_p>450MeV and cthp>0.4 \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n"; + // This sample corresponds to the |#Delta p| variable + // #Delta p = |p_{p}^{measured} - p_{p}^{inferred}| + // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("|#Delta p|"); - fSettings.SetYTitle("p_#mu"); - fSettings.SetZTitle("cos#theta_{#mu}"); - // fSettings.SetZTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetXTitle("|#Delta #vec{p}|-p_{#mu}-cos#theta_{#mu}"); + fSettings.SetYTitle("d^{2}#sigma/d|#Delta #vec{p}|dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV", "FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fAnalysis = 1; outOfBoundsMC = 0.0; // CCQELike plot information fSettings.SetTitle("T2K_CC0pinp_ifk_XSec_3Dinfip_nu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width") / (fNEvents + 0.)) / (TotalIntegratedFlux())); - // fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * 10 - // / (TotalIntegratedFlux())); fSettings.SetDataInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root;result_tp"); SetDataFromRootFile(fSettings.GetDataInput()); fSettings.SetCovarInput(FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root;cor_tp"); SetCorrelationFromRootFile(fSettings.GetCovarInput()); - // SetCovarFromRootFile(FitPar::GetDataBase() + - // "/T2K/CC0pi/infkResults_origBin.root", "cov_tp" ); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; bool T2K_CC0pinp_ifk_XSec_3Dinfip_nu::isSignal(FitEvent *event) { return SignalDef::isT2K_CC0pi_ifk(event, EnuMin, EnuMax); }; void T2K_CC0pinp_ifk_XSec_3Dinfip_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(2212) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double pmu = Pmu.Vect().Mag() / 1000.; - // double pp = Pp.Vect().Mag()/1000.; double CosThetaMu = cos(Pnu.Vect().Angle(Pmu.Vect())); TVector3 tp_inf = FitUtils::tppInfK(Pmu, CosThetaMu, 25, true); TVector3 Pp_mev(Pp.X() / 1000, Pp.Y() / 1000, Pp.Z() / 1000); TVector3 delta_tp = tp_inf - Pp_mev; - // std::cout << "Proton 3 mom is: " << std::endl; - //(Pp.Vect()).Print("all"); - // std::cout << "Inferred Proton 3 mom is: " << std::endl; - // tp_inf.Print("all"); - // std::cout << " " << std::endl; - fXVar = delta_tp.Mag(); fYVar = pmu; fZVar = CosThetaMu; return; }; void T2K_CC0pinp_ifk_XSec_3Dinfip_nu::FillHistograms() { Measurement1D::FillHistograms(); if (Signal) { FillMCSlice(fXVar, fYVar, fZVar, Weight); } } void T2K_CC0pinp_ifk_XSec_3Dinfip_nu::ConvertEventRates() { for (int i = 0; i < 7; i++) { fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); // First scale MC slices also by their width in Y and Z // MCHist_Slices[0]->Scale(1.0 / 1.00); // MCHist_Slices[1]->Scale(1.0 / 0.60); // MCHist_Slices[2]->Scale(1.0 / 0.10); // MCHist_Slices[3]->Scale(1.0 / 0.10); // Now Convert into 1D list fMCHist->Reset(); // The first bin in the histogram in underflow, so set this and start bincount // at 1 fMCHist->SetBinContent(1, outOfBoundsMC); int bincount = 1; for (int i = 0; i < 7; i++) { for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fMCHist->SetBinContent(bincount + 1, fMCHist_Slices[i]->GetBinContent(j + 1)); // fMCHist->SetBinError(bincount+1, fMCHist_Slices[i]->GetBinError(j+1)); bincount++; } } return; } void T2K_CC0pinp_ifk_XSec_3Dinfip_nu::FillMCSlice(double x, double y, double z, double w) { // x is delta_tp // y is pmu // z is CosThetaMu if (z <= -0.6) fMCHist_Slices[0]->Fill(x, w); else if (z >= -0.6 and z < 0.0 and y < 0.25) fMCHist_Slices[1]->Fill(x, w); else if (z >= -0.6 and z < 0.0 and y > 0.25) fMCHist_Slices[2]->Fill(x, w); else if (z >= 0.0 and y < 0.25) fMCHist_Slices[3]->Fill(x, w); else if (z >= 0.0 and z < 0.8 and y >= 0.25) fMCHist_Slices[4]->Fill(x, w); else if (z >= 0.8 and z < 1.0 and y >= 0.25 and y < 0.75) fMCHist_Slices[5]->Fill(x, w); else if (z >= 0.8 and z < 1.0 and y >= 0.75) fMCHist_Slices[6]->Fill(x, w); else outOfBoundsMC += w; } void T2K_CC0pinp_ifk_XSec_3Dinfip_nu::SetHistograms() { + std::string name = fSettings.GetName(); + // Read in 1D Data Histograms fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root") - .c_str(), - "READ"); - // fInputFile->ls(); - - // Read in 1D Data - fDataHist = (TH1D *)fInputFile->Get("result_tp"); - fDataHist->SetNameTitle("T2K_CC0pinp_ifk_XSec_3Dinfip_nu_data", - "T2K_CC0pinp_ifk_XSec_3Dinfip_nu_data"); - SetAutoProcessTH1(fDataHist, kCMD_Write); + .c_str(), "READ"); // Read in 2D Data Slices and Make MC Slices for (int i = 0; i < 7; i++) { // both y and z slices // Get Data Histogram - // fInputFile->ls(); fDataHist_Slices.push_back( (TH1D *)fInputFile->Get(Form("resultBin%i_tp", i))->Clone()); fDataHist_Slices[i]->SetNameTitle( - Form("T2K_CC0pinp_ifk_XSec_3Dinfip_nu_data_Slice%i", i), - (Form("T2K_CC0pinp_ifk_XSec_3Dinfip_nu_data_Slice%i", i))); + Form("%s_data_Slice%i", name.c_str(), i), + Form("%s_data_Slice%i;|#Delta #vec{p}| (GeV);%s", + name.c_str(), i, fSettings.GetYTitle().c_str())); // Make MC Clones fMCHist_Slices.push_back((TH1D *)fDataHist_Slices[i]->Clone()); fMCHist_Slices[i]->SetNameTitle( - Form("T2K_CC0pinp_ifk_XSec_3Dinfip_nu_MC_Slice%i", i), - (Form("T2K_CC0pinp_ifk_XSec_3Dinfip_nu_MC_Slice%i", i))); + Form("%s_MC_Slice%i", name.c_str(), i), + Form("%s_MC_Slice%i;|#Delta #vec{p}| (GeV);%s", + name.c_str(), i, fSettings.GetYTitle().c_str())); SetAutoProcessTH1(fDataHist_Slices[i], kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); fMCHist_Slices[i]->Reset(); } return; }; diff --git a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h index 5aad958..8ea8cb8 100644 --- a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h +++ b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfip_nu.h @@ -1,73 +1,73 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PINP_IFK_XSEC_3DINFIP_NU_H_SEEN #define T2K_CC0PINP_IFK_XSEC_3DINFIP_NU_H_SEEN #include "Measurement1D.h" class T2K_CC0pinp_ifk_XSec_3Dinfip_nu : public Measurement1D { public: /// Basic Constructor. T2K_CC0pinp_ifk_XSec_3Dinfip_nu(nuiskey samplekey); /// Virtual Destructor ~T2K_CC0pinp_ifk_XSec_3Dinfip_nu() {}; /// Numu CC0PI Signal Definition /// /// /item bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. /// Read from FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root" void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); /// Have to do a weird event scaling for analysis 1 void ConvertEventRates(); private: bool only_allowed_particles; bool numu_event; double numu_energy; int particle_pdg; double pmu, CosThetaMu; int fAnalysis; double outOfBoundsMC; bool fIsSystCov, fIsStatCov, fIsNormCov; TFile* fInputFile; std::vector fMCHist_Slices; std::vector fDataHist_Slices; void FillMCSlice(double x, double y, double z, double w); }; #endif diff --git a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.cxx b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.cxx index c5a3fc3..bb5a44c 100644 --- a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.cxx +++ b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.cxx @@ -1,188 +1,187 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h" //******************************************************************** T2K_CC0pinp_ifk_XSec_3Dinfp_nu::T2K_CC0pinp_ifk_XSec_3Dinfp_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC0pinp_ifk_XSec_3Dinfp_nu sample. \n" \ "Target: CH \n" \ "Flux: T2K 2.5 degree off-axis (ND280) \n" \ "Signal: CC0piNp (N>=1) with p_p>450MeV and cthp>0.4 \n" "https://doi.org/10.1103/PhysRevD.98.032003 \n"; + + // This sample corresponds to the #Delta p variable + // #Delta p = |p_{p}^{measured}| - |p_{p}^{inferred}| // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle("#Delta p"); - fSettings.SetYTitle("p_#mu"); - fSettings.SetZTitle("cos#theta_{#mu}"); - //fSettings.SetZTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetXTitle("#Delta p-p_{#mu}-cos#theta_{#mu}"); + fSettings.SetYTitle("d^{2}#sigma/d#Delta pdp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV^{2})"); fSettings.SetAllowedTypes("FULL,DIAG/FREE,SHAPE,FIX/SYSTCOV/STATCOV","FIX/FULL"); fSettings.SetEnuRange(0.0, 10.0); fSettings.DefineAllowedTargets("C,H"); fAnalysis = 1; outOfBoundsMC = 0.0; // CCQELike plot information fSettings.SetTitle("T2K_CC0pinp_ifk_XSec_3Dinfp_nu"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) / (TotalIntegratedFlux())); - //fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * 10 / (TotalIntegratedFlux())); fSettings.SetDataInput( FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root;result_p" ); SetDataFromRootFile( fSettings.GetDataInput() ); fSettings.SetCovarInput( FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root;cor_p" ); SetCorrelationFromRootFile(fSettings.GetCovarInput() ); - //SetCovarFromRootFile(FitPar::GetDataBase() + "/T2K/CC0pi/infkResults_origBin.root", "cov_p" ); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; bool T2K_CC0pinp_ifk_XSec_3Dinfp_nu::isSignal(FitEvent *event){ return SignalDef::isT2K_CC0pi_ifk(event, EnuMin, EnuMax); }; void T2K_CC0pinp_ifk_XSec_3Dinfp_nu::FillEventVariables(FitEvent* event){ if (event->NumFSParticle(13) == 0 || event->NumFSParticle(2212) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Pp = event->GetHMFSParticle(2212)->fP; double pmu = Pmu.Vect().Mag()/1000.; double CosThetaMu = cos(Pnu.Vect().Angle(Pmu.Vect())); double delta_p = Pp.Vect().Mag()/1000. - FitUtils::ppInfK(Pmu, CosThetaMu, 25, true); fXVar = delta_p; fYVar = pmu; fZVar = CosThetaMu; return; }; void T2K_CC0pinp_ifk_XSec_3Dinfp_nu::FillHistograms(){ Measurement1D::FillHistograms(); if (Signal){ FillMCSlice( fXVar, fYVar, fZVar, Weight ); } } void T2K_CC0pinp_ifk_XSec_3Dinfp_nu::ConvertEventRates(){ for (int i = 0; i < 7; i++){ fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); // First scale MC slices also by their width in Y and Z //MCHist_Slices[0]->Scale(1.0 / 1.00); //MCHist_Slices[1]->Scale(1.0 / 0.60); //MCHist_Slices[2]->Scale(1.0 / 0.10); //MCHist_Slices[3]->Scale(1.0 / 0.10); // Now Convert into 1D list fMCHist->Reset(); //The first bin in the histogram in underflow, so set this and start bincount at 1 fMCHist->SetBinContent(1, outOfBoundsMC); int bincount = 1; for (int i = 0; i < 7; i++){ for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++){ fMCHist->SetBinContent(bincount+1, fMCHist_Slices[i]->GetBinContent(j+1)); //fMCHist->SetBinError(bincount+1, fMCHist_Slices[i]->GetBinError(j+1)); bincount++; } } return; } void T2K_CC0pinp_ifk_XSec_3Dinfp_nu::FillMCSlice(double x, double y, double z, double w){ // x is delta_p // y is pmu // z is CosThetaMu if (z <= -0.6) fMCHist_Slices[0]->Fill(x,w); else if (z >= -0.6 and z < 0.0 and y < 0.25) fMCHist_Slices[1]->Fill(x,w); else if (z >= -0.6 and z < 0.0 and y > 0.25) fMCHist_Slices[2]->Fill(x,w); else if (z >= 0.0 and y < 0.25) fMCHist_Slices[3]->Fill(x,w); else if (z >= 0.0 and z < 0.8 and y >= 0.25) fMCHist_Slices[4]->Fill(x,w); else if (z >= 0.8 and z < 1.0 and y >= 0.25 and y < 0.75) fMCHist_Slices[5]->Fill(x,w); else if (z >= 0.8 and z < 1.0 and y >= 0.75) fMCHist_Slices[6]->Fill(x,w); else outOfBoundsMC += w; } void T2K_CC0pinp_ifk_XSec_3Dinfp_nu::SetHistograms(){ + std::string name = fSettings.GetName(); + // Read in 1D Data Histograms fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/STV/infkResults_origBin.root").c_str(),"READ"); - //fInputFile->ls(); - // Read in 1D Data - fDataHist = (TH1D*) fInputFile->Get("result_p"); - fDataHist->SetNameTitle("T2K_CC0pinp_ifk_XSec_3Dinfp_nu_data", "T2K_CC0pinp_ifk_XSec_3Dinfp_nu_data"); - SetAutoProcessTH1(fDataHist,kCMD_Write); - // Read in 2D Data Slices and Make MC Slices for (int i = 0; i < 7; i++){ //both y and z slices // Get Data Histogram - //fInputFile->ls(); fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("resultBin%i_p",i))->Clone()); - fDataHist_Slices[i]->SetNameTitle(Form("T2K_CC0pinp_ifk_XSec_3Dinfp_nu_data_Slice%i",i), (Form("T2K_CC0pinp_ifk_XSec_3Dinfp_nu_data_Slice%i",i))); + fDataHist_Slices[i]->SetNameTitle(Form("%s_data_Slice%i", name.c_str(), i), + Form("%s_data_Slice%i;#Delta p (GeV);%s", + name.c_str(), i, fSettings.GetYTitle().c_str())); // Make MC Clones fMCHist_Slices.push_back((TH1D*) fDataHist_Slices[i]->Clone()); - fMCHist_Slices[i]->SetNameTitle(Form("T2K_CC0pinp_ifk_XSec_3Dinfp_nu_MC_Slice%i",i), (Form("T2K_CC0pinp_ifk_XSec_3Dinfp_nu_MC_Slice%i",i))); + fMCHist_Slices[i]->SetNameTitle(Form("%s_MC_Slice%i",name.c_str(), i), + Form("%s_MC_Slice%i;#Delta p (GeV);%s", + name.c_str(), i, fSettings.GetYTitle().c_str())); SetAutoProcessTH1(fDataHist_Slices[i],kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); fMCHist_Slices[i]->Reset(); } return; }; diff --git a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h index 332c072..9965bbf 100644 --- a/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h +++ b/src/T2K/T2K_CC0pinp_ifk_XSec_3Dinfp_nu.h @@ -1,73 +1,73 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_CC0PINP_IFK_XSEC_3DINFP_NU_H_SEEN #define T2K_CC0PINP_IFK_XSEC_3DINFP_NU_H_SEEN #include "Measurement1D.h" class T2K_CC0pinp_ifk_XSec_3Dinfp_nu : public Measurement1D { public: /// Basic Constructor. T2K_CC0pinp_ifk_XSec_3Dinfp_nu(nuiskey samplekey); /// Virtual Destructor ~T2K_CC0pinp_ifk_XSec_3Dinfp_nu() {}; /// Numu CC0PI Signal Definition /// /// /item bool isSignal(FitEvent *nvect); /// Read histograms in a special way because format is different. /// Read from FitPar::GetDataBase()+"/T2K/CC0pi/T2K_CC0PI_2DPmuCosmu_Data.root" void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); /// Have to do a weird event scaling for analysis 1 void ConvertEventRates(); private: bool only_allowed_particles; bool numu_event; double numu_energy; int particle_pdg; double pmu, CosThetaMu; int fAnalysis; double outOfBoundsMC; bool fIsSystCov, fIsStatCov, fIsNormCov; TFile* fInputFile; std::vector fMCHist_Slices; std::vector fDataHist_Slices; void FillMCSlice(double x, double y, double z, double w); }; #endif diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.cxx index e7fe2e8..418b4f3 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.cxx @@ -1,111 +1,111 @@ #include #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1DAdlerPhi_nu.h" // The constructor T2K_CC1pip_CH_XSec_1DAdlerPhi_nu::T2K_CC1pip_CH_XSec_1DAdlerPhi_nu( nuiskey samplekey) { // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.2, costheta_pi > 0.2\n" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_CH_XSec_1DAdlerPhi_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("#phi_{Adler} (radians)"); - fSettings.SetYTitle("d#sigma/d#phi_{Adler} (cm^{2}/rad/nucleon)"); + fSettings.SetXTitle("#phi_{Adler} (rad.)"); + fSettings.SetYTitle("d#sigma/d#phi_{Adler} (cm^{2}/rad./nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/phi_adler.root", "Phi_Adler"); SetCovarFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/phi_adler.root", "Phi_AdlerCov"); SetShapeCovar(); fDataHist->Scale(1E-38); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void T2K_CC1pip_CH_XSec_1DAdlerPhi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; // Reconstruct the neutrino TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double rEnu = FitUtils::EnuCC1piprec_T2K_eMB(Pnu, Pmu, Ppip) * 1000.; // Now make the reconstructed neutrino // Has the same direction as the predicted neutrino TLorentzVector PnuReco(Pnu.Vect().Unit().X() * rEnu, Pnu.Vect().Unit().Y() * rEnu, Pnu.Vect().Unit().Z() * rEnu, rEnu); // Reconstruct the initial state assuming still nucleon TLorentzVector Pinit(0, 0, 0, PhysConst::mass_proton * 1000.); // Pretty much a copy of FitUtils::PhiAdler but using the reconstructed // neutrino instead of true neutrino{ // Get the "resonance" lorentz vector (pion proton system) reconstructed from // the variables TLorentzVector Pres = PnuReco + Pinit - Pmu; // Boost the particles into the resonance rest frame so we can define the // x,y,z axis PnuReco.Boost(-Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Ppip.Boost(-Pres.BoostVector()); // The z-axis is defined as the axis of three-momentum transfer, \vec{k} // Also unit normalise the axis TVector3 zAxis = (PnuReco.Vect() - Pmu.Vect()) * (1.0 / ((PnuReco.Vect() - Pmu.Vect()).Mag())); // The y-axis is then defined perpendicular to z and muon momentum in the // resonance frame TVector3 yAxis = PnuReco.Vect().Cross(Pmu.Vect()); yAxis *= 1.0 / double(yAxis.Mag()); // And the x-axis is then simply perpendicular to z and x TVector3 xAxis = yAxis.Cross(zAxis); xAxis *= 1.0 / double(xAxis.Mag()); double x = Ppip.Vect().Dot(xAxis); double y = Ppip.Vect().Dot(yAxis); double newphi = atan2(y, x); fXVar = newphi; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1DAdlerPhi_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936( event, EnuMin, EnuMax, SignalDef::kMuonHighEff | SignalDef::kPionVFwd | SignalDef::kPionHighMom); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DCosThAdler_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DCosThAdler_nu.cxx index 7f79aba..376b9c3 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1DCosThAdler_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1DCosThAdler_nu.cxx @@ -1,102 +1,102 @@ #include #include "T2K_SignalDef.h" #include "T2K_CC1pip_CH_XSec_1DCosThAdler_nu.h" // The constructor T2K_CC1pip_CH_XSec_1DCosThAdler_nu::T2K_CC1pip_CH_XSec_1DCosThAdler_nu( nuiskey samplekey) { // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.2, costheta_pi > 0.2\n" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_CH_XSec_1DCosThAdler_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("cos#theta_{Adler} (radians)"); + fSettings.SetXTitle("cos#theta_{Adler} (rad.)"); fSettings.SetYTitle("d#sigma/dcos#theta_{Adler} (cm^{2}/1/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/theta_adler.root", "Theta_Adler"); SetCovarFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/theta_adler.root", "Theta_AdlerCov"); SetShapeCovar(); fDataHist->Scale(1E-38); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; void T2K_CC1pip_CH_XSec_1DCosThAdler_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0 || event->NumFSParticle(211) == 0) return; // Essentially the same as FitUtils::CosThAdler but uses the reconsturcted // neutrino instead of the true neutrino Reconstruct the neutrino TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double rEnu = FitUtils::EnuCC1piprec_T2K_eMB(Pnu, Pmu, Ppip) * 1000.; // Now make the reconstructed neutrino // Has the same direction as the predicted neutrino TLorentzVector PnuReco(Pnu.Vect().Unit().X() * rEnu, Pnu.Vect().Unit().Y() * rEnu, Pnu.Vect().Unit().Z() * rEnu, rEnu); // Reconstruct the initial state assuming still nucleon TLorentzVector Pinit(0, 0, 0, PhysConst::mass_proton * 1000.); // Pretty much a copy of FitUtils::PhiAdler but using the reconstructed // neutrino instead of true neutrino{ // Get the "resonance" lorentz vector (pion proton system) reconstructed from // the variables TLorentzVector Pres = PnuReco + Pinit - Pmu; // Boost the particles into the resonance rest frame so we can define the // x,y,z axis PnuReco.Boost(-Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Ppip.Boost(-Pres.BoostVector()); // The z-axis is defined as the axis of three-momentum transfer, \vec{k} // Also unit normalise the axis TVector3 zAxis = (PnuReco.Vect() - Pmu.Vect()) * (1.0 / ((PnuReco.Vect() - Pmu.Vect()).Mag())); // Then the angle between the pion in the "resonance" rest-frame and the // z-axis is the theta Adler angle double costhAdler = cos(Ppip.Vect().Angle(zAxis)); fXVar = costhAdler; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1DCosThAdler_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936( event, EnuMin, EnuMax, SignalDef::kMuonHighEff | SignalDef::kPionVFwd | SignalDef::kPionHighMom); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx index 0ef525e..879a4b4 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1DQ2_nu.cxx @@ -1,102 +1,102 @@ #include #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(nuiskey samplekey) { // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.2, costheta_pi > 0.2\n" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_CH_XSec_1DQ2_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("Q^{2} (GeV/c)^{2}"); + fSettings.SetXTitle("Q^{2} (GeV^{2})"); fSettings.SetYTitle("d#sigma/dQ^{2} (cm^{2}/GeV^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/Q2.root", "Q2"); SetCovarFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/Q2.root", "Q2Cov"); SetShapeCovar(); fDataHist->Scale(1E-38); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936( event, EnuMin, EnuMax, SignalDef::kMuonHighEff | SignalDef::kPionVFwd | SignalDef::kPionHighMom); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx index 041ea16..718a11f 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dppi_nu.cxx @@ -1,71 +1,71 @@ #include #include "T2K_CC1pip_CH_XSec_1Dppi_nu.h" #include "T2K_SignalDef.h" //******************************************************************** T2K_CC1pip_CH_XSec_1Dppi_nu::T2K_CC1pip_CH_XSec_1Dppi_nu(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.2, costheta_pi > 0.2\n" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_CH_XSec_1Dppi_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("p_{#pi} (GeV/c)"); - fSettings.SetYTitle("d#sigma/dp_{#pi} (cm^{2}/(GeV/c)/nucleon)"); + fSettings.SetXTitle("p_{#pi} (GeV)"); + fSettings.SetYTitle("d#sigma/dp_{#pi} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/MomentumPion.root", "Momentum_pion"); SetCovarFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/MomentumPion.root", "Momentum_pionCov"); SetShapeCovar(); fDataHist->Scale(1E-38); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; 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) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936( event, EnuMin, EnuMax, SignalDef::kMuonHighEff | SignalDef::kPionVFwd); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx index fd4826a..db2a4c5 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthmupi_nu.cxx @@ -1,72 +1,72 @@ #include #include "T2K_CC1pip_CH_XSec_1Dthmupi_nu.h" #include "T2K_SignalDef.h" // The constructor T2K_CC1pip_CH_XSec_1Dthmupi_nu::T2K_CC1pip_CH_XSec_1Dthmupi_nu( nuiskey samplekey) { // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.2, costheta_pi > 0.2\n" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_CH_XSec_1Dthmupi_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("#theta_{#mu,#pi} (radians)"); - fSettings.SetYTitle("d#sigma/d#theta_{#mu,#pi} (cm^{2}/radians/nucleon)"); + fSettings.SetXTitle("#theta_{#mu,#pi} (rad.)"); + fSettings.SetYTitle("d#sigma/d#theta_{#mu,#pi} (cm^{2}/rad./nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/Thetapimu.root", "Theta(pi,mu)(rads)"); SetCovarFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/Thetapimu.root", "Theta(pi,mu)(rads)Cov"); SetShapeCovar(); fDataHist->Scale(1E-38); FinaliseMeasurement(); }; 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; // std::cout << thmupi << std::endl; return; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dthmupi_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936( event, EnuMin, EnuMax, SignalDef::kMuonHighEff | SignalDef::kPionVFwd | SignalDef::kPionHighMom); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx index abc4ea1..9244b8c 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_1Dthpi_nu.cxx @@ -1,67 +1,67 @@ #include #include "T2K_CC1pip_CH_XSec_1Dthpi_nu.h" #include "T2K_SignalDef.h" // The constructor T2K_CC1pip_CH_XSec_1Dthpi_nu::T2K_CC1pip_CH_XSec_1Dthpi_nu(nuiskey samplekey) { // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.2, costheta_pi > 0\n" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_CH_XSec_1Dthpi_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("#theta_{#pi} (radians)"); - fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2}/radians/nucleon)"); + fSettings.SetXTitle("#theta_{#pi} (rad.)"); + fSettings.SetYTitle("d#sigma/d#theta_{#pi} (cm^{2}/rad./nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/Thetapion.root", "Theta_pion"); SetCovarFromRootFile(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/Thetapion.root", "Theta_pionCov"); SetShapeCovar(); fDataHist->Scale(1E-38); FinaliseMeasurement(); }; void T2K_CC1pip_CH_XSec_1Dthpi_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(211) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double thpi = FitUtils::th(Pnu, Ppip); fXVar = thpi; }; //******************************************************************** bool T2K_CC1pip_CH_XSec_1Dthpi_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936( event, EnuMin, EnuMax, SignalDef::kMuonHighEff | SignalDef::kPionFwd | SignalDef::kPionHighMom); } diff --git a/src/T2K/T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.cxx b/src/T2K/T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.cxx index cec28d0..1d41d6d 100644 --- a/src/T2K/T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.cxx +++ b/src/T2K/T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.cxx @@ -1,211 +1,208 @@ #include "T2K_CC1pip_CH_XSec_2Dpmucosmu_nu.h" #include "T2K_SignalDef.h" //******************************************************************** T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::T2K_CC1pip_CH_XSec_2Dpmucosmu_nu( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_CH_XSec_nu sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, costheta_mu > 0" "https://arxiv.org/abs/1909.03936"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle(" "); - fSettings.SetYTitle( - "d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/(GeV/c)/nucleon)"); + fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("T2K_CC1pip_CH_XSec_2Dpmucosmu_nu"); fSettings.SetDataInput(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/PmuThetamu.root"); fSettings.SetCovarInput(GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/CH/PmuThetamu.root"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetHistograms(); covar = StatUtils::GetInvert(fFullCovar, true); fDecomp = StatUtils::GetDecomp(fFullCovar); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); + fSaveFine = false; }; void T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::SetHistograms() { TFile *data = new TFile(fSettings.GetDataInput().c_str(), "open"); std::string dataname = "p_mu_theta_mu"; // Number of slices we have const int nslices = 4; int nbins = 0; for (int i = 0; i < nslices; ++i) { TH1D *slice = (TH1D *)data->Get(Form("%s_%i", dataname.c_str(), i)); - slice = (TH1D *)slice->Clone((fName + Form("_data_slice%i", i)).c_str()); + slice = (TH1D *)slice->Clone((fName + Form("_data_Slice%i", i)).c_str()); slice->Scale(1E-38); - slice->GetXaxis()->SetTitle(fSettings.GetS("xtitle").c_str()); - slice->GetYaxis()->SetTitle(fSettings.GetS("ytitle").c_str()); + slice->GetXaxis()->SetTitle("p_{#mu}"); + slice->GetYaxis()->SetTitle(fSettings.GetYTitle().c_str()); fDataHist_Slices.push_back(slice); fMCHist_Slices.push_back( - (TH1D *)slice->Clone((fName + Form("_mc_slice%i", i)).c_str())); + (TH1D *)slice->Clone((fName + Form("_MC_Slice%i", i)).c_str())); SetAutoProcessTH1(fDataHist_Slices[i], kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); fMCHist_Slices[i]->Reset(); fMCHist_Slices[i]->SetLineColor(kRed); //nbins += slice->GetXaxis()->GetNbins(); // Skip the highest momentum bin because it's rubbish nbins += slice->GetXaxis()->GetNbins() - 1; } fDataHist = new TH1D(dataname.c_str(), dataname.c_str(), nbins, 0, nbins); fDataHist->SetNameTitle((fName + "_data").c_str(), (fName + "_data").c_str()); int bincount = 1; for (int i = 0; i < nslices; ++i) { // Skip the highest momentum bin because it's rubbish for (int j = 0; j < fDataHist_Slices[i]->GetXaxis()->GetNbins() - 1; ++j) { //for (int j = 0; j < fDataHist_Slices[i]->GetXaxis()->GetNbins(); ++j) { fDataHist->SetBinContent(bincount, fDataHist_Slices[i]->GetBinContent(j + 1)); fDataHist->SetBinError(bincount, fDataHist_Slices[i]->GetBinError(j + 1)); TString title; if (j == 0) { title = "cos#theta_{#mu}="; if (i == 0) { title += "0-0.8, "; } else if (i == 1) { title += "0.8-0.85, "; } else if (i == 2) { title += "0.85-0.90, "; } else if (i == 3) { title += "0.90-1.00, "; } } title += Form("p_{#mu}=%.2f-%.2f", fDataHist_Slices[i]->GetBinLowEdge(j + 1), fDataHist_Slices[i]->GetBinLowEdge(j + 2)); fDataHist->GetXaxis()->SetBinLabel(bincount, title); bincount++; } } fDataHist->GetXaxis()->SetTitle(fSettings.GetS("xtitle").c_str()); fDataHist->GetYaxis()->SetTitle(fSettings.GetS("ytitle").c_str()); // Get the covariance TMatrixDSym *temp = StatUtils::GetCovarFromRootFile(fSettings.GetCovarInput(), "Covariance_pmu_thetamu"); int ncovbins = temp->GetNrows(); // Skip the highest momentum bin because it's rubbish fFullCovar = new TMatrixDSym(ncovbins - 4); //fFullCovar = new TMatrixDSym(ncovbins); if (fFullCovar->GetNrows() != fDataHist->GetXaxis()->GetNbins()*fDataHist->GetYaxis()->GetNbins()) { NUIS_ERR(FTL, "Number of bins in covariance matrix does not match data"); } // Number of costhetamu slices is nslices // Number of pmu slices is int count1 = 0; // Skip the highest momentum bin because it's rubbish for (int i = 0; i < ncovbins - 4; ++i) { //for (int i = 0; i < ncovbins; ++i) { int count2 = 0; // Skip the highest momentum bin because it's rubbish for (int j = 0; j < ncovbins - 4; ++j) { //for (int j = 0; j < ncovbins; ++j) { // 1E79 matched to diagonal error (*fFullCovar)(count1, count2) = (*temp)(i, j); count2++; } count1++; } - // Now reorganise the rows - delete temp; }; void T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::FillEventVariables(FitEvent *event) { if (event->NumFSParticle(13) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(13)->fP; double pmu = FitUtils::p(Pmu); double costhmu = cos(FitUtils::th(Pnu, Pmu)); fXVar = pmu; fYVar = costhmu; }; void T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::FillHistograms() { Measurement1D::FillHistograms(); if (Signal) { FillMCSlice(fXVar, fYVar, Weight); } }; void T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::ConvertEventRates() { const int nslices = 4; for (int i = 0; i < nslices; i++) { fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); // First scale MC slices also by their width in Y and Z fMCHist_Slices[0]->Scale(1.0 / 0.80); fMCHist_Slices[1]->Scale(1.0 / 0.05); fMCHist_Slices[2]->Scale(1.0 / 0.05); fMCHist_Slices[3]->Scale(1.0 / 0.10); // Now Convert into 1D list fMCHist->Reset(); int bincount = 1; for (int i = 0; i < nslices; i++) { for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX() - 1; j++) { - //for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fMCHist->SetBinContent(bincount, fMCHist_Slices[i]->GetBinContent(j + 1)); bincount++; } } } void T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::FillMCSlice(double pmu, double cosmu, double weight) { // Hard code the bin edges in here if (cosmu < 0.8) { fMCHist_Slices[0]->Fill(pmu, weight); } else if (cosmu > 0.8 && cosmu < 0.85) { fMCHist_Slices[1]->Fill(pmu, weight); } else if (cosmu > 0.85 && cosmu < 0.90) { fMCHist_Slices[2]->Fill(pmu, weight); } else if (cosmu > 0.90 && cosmu < 1.00) { fMCHist_Slices[3]->Fill(pmu, weight); } }; //******************************************************************** bool T2K_CC1pip_CH_XSec_2Dpmucosmu_nu::isSignal(FitEvent *event) { //******************************************************************** return SignalDef::isCC1pip_T2K_arxiv1909_03936(event, EnuMin, EnuMax, SignalDef::kMuonFwd); }; diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx index 21ec574..ef9c092 100644 --- a/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1DEnuMB_nu.cxx @@ -1,91 +1,91 @@ #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( nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_H2O_XSec_nu sample. \n" "Target: H20 \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.3, costheta_pi > 0.3\n" "https://journals.aps.org/prd/pdf/10.1103/PhysRevD.95.012010"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_H2O_XSec_1DEnuMB_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("E_{#nu}^{MiniBooNE} (GeV)"); - fSettings.SetYTitle("#sigma(E_{#nu}^{MiniBooNE}) (cm^{2}/nucleon)"); + fSettings.SetXTitle("E_{#nu}^{MB} (GeV)"); + fSettings.SetYTitle("#sigma(E_{#nu}^{MB}) (cm^{2}/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/DIAG"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root;EnuRec_MB/" "hResultTot"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/H2O/nd280data-numu-cc1pi-xs-on-h2o-2015.root;EnuRec_MB/" "TotalCovariance"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(fSettings.GetDataInput()); SetCovarFromRootFile(fSettings.GetCovarInput()); ScaleCovar(1E76); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** // 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_PRD97_012001(event, EnuMin, EnuMax); } diff --git a/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx b/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx index 52402e1..1ecb208 100644 --- a/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx +++ b/src/T2K/T2K_CC1pip_H2O_XSec_1Dppi_nu.cxx @@ -1,79 +1,79 @@ #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(nuiskey samplekey) { //******************************************************************** // Sample overview --------------------------------------------------- std::string descrip = "T2K_CC1pip_H2O_XSec_nu sample. \n" "Target: H20 \n" "Flux: T2K FHC numu \n" "Signal: CC1pi+, p_mu > 200 MeV, p_pi > 200 MeV\n" ", costheta_mu > 0.3, costheta_pi > 0.3\n" "https://journals.aps.org/prd/pdf/10.1103/PhysRevD.95.012010"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetTitle("T2K_CC1pip_H2O_XSec_1Dppi_nu"); fSettings.SetDescription(descrip); - fSettings.SetXTitle("p_{#pi^{+}} (GeV/c)"); - fSettings.SetYTitle("d#sigma/dp_{#pi^{+}} (cm^{2}/(GeV/c)/nucleon)"); + fSettings.SetXTitle("p_{#pi^{+}} (GeV)"); + fSettings.SetYTitle("d#sigma/dp_{#pi^{+}} (cm^{2}/GeV/nucleon)"); fSettings.SetAllowedTypes("FIX,FREE,SHAPE/DIAG,FULL/NORM/MASK", "FIX/FULL"); fSettings.SetEnuRange(0.0, 100.0); fSettings.DefineAllowedTargets("C,H"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDataInput( GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/H2O/" "nd280data-numu-cc1pi-xs-on-h2o-2015.root;PosPionMom/hResultTot"); fSettings.SetCovarInput( GeneralUtils::GetTopLevelDir() + "/data/T2K/CC1pip/H2O/" "nd280data-numu-cc1pi-xs-on-h2o-2015.root;PosPionMom/TotalCovariance"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = (GetEventHistogram()->Integral("width") * 1E-38) / double(fNEvents) / TotalIntegratedFlux("width"); // Plot Setup ------------------------------------------------------- SetDataFromRootFile(fSettings.GetDataInput()); SetCovarFromRootFile(fSettings.GetCovarInput()); ScaleCovar(1E76); SetShapeCovar(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; //******************************************************************** // 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_PRD97_012001(event, EnuMin, EnuMax); } diff --git a/src/T2K/T2K_CCinc_XSec_2DPcos_nu_nonuniform.cxx b/src/T2K/T2K_CCinc_XSec_2DPcos_nu_nonuniform.cxx index 06fbefb..b5befe9 100644 --- a/src/T2K/T2K_CCinc_XSec_2DPcos_nu_nonuniform.cxx +++ b/src/T2K/T2K_CCinc_XSec_2DPcos_nu_nonuniform.cxx @@ -1,257 +1,254 @@ #include "T2K_CCinc_XSec_2DPcos_nu_nonuniform.h" #include "T2K_SignalDef.h" // *********************************** // Implemented by Alfonso Garcia, Barcelona (now NIKHEF) // Clarence Wret, Rochester // (Alfonso was the T2K analyser) // *********************************** //******************************************************************** T2K_CCinc_XSec_2DPcos_nu_nonuniform::T2K_CCinc_XSec_2DPcos_nu_nonuniform( nuiskey samplekey) { //******************************************************************** + fSaveFine = false; fAllowedTypes += "/GENIE/NEUT"; // Sample overview --------------------------------------------------- std::string descrip = "T2K_CCinc_XSec_2DPcos_nu_nonuniform sample. \n" "Target: CH \n" "Flux: T2K FHC numu \n" "Signal: CC-inclusive \n" "https://journals.aps.org/prd/abstract/10.1103/PhysRevD.98.012004"; // Setup common settings fSettings = LoadSampleSettings(samplekey); fSettings.SetDescription(descrip); - fSettings.SetXTitle(""); - // fSettings.SetXTitle("p_{#mu} (GeV)"); - // fSettings.SetYTitle("cos#theta_{#mu}"); + fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); fSettings.SetYTitle("#frac{d^{2}#sigma}{dp_{#mu}dcos#theta_{#mu}} " - "[#frac{cm^{2}}{nucleon/GeV/c}]"); + "(cm^{2}/nucleon/GeV)"); fSettings.SetEnuRange(0.0, 30.0); fSettings.DefineAllowedTargets("C,H"); // CCQELike plot information fSettings.SetTitle("T2K CC-inclusive p_{#mu} cos#theta_{#mu}"); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = GetEventHistogram()->Integral("width") * 1E-38 / fNEvents / TotalIntegratedFlux(); // Default to using the NEUT unfolded data UnfoldWithGENIE = false; // Check option if (fSettings.Found("type", "GENIE")) UnfoldWithGENIE = true; // Tell user what's happening if (UnfoldWithGENIE) { NUIS_LOG(SAM, fName << " is using GENIE unfolded data. Want NEUT? Specify " "type=\"NEUT\" in your config file"); } else { NUIS_LOG(SAM, fName << " is using NEUT unfolded data. Want GENIE? Specify " "type=\"GENIE\" in your config file"); } // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); }; // Signal is simply a CC inclusive without any angular/momentum cuts bool T2K_CCinc_XSec_2DPcos_nu_nonuniform::isSignal(FitEvent *event) { return SignalDef::isCCINC(event, 14, EnuMin, EnuMax); }; void T2K_CCinc_XSec_2DPcos_nu_nonuniform::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; }; // Fill up the MCSlice void T2K_CCinc_XSec_2DPcos_nu_nonuniform::FillHistograms() { if (Signal) FillMCSlice(fXVar, fYVar, Weight); } // Modification is needed after the full reconfigure to move bins around void T2K_CCinc_XSec_2DPcos_nu_nonuniform::ConvertEventRates() { // Do standard conversion. Measurement1D::ConvertEventRates(); // First scale MC slices also by their width in Y - fMCHist_Slices[0]->Scale(1.0 / 0.25); + fMCHist_Slices[0]->Scale(1.0 / 0.75); fMCHist_Slices[1]->Scale(1.0 / 0.50); fMCHist_Slices[2]->Scale(1.0 / 0.20); fMCHist_Slices[3]->Scale(1.0 / 0.15); fMCHist_Slices[4]->Scale(1.0 / 0.11); fMCHist_Slices[5]->Scale(1.0 / 0.09); fMCHist_Slices[6]->Scale(1.0 / 0.07); fMCHist_Slices[7]->Scale(1.0 / 0.05); fMCHist_Slices[8]->Scale(1.0 / 0.04); fMCHist_Slices[9]->Scale(1.0 / 0.025); fMCHist_Slices[10]->Scale(1.0 / 0.015); // Now Convert into 1D list fMCHist->Reset(); int bincount = 0; for (int i = 0; i < nSlices; i++) { for (int j = 0; j < fMCHist_Slices[i]->GetNbinsX(); j++) { fMCHist->SetBinContent(bincount + 1, fMCHist_Slices[i]->GetBinContent(j + 1)); fMCHist->SetBinError(bincount + 1, fMCHist_Slices[i]->GetBinError(j + 1)); bincount++; } } }; void T2K_CCinc_XSec_2DPcos_nu_nonuniform::FillMCSlice(double x, double y, double w) { if (y >= -1.0 && y < -0.25) fMCHist_Slices[0]->Fill(x, w); else if (y >= -0.25 && y < 0.25) fMCHist_Slices[1]->Fill(x, w); else if (y >= 0.25 && y < 0.45) fMCHist_Slices[2]->Fill(x, w); else if (y >= 0.45 && y < 0.6) fMCHist_Slices[3]->Fill(x, w); else if (y >= 0.6 && y < 0.71) fMCHist_Slices[4]->Fill(x, w); else if (y >= 0.71 && y < 0.80) fMCHist_Slices[5]->Fill(x, w); else if (y >= 0.80 && y < 0.87) fMCHist_Slices[6]->Fill(x, w); else if (y >= 0.87 && y < 0.92) fMCHist_Slices[7]->Fill(x, w); else if (y >= 0.92 && y < 0.96) fMCHist_Slices[8]->Fill(x, w); else if (y >= 0.96 && y <= 0.985) fMCHist_Slices[9]->Fill(x, w); else if (y >= 0.985 && y <= 1.0) fMCHist_Slices[10]->Fill(x, w); }; void T2K_CCinc_XSec_2DPcos_nu_nonuniform::SetHistograms() { // Read in 1D Data Histograms - TFile *fInputFile = - new TFile((FitPar::GetDataBase() + + TFile *fInputFile = new TFile((FitPar::GetDataBase() + "T2K/CCinc/nd280data-numu-cc-inc-xs-on-c-2018/histograms.root") - .c_str(), - "OPEN"); + .c_str(), "OPEN"); // Number of theta slices in the release nSlices = 11; // Data release includes unfolding with NEUT or GENIE as prior // Choose whichever the user specifies std::string basename; if (UnfoldWithGENIE) basename = "hist_xsec_data_prior_neut_cthbin"; else basename = "hist_xsec_data_prior_neut_cthbin"; // Read in 2D Data Slices and Make MC Slices // Count the number of bins we have in total so we can match covariance matrix int bincount = 0; for (int i = 0; i < nSlices; i++) { // Get Data Histogram - // fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("dataslice_%i",i))->Clone()); fDataHist_Slices.push_back( (TH1D *)fInputFile->Get(Form("%s%i", basename.c_str(), i)) ->Clone( - Form("T2K_CCinc_XSec_2DPcos_nu_nonuniform_slice%i_data", i))); + Form("T2K_CCinc_XSec_2DPcos_nu_nonuniform_Slice%i_data", i))); fDataHist_Slices[i]->SetDirectory(0); fDataHist_Slices[i]->Scale(1E-39); - fDataHist_Slices[i]->GetYaxis()->SetTitle(fSettings.GetS("ytitle").c_str()); + fDataHist_Slices[i]->GetXaxis()->SetTitle("p_{#mu} (GeV)"); + fDataHist_Slices[i]->GetYaxis()->SetTitle(fSettings.GetYTitle().c_str()); // Count up the bins bincount += fDataHist_Slices.back()->GetNbinsX(); // Make MC Clones fMCHist_Slices.push_back((TH1D *)fDataHist_Slices[i]->Clone( Form("T2K_CCinc_XSec_2DPcos_nu_nonuniform_Slice%i_MC", i))); fMCHist_Slices[i]->Reset(); fMCHist_Slices[i]->SetDirectory(0); fMCHist_Slices[i]->SetLineColor(kRed); - fMCHist_Slices[i]->GetYaxis()->SetTitle(fSettings.GetS("ytitle").c_str()); + fMCHist_Slices[i]->GetYaxis()->SetTitle(fSettings.GetYTitle().c_str()); SetAutoProcessTH1(fDataHist_Slices[i], kCMD_Write); SetAutoProcessTH1(fMCHist_Slices[i]); } fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), bincount, 0, bincount); fDataHist->SetDirectory(0); int counter = 0; for (int i = 0; i < nSlices; ++i) { // Set a nice title std::string costitle = fDataHist_Slices[i]->GetTitle(); costitle = costitle.substr(costitle.find("-> ") + 3, costitle.size()); std::string found = costitle.substr(0, costitle.find(" < ")); std::string comp = costitle.substr(costitle.find(found) + found.size() + 3, costitle.size()); comp = comp.substr(comp.find(" < ") + 3, comp.size()); costitle = "cos#theta_{#mu}=" + found + "-" + comp; for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++) { fDataHist->SetBinContent(counter + 1, fDataHist_Slices[i]->GetBinContent(j + 1)); fDataHist->SetBinError(counter + 1, fDataHist_Slices[i]->GetBinError(j + 1)); // Set a nice axis if (j == 0) fDataHist->GetXaxis()->SetBinLabel( counter + 1, Form("%s, p_{#mu}=%.1f-%.1f", costitle.c_str(), fDataHist_Slices[i]->GetBinLowEdge(j + 1), fDataHist_Slices[i]->GetBinLowEdge(j + 2))); else fDataHist->GetXaxis()->SetBinLabel( counter + 1, Form("p_{#mu}=%.1f-%.1f", fDataHist_Slices[i]->GetBinLowEdge(j + 1), fDataHist_Slices[i]->GetBinLowEdge(j + 2))); counter++; } } // The correlation matrix // Major in angular bins, minor in momentum bins: runs theta1, pmu1, pmu2, // theta2, pmu1, pmu2, theta3, pmu1, pmu2 etc The correlation matrix TH2D *tempcov = NULL; if (UnfoldWithGENIE) tempcov = (TH2D *)fInputFile->Get("covariance_matrix_genie"); else tempcov = (TH2D *)fInputFile->Get("covariance_matrix_neut"); fFullCovar = new TMatrixDSym(bincount); for (int i = 0; i < fDataHist->GetNbinsX(); i++) { for (int j = 0; j < fDataHist->GetNbinsX(); j++) { (*fFullCovar)(i, j) = tempcov->GetBinContent(i + 1, j + 1); } } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); (*fFullCovar) *= 1E38 * 1E38; (*covar) *= 1E-38 * 1E-38; fInputFile->Close(); }; diff --git a/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.cxx b/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.cxx index bef9d13..74718b9 100644 --- a/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.cxx +++ b/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.cxx @@ -1,249 +1,216 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h" static size_t nangbins = 9; static double angular_binning_costheta[] = {-1, 0.2, 0.6, 0.7, 0.8, 0.85, 0.9, 0.94, 0.98, 1 }; //******************************************************************** T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos(nuiskey samplekey) { //******************************************************************** // Samples overview --------------------------------------------------- fSettings = LoadSampleSettings(samplekey); - std::string name = fSettings.GetS("name"); + std::string name = fSettings.GetName(); std::string descrip = ""; // This has to deal with NuMu FHC, and AntiNuMu RHC if (!name.compare("T2K_NuMu_CC0pi_CH_XSec_2DPcos")){ descrip = name +". \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "DOI:10.1103/PhysRevD.101.112001"; fSettings.SetTitle("T2K_NuMu_CC0pi_CH_XSec_2DPcos"); fSettings.DefineAllowedSpecies("numu"); NuPDG = 14; LepPDG = 13; } else if (!name.compare("T2K_AntiNuMu_CC0pi_CH_XSec_2DPcos")){ descrip = name +". \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "DOI:10.1103/PhysRevD.101.112001"; fSettings.SetTitle("T2K_AntiNuMu_CC0pi_CH_XSec_2DPcos"); fSettings.DefineAllowedSpecies("numub"); NuPDG = -14; LepPDG = -13; } // Setup common settings fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); - fSettings.SetYTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("DIAG,FULL/FREE,SHAPE,FIX/SYSTCOV/STATCOV","FIX"); fSettings.SetEnuRangeFromFlux(fFluxHist); fSettings.DefineAllowedTargets("C,H"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * 1E-38 / (TotalIntegratedFlux())); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); - + fSaveFine = false; }; bool T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::isSignal(FitEvent *event){ return SignalDef::isCC0pi(event, NuPDG, EnuMin, EnuMax); }; void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::FillEventVariables(FitEvent* event){ if (event->NumFSParticle(LepPDG) == 0) return; TLorentzVector Pnu = event->GetNeutrinoIn()->fP; TLorentzVector Pmu = event->GetHMFSParticle(LepPDG)->fP; double pmu = Pmu.Vect().Mag()/1000.; double CosThetaMu = cos(Pnu.Vect().Angle(Pmu.Vect())); fXVar = pmu; fYVar = CosThetaMu; return; }; void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::FillHistograms(){ Measurement1D::FillHistograms(); if (Signal){ FillMCSlice( fXVar, fYVar, Weight ); } } void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::ConvertEventRates(){ for (size_t i = 0; i < nangbins; i++){ - if(NuPDG==14) fMCHistNuMu_Slices[i]->GetSumw2(); - else if(NuPDG==-14) fMCHistAntiNuMu_Slices[i]->GetSumw2(); + fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); // Scale MC slices by their bin area for (size_t i = 0; i < nangbins; ++i) { - if(NuPDG==14) fMCHistNuMu_Slices[i]->Scale(1. / (angular_binning_costheta[i + 1] - angular_binning_costheta[i])); - else if(NuPDG==-14) fMCHistAntiNuMu_Slices[i]->Scale(1. / (angular_binning_costheta[i + 1] - angular_binning_costheta[i])); + fMCHist_Slices[i]->Scale(1. / (angular_binning_costheta[i + 1] - angular_binning_costheta[i])); } // Now Convert into 1D lists fMCHist->Reset(); int bincount = 0; for (size_t i = 0; i < nangbins; i++){ - if(NuPDG==14){ - for (int j = 0; j < fDataHistNuMu_Slices[i]->GetNbinsX(); j++){ - fMCHist->SetBinContent(bincount+1, fMCHistNuMu_Slices[i]->GetBinContent(j+1)); - bincount++; - } - } - else if(NuPDG==-14){ - for (int j = 0; j < fMCHistAntiNuMu_Slices[i]->GetNbinsX(); j++){ - fMCHist->SetBinContent(bincount+1, fMCHistAntiNuMu_Slices[i]->GetBinContent(j+1)); - bincount++; - } + for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++){ + fMCHist->SetBinContent(bincount+1, fMCHist_Slices[i]->GetBinContent(j+1)); + bincount++; } - } + } return; } void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::FillMCSlice(double x, double y, double w){ for (size_t i = 0; i < nangbins; ++i) { if ((y > angular_binning_costheta[i]) && (y <= angular_binning_costheta[i + 1])) { - if(NuPDG==14) fMCHistNuMu_Slices[i]->Fill(x, w); - else if(NuPDG==-14) fMCHistAntiNuMu_Slices[i]->Fill(x, w); + fMCHist_Slices[i]->Fill(x, w); } } } void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos::SetHistograms(){ - // Read in 1D Data Histograms - fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointNuMu-AntiNuMu/JointNuMuAntiNuMuCC0piXsecDataRelease.root").c_str(),"READ"); - - TH1D* hLinearResult; + std::string name = fSettings.GetName(); + std::string titles = fSettings.GetFullTitles(); - if(NuPDG==14) hLinearResult = (TH1D*) fInputFile->Get("hNuMuCC0piXsecLinearResult"); - else if(NuPDG==-14) hLinearResult = (TH1D*) fInputFile->Get("hAntiNuMuCC0piXsecLinearResult"); + std::string nuType; + if (NuPDG==14) nuType = "NuMu"; + else nuType = "AntiNuMu"; - int Nbins = hLinearResult->GetNbinsX(); + // Read in 1D Data Histograms + fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointNuMu-AntiNuMu/JointNuMuAntiNuMuCC0piXsecDataRelease.root").c_str(),"READ"); - std::string histoLinearNuType; - if(NuPDG==14) histoLinearNuType = "NuMuCC0pi"; - else if(NuPDG==-14) histoLinearNuType = "AntiNuMuCC0pi"; + TH1D* hLinearResult = (TH1D*) fInputFile->Get(Form("h%sCC0piXsecLinearResult", nuType.c_str())); + int Nbins = hLinearResult->GetNbinsX(); // Now Convert into 1D list - fDataHist = new TH1D(("LinarResult" + histoLinearNuType).c_str(),("LinarResult" + histoLinearNuType).c_str(),Nbins,0,Nbins); + fDataHist = new TH1D(Form("%s_data", name.c_str()), + Form("%s_data%s", name.c_str(), titles.c_str()), + Nbins,0,Nbins); for (int bin = 0; bin < Nbins; bin++){ fDataHist->SetBinContent(bin+1, hLinearResult->GetBinContent(bin+1)); } // Make covariance matrix fFullCovar = new TMatrixDSym(Nbins); TMatrixDSym* tmpcovstat = (TMatrixDSym*) fInputFile->Get("JointNuMuAntiNuMuCC0piXsecCovMatrixStat"); TMatrixDSym* tmpcovsyst = (TMatrixDSym*) fInputFile->Get("JointNuMuAntiNuMuCC0piXsecCovMatrixSyst"); for(int ibin=0; ibinReset(); int bincount = 0; for (size_t i = 0; i < nangbins; i++){ - if(NuPDG==14){ - // Make slices for data - fDataHistNuMu_Slices.push_back((TH1D*)fInputFile->Get(Form("hXsecNuMuCC0piDataSlice_%zu",i))->Clone()); - fDataHistNuMu_Slices[i]->SetNameTitle(Form("T2K_NuMu_CC0pi_2DPcos_data_Slice%zu",i), - (Form("T2K_NuMu_CC0pi_2DPcos_data_Slice%zu",i))); - - // Loop over nbins and set errors from covar - for (int j = 0; j < fDataHistNuMu_Slices[i]->GetNbinsX(); j++){ - fDataHistNuMu_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); - fDataHist->SetBinContent(bincount+1, fDataHistNuMu_Slices[i]->GetBinContent(j+1)); - fDataHist->SetBinError(bincount+1, fDataHistNuMu_Slices[i]->GetBinError(j+1)); - bincount++; - } - - // Save MC slices - fMCHistNuMu_Slices.push_back((TH1D*) fDataHistNuMu_Slices[i]->Clone()); - fMCHistNuMu_Slices[i]->SetNameTitle(Form("T2K_NuMu_CC0pi_2DPcos_MC_Slice%zu",i), (Form("T2K_NuMu_CC0pi_2DPcos_MC_Slice%zu",i))); - - SetAutoProcessTH1(fDataHistNuMu_Slices[i],kCMD_Write); - SetAutoProcessTH1(fMCHistNuMu_Slices[i]); - - } - else if(NuPDG==-14) { - // Make slices for data - fDataHistAntiNuMu_Slices.push_back((TH1D*)fInputFile->Get(Form("hXsecAntiNuMuCC0piDataSlice_%zu",i))->Clone()); - fDataHistAntiNuMu_Slices[i]->SetNameTitle(Form("T2K_AntiNuMu_CC0pi_2DPcos_data_Slice%zu",i), - (Form("T2K_AntiNuMu_CC0pi_2DPcos_data_Slice%zu",i))); - - //Loop over nbins and set errors from covar - for (int j = 0; j < fDataHistAntiNuMu_Slices[i]->GetNbinsX(); j++){ - fDataHistAntiNuMu_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); - fDataHist->SetBinContent(bincount+1, fDataHistAntiNuMu_Slices[i]->GetBinContent(j+1)); - fDataHist->SetBinError(bincount+1, fDataHistAntiNuMu_Slices[i]->GetBinError(j+1)); - bincount++; - } - - // Save MC slices - fMCHistAntiNuMu_Slices.push_back((TH1D*) fDataHistAntiNuMu_Slices[i]->Clone()); - fMCHistAntiNuMu_Slices[i]->SetNameTitle(Form("T2K_AntiNuMu_CC0pi_2DPcos_MC_Slice%zu",i), (Form("T2K_AntiNuMu_CC0pi_2DPcos_MC_Slice%zu",i))); - - SetAutoProcessTH1(fDataHistAntiNuMu_Slices[i],kCMD_Write); - SetAutoProcessTH1(fMCHistAntiNuMu_Slices[i]); + // Make slices for data + fDataHist_Slices.push_back((TH1D*)fInputFile->Get(Form("hXsec%sCC0piDataSlice_%zu",nuType.c_str(),i))->Clone()); + fDataHist_Slices[i]->SetNameTitle(Form("%s_data_Slice%zu",name.c_str(), i), + Form("%s_data_Slice%zu%s",name.c_str(), i, titles.c_str())); + + // Loop over nbins and set errors from covar + for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++){ + fDataHist_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); + fDataHist->SetBinContent(bincount+1, fDataHist_Slices[i]->GetBinContent(j+1)); + fDataHist->SetBinError(bincount+1, fDataHist_Slices[i]->GetBinError(j+1)); + bincount++; } - } + + // Save MC slices + fMCHist_Slices.push_back((TH1D*) fDataHist_Slices[i]->Clone()); + fMCHist_Slices[i]->SetNameTitle(Form("%s_MC_Slice%zu",name.c_str(), i), + Form("%s_MC_Slice%zu%s",name.c_str(),i,titles.c_str())); + + SetAutoProcessTH1(fDataHist_Slices[i],kCMD_Write); + SetAutoProcessTH1(fMCHist_Slices[i]); + } return; }; diff --git a/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h b/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h index ad9ee27..7eb38d2 100644 --- a/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h +++ b/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos.h @@ -1,68 +1,66 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_NUMUANTINUMU_CC0PI_CH_XSEC_2DPCOS_H_SEEN #define T2K_NUMUANTINUMU_CC0PI_CH_XSEC_2DPCOS_H_SEEN #include "Measurement1D.h" #include "TH2Poly.h" class T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos : public Measurement1D { public: /// Basic Constructor. /// /brief Parses two different measurements. /// T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos(nuiskey samplekey); /// Virtual Destructor ~T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos() {}; /// Signal definition bool isSignal(FitEvent *nvect); /// Read histograms void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); /// Event scaling void ConvertEventRates(); private: TFile* fInputFile; - std::vector fMCHistNuMu_Slices; - std::vector fDataHistNuMu_Slices; - std::vector fMCHistAntiNuMu_Slices; - std::vector fDataHistAntiNuMu_Slices; + std::vector fMCHist_Slices; + std::vector fDataHist_Slices; double pmu, CosThetaMu; int NuPDG; int LepPDG; void FillMCSlice(double x, double y, double w); }; #endif diff --git a/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.cxx b/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.cxx index f01e6a5..b169826 100644 --- a/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.cxx +++ b/src/T2K/T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.cxx @@ -1,155 +1,156 @@ #include "T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint.h" //******************************************************************** T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint::T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint(nuiskey samplekey){ //******************************************************************** fSettings = LoadSampleSettings(samplekey); std::string descrip = "T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint. \n" "Target: CH \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "DOI:10.1103/PhysRevD.101.112001"; fSettings.SetTitle("T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint"); fSettings.DefineAllowedSpecies("numu, numub"); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); - fSettings.SetYTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("DIAG,FULL/FREE,SHAPE,FIX/SYSTCOV/STATCOV","FIX"); fSettings.SetEnuRange(0.0, 30.0); fSettings.DefineAllowedTargets("C,H"); FinaliseSampleSettings(); if (fSubInFiles.size() != 2) { NUIS_ABORT("T2K NuMu-AntiNuMu joint requires input files in format: NuMu and AntiNuMu"); } std::string inFileNuMu = fSubInFiles.at(0); std::string inFileAntiNuMu = fSubInFiles.at(1); // Create some config keys nuiskey NuMuKey = Config::CreateKey("sample"); NuMuKey.SetS("input", inFileNuMu); NuMuKey.SetS("type", fSettings.GetS("type")); NuMuKey.SetS("name", "T2K_NuMu_CC0pi_CH_XSec_2DPcos"); NuMuCC0pi = new T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos(NuMuKey); nuiskey AntiNuMuKey = Config::CreateKey("sample"); AntiNuMuKey.SetS("input", inFileAntiNuMu); AntiNuMuKey.SetS("type", fSettings.GetS("type")); AntiNuMuKey.SetS("name", "T2K_AntiNuMu_CC0pi_CH_XSec_2DPcos"); AntiNuMuCC0pi = new T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos(AntiNuMuKey); // Sort out the data hist this->CombineDataHists(); // Set the covariance SetCovariance(); // Add to chain for processing fSubChain.clear(); fSubChain.push_back(NuMuCC0pi); fSubChain.push_back(AntiNuMuCC0pi); // This saves information from the sub-measurements fSaveSubMeas = true; + fSaveFine = false; FinaliseMeasurement(); }; //******************************************************************** void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint::SetCovariance(){ //******************************************************************** fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointNuMu-AntiNuMu/JointNuMuAntiNuMuCC0piXsecDataRelease.root").c_str(),"READ"); TMatrixDSym* tmpcovstat = (TMatrixDSym*) fInputFile->Get("JointNuMuAntiNuMuCC0piXsecCovMatrixStat"); TMatrixDSym* tmpcovsyst = (TMatrixDSym*) fInputFile->Get("JointNuMuAntiNuMuCC0piXsecCovMatrixSyst"); fFullCovar = new TMatrixDSym(*tmpcovstat); (*fFullCovar)+=(*tmpcovsyst); covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); ScaleCovar(1E76); return; } //******************************************************************** void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint::CombineDataHists(){ //******************************************************************** TH1D *hNuMuData = (TH1D*)NuMuCC0pi->GetDataHistogram(); TH1D *hAntiNuMuData = (TH1D*)AntiNuMuCC0pi->GetDataHistogram(); int nbins = hNuMuData->GetNbinsX() + hAntiNuMuData->GetNbinsX(); fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), nbins, 0, nbins); fDataHist->SetDirectory(0); int count = 0; for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, hNuMuData->GetBinContent(x+1)); fDataHist->SetBinError(count+1, hNuMuData->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("NuMu CC0pi %.1f-%.1f", hNuMuData->GetXaxis()->GetBinLowEdge(x+1), hNuMuData->GetXaxis()->GetBinUpEdge(x+1))); count++; } for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, hAntiNuMuData->GetBinContent(x+1)); fDataHist->SetBinError(count+1, hAntiNuMuData->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("AntiNuMu CC0pi %.1f-%.1f", hAntiNuMuData->GetXaxis()->GetBinLowEdge(x+1), hAntiNuMuData->GetXaxis()->GetBinUpEdge(x+1))); count++; } } //******************************************************************** void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint::SetHistograms() { //******************************************************************** NuMuCC0pi->SetHistograms(); AntiNuMuCC0pi->SetHistograms(); return; } //******************************************************************** void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint::FillHistograms() { //******************************************************************** NuMuCC0pi->FillHistograms(); AntiNuMuCC0pi->FillHistograms(); return; } //******************************************************************** void T2K_NuMuAntiNuMu_CC0pi_CH_XSec_2DPcos_joint::ConvertEventRates() { //******************************************************************** NuMuCC0pi->ConvertEventRates(); AntiNuMuCC0pi->ConvertEventRates(); TH1D* hNuMuCC0pi = (TH1D*)NuMuCC0pi->GetMCHistogram(); TH1D* hAntiNuMuCC0pi = (TH1D*)AntiNuMuCC0pi->GetMCHistogram(); int count = 0; for (int i = 0; i < hNuMuCC0pi->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, hNuMuCC0pi->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, hNuMuCC0pi->GetBinError(i + 1)); count++; } for (int i = 0; i < hAntiNuMuCC0pi->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, hAntiNuMuCC0pi->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, hAntiNuMuCC0pi->GetBinError(i + 1)); count++; } return; } diff --git a/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.cxx b/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.cxx index 5a389f3..f3c1c68 100644 --- a/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.cxx +++ b/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.cxx @@ -1,274 +1,215 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_NuMu_CC0pi_OC_XSec_2DPcos.h" static size_t nangbins = 6; static double angular_binning_costheta[] = {-1, 0., 0.6, 0.75, 0.86, 0.93, 1.}; //******************************************************************** T2K_NuMu_CC0pi_OC_XSec_2DPcos::T2K_NuMu_CC0pi_OC_XSec_2DPcos(nuiskey samplekey) { //******************************************************************** // Samples overview --------------------------------------------------- fSettings = LoadSampleSettings(samplekey); - std::string name = fSettings.GetS("name"); + std::string name = fSettings.GetName(); std::string descrip = ""; // This has to deal with NuMu on O and on C if (!name.compare("T2K_NuMu_CC0pi_O_XSec_2DPcos")){ descrip = name +". \n" "Target: Oxygen \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "DOI:10.1103/PhysRevD.101.112004"; fSettings.SetTitle("T2K_NuMu_CC0pi_O_XSec_2DPcos"); fSettings.DefineAllowedTargets("O"); Target = "O"; } else if (!name.compare("T2K_NuMu_CC0pi_C_XSec_2DPcos")){ descrip = name +". \n" "Target: Carbon \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "DOI:10.1103/PhysRevD.101.112004"; fSettings.SetTitle("T2K_NuMu_CC0pi_C_XSec_2DPcos"); fSettings.DefineAllowedTargets("C"); Target = "C"; } // Setup common settings fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); - fSettings.SetYTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("DIAG,FULL/FREE,SHAPE,FIX/SYSTCOV/STATCOV","FIX"); fSettings.SetEnuRangeFromFlux(fFluxHist); fSettings.DefineAllowedSpecies("numu"); FinaliseSampleSettings(); // Scaling Setup --------------------------------------------------- // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon fScaleFactor = ((GetEventHistogram()->Integral("width")/(fNEvents+0.)) * 1E-38 / (TotalIntegratedFlux())); // Setup Histograms SetHistograms(); // Final setup --------------------------------------------------- FinaliseMeasurement(); - + fSaveFine = false; }; bool T2K_NuMu_CC0pi_OC_XSec_2DPcos::isSignal(FitEvent *event){ return SignalDef::isCC0pi(event, 14, EnuMin, EnuMax); }; void T2K_NuMu_CC0pi_OC_XSec_2DPcos::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; }; void T2K_NuMu_CC0pi_OC_XSec_2DPcos::FillHistograms(){ Measurement1D::FillHistograms(); if (Signal){ FillMCSlice( fXVar, fYVar, Weight ); } } void T2K_NuMu_CC0pi_OC_XSec_2DPcos::ConvertEventRates(){ for (size_t i = 0; i < nangbins; i++){ - if(Target=="O") fMCHistNuMuO_Slices[i]->GetSumw2(); - else if(Target=="C") fMCHistNuMuC_Slices[i]->GetSumw2(); + fMCHist_Slices[i]->GetSumw2(); } // Do standard conversion. Measurement1D::ConvertEventRates(); // Scale MC slices by their bin width for (size_t i = 0; i < nangbins; ++i) { - if(Target=="O") fMCHistNuMuO_Slices[i]->Scale(1. / (angular_binning_costheta[i + 1] - angular_binning_costheta[i])); - else if(Target=="C") fMCHistNuMuC_Slices[i]->Scale(1. / (angular_binning_costheta[i + 1] - angular_binning_costheta[i])); + fMCHist_Slices[i]->Scale(1. / (angular_binning_costheta[i + 1] - angular_binning_costheta[i])); } // Now Convert into 1D histogram fMCHist->Reset(); int bincount = 0; for (size_t i = 0; i < nangbins; i++){ - if(Target=="O"){ - for (int j = 0; j < fMCHistNuMuO_Slices[i]->GetNbinsX(); j++){ - fMCHist->SetBinContent(bincount+1, fMCHistNuMuO_Slices[i]->GetBinContent(j+1)); - bincount++; - } - } - else if(Target=="C"){ - for (int j = 0; j < fMCHistNuMuC_Slices[i]->GetNbinsX(); j++){ - fMCHist->SetBinContent(bincount+1, fMCHistNuMuC_Slices[i]->GetBinContent(j+1)); - bincount++; - } + for (int j = 0; j < fMCHist_Slices[i]->GetNbinsX(); j++){ + fMCHist->SetBinContent(bincount+1, fMCHist_Slices[i]->GetBinContent(j+1)); + bincount++; } } return; } void T2K_NuMu_CC0pi_OC_XSec_2DPcos::FillMCSlice(double x, double y, double w){ for (size_t i = 0; i < nangbins; ++i) { if ((y > angular_binning_costheta[i]) && (y <= angular_binning_costheta[i + 1])) { - if(Target=="O") fMCHistNuMuO_Slices[i]->Fill(x, w); - else if(Target=="C") fMCHistNuMuC_Slices[i]->Fill(x, w); + fMCHist_Slices[i]->Fill(x, w); } } } void T2K_NuMu_CC0pi_OC_XSec_2DPcos::SetHistograms(){ // Read covariance matrix fInputFileCov = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointO-C/covmatrix_noreg.root").c_str(),"READ"); - TH1D* hLinearResult; - int Nbins; - - if(Target=="O"){ - fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointO-C/linear_unreg_results_O_nuisance.root").c_str(),"READ"); - // Read 1D data histogram - hLinearResult = (TH1D*) fInputFile->Get("LinResult"); - - Nbins = hLinearResult->GetNbinsX(); - - // Make covariance matrix - fFullCovar = new TMatrixDSym(Nbins); - TMatrixDSym* tempcov = (TMatrixDSym*) fInputFileCov->Get("covmatrixObin"); - - for(int ibin=0; ibinSetBinContent(bin+1, hLinearResult->GetBinContent(bin+1)); - } + fInputFile = new TFile(input_file_name.c_str(), "READ"); + TH1D* hLinearResult = (TH1D*) fInputFile->Get("LinResult"); + int Nbins = hLinearResult->GetNbinsX(); - fDataHist->Reset(); - int bincount = 0; - for (size_t i = 0; i < nangbins; i++){ - // Make slices for data - fDataHistNuMuO_Slices.push_back((TH1D*) fInputFile->Get(Form("dataslice_%zu",i))->Clone()); - fDataHistNuMuO_Slices[i]->SetNameTitle(Form("T2K_NuMu_CC0pi_O_2DPcos_data_Slice%zu",i), - (Form("T2K_NuMu_CC0pi_O_2DPcos_data_Slice%zu",i))); - fDataHistNuMuO_Slices[i]->Scale(1E-39); - // Loop over nbins and set errors from covariance - for (int j = 0; j < fDataHistNuMuO_Slices[i]->GetNbinsX(); j++){ - fDataHistNuMuO_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); - - fDataHist->SetBinContent(bincount+1, fDataHistNuMuO_Slices[i]->GetBinContent(j+1)); - fDataHist->SetBinError(bincount+1, fDataHistNuMuO_Slices[i]->GetBinError(j+1)); - bincount++; - } - - // Save MC slices - fMCHistNuMuO_Slices.push_back((TH1D*) fDataHistNuMuO_Slices[i]->Clone()); - fMCHistNuMuO_Slices[i]->SetNameTitle(Form("T2K_NuMu_CC0pi_O_2DPcos_MC_Slice%zu",i), (Form("T2K_NuMu_CC0pi_O_2DPcos_MC_Slice%zu",i))); - - SetAutoProcessTH1(fDataHistNuMuO_Slices[i],kCMD_Write); - SetAutoProcessTH1(fMCHistNuMuO_Slices[i]); - } - } - else if(Target=="C"){ - - fInputFile = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointO-C/linear_unreg_results_C_nuisance.root").c_str(),"READ"); - - // Read 1D data histogram - hLinearResult = (TH1D*) fInputFile->Get("LinResult"); - - Nbins = hLinearResult->GetNbinsX(); - - // Make the covariance matrix - fFullCovar = new TMatrixDSym(Nbins); - TMatrixDSym* tempcov = (TMatrixDSym*) fInputFileCov->Get("covmatrixCbin"); - - for(int ibin=0; ibinGet(covar_name.c_str()); - // Now Convert into 1D histrogram - fDataHist = new TH1D("LinarResultCarbon","LinarResultCarbon",Nbins,0,Nbins); - for (int bin = 0; bin < Nbins; bin++){ - fDataHist->SetBinContent(bin+1, hLinearResult->GetBinContent(bin+1)); + for(int ibin=0; ibinSetBinContent(bin+1, hLinearResult->GetBinContent(bin+1)); + } - fDataHist->Reset(); - - int bincount=0; - for (size_t i = 0; i < nangbins; i++){ - // Make slices for data - fDataHistNuMuC_Slices.push_back((TH1D*) fInputFile->Get(Form("dataslice_%zu",i))->Clone()); - fDataHistNuMuC_Slices[i]->SetNameTitle(Form("T2K_NuMu_CC0pi_C_2DPcos_data_Slice%zu",i), - (Form("T2K_NuMu_CC0pi_C_2DPcos_data_Slice%zu",i))); - - fDataHistNuMuC_Slices[i]->Scale(1E-39); - //Loop over nbins and set errors from covariance - for (int j = 0; j < fDataHistNuMuC_Slices[i]->GetNbinsX(); j++){ - fDataHistNuMuC_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); - - fDataHist->SetBinContent(bincount+1, fDataHistNuMuC_Slices[i]->GetBinContent(j+1)); - fDataHist->SetBinError(bincount+1, fDataHistNuMuC_Slices[i]->GetBinError(j+1)); - bincount++; - } - - //Save MC slices - fMCHistNuMuC_Slices.push_back((TH1D*) fDataHistNuMuC_Slices[i]->Clone()); - fMCHistNuMuC_Slices[i]->SetNameTitle(Form("T2K_NuMu_CC0pi_C_2DPcos_MC_Slice%zu",i), (Form("T2K_NuMu_CC0pi_C_2DPcos_MC_Slice%zu",i))); - - SetAutoProcessTH1(fDataHistNuMuC_Slices[i],kCMD_Write); - SetAutoProcessTH1(fMCHistNuMuC_Slices[i]); + fDataHist->Reset(); + int bincount = 0; + for (size_t i = 0; i < nangbins; i++){ + // Make slices for data + fDataHist_Slices.push_back((TH1D*) fInputFile->Get(Form("dataslice_%zu",i))->Clone()); + fDataHist_Slices[i]->SetNameTitle(Form("%s_data_Slice%zu",name.c_str(), i), + (Form("%s_data_Slice%zu%s",name.c_str(),i,titles.c_str()))); + fDataHist_Slices[i]->Scale(1E-39); + // Loop over nbins and set errors from covariance + for (int j = 0; j < fDataHist_Slices[i]->GetNbinsX(); j++){ + fDataHist_Slices[i]->SetBinError(j+1, sqrt((*fFullCovar)(bincount,bincount))*1E-38); + + fDataHist->SetBinContent(bincount+1, fDataHist_Slices[i]->GetBinContent(j+1)); + fDataHist->SetBinError(bincount+1, fDataHist_Slices[i]->GetBinError(j+1)); + bincount++; } - } - return; + // Save MC slices + fMCHist_Slices.push_back((TH1D*) fDataHist_Slices[i]->Clone()); + fMCHist_Slices[i]->SetNameTitle(Form("%s_MC_Slice%zu",name.c_str(),i), + Form("%s_MC_Slice%zu%s",name.c_str(),i,titles.c_str())); + SetAutoProcessTH1(fDataHist_Slices[i],kCMD_Write); + SetAutoProcessTH1(fMCHist_Slices[i]); + } + return; }; diff --git a/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.h b/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.h index 8c45fd1..fe630d2 100644 --- a/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.h +++ b/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos.h @@ -1,68 +1,65 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_NUMU_CC0PI_OC_XSEC_2DPCOS_H_SEEN #define T2K_NUMU_CC0PI_OC_XSEC_2DPCOS_H_SEEN #include "Measurement1D.h" #include "TH2Poly.h" class T2K_NuMu_CC0pi_OC_XSec_2DPcos : public Measurement1D { public: /// Basic Constructor. /// /brief Parses two different measurements. /// T2K_NuMu_CC0pi_OC_XSec_2DPcos(nuiskey samplekey); /// Virtual Destructor ~T2K_NuMu_CC0pi_OC_XSec_2DPcos() {}; /// Signal definition bool isSignal(FitEvent *nvect); /// Read histograms void SetHistograms(); /// Bin Tmu CosThetaMu void FillEventVariables(FitEvent* customEvent); // Fill Histograms void FillHistograms(); /// Event scaling void ConvertEventRates(); private: TFile* fInputFile; TFile* fInputFileCov; - std::vector fMCHistNuMuO_Slices; - std::vector fDataHistNuMuO_Slices; - std::vector fMCHistNuMuC_Slices; - std::vector fDataHistNuMuC_Slices; + std::vector fMCHist_Slices; + std::vector fDataHist_Slices; double pmu, CosThetaMu; std::string Target; void FillMCSlice(double x, double y, double w); - }; #endif diff --git a/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.cxx b/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.cxx index 1ad9e6a..1209f32 100644 --- a/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.cxx +++ b/src/T2K/T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.cxx @@ -1,161 +1,162 @@ #include "T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint.h" //******************************************************************** T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint::T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint(nuiskey samplekey){ //******************************************************************** fSettings = LoadSampleSettings(samplekey); std::string descrip = "T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint. \n" "Target: O-C \n" "Flux: T2K 2.5 degree off-axis (ND280) \n" "Signal: CC0pi\n" "DOI:10.1103/PhysRevD.101.112004"; fSettings.SetTitle("T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint"); fSettings.DefineAllowedSpecies("numu"); fSettings.SetDescription(descrip); fSettings.SetXTitle("p_{#mu}-cos#theta_{#mu}"); - fSettings.SetYTitle("d^{2}#sigma/dP_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); + fSettings.SetYTitle("d^{2}#sigma/dp_{#mu}dcos#theta_{#mu} (cm^{2}/GeV)"); fSettings.SetAllowedTypes("DIAG,FULL/FREE,SHAPE,FIX/SYSTCOV/STATCOV","FIX"); fSettings.SetEnuRange(0.0, 30.0); fSettings.DefineAllowedTargets("O,C"); FinaliseSampleSettings(); if (fSubInFiles.size() != 2) { NUIS_ABORT("T2K NuMuCC0pi O-C joint requires input files in format: NuMuCC0pi on O and NuMuCC0pi on C"); } std::string inFileNuMuO = fSubInFiles.at(0); std::string inFileNuMuC = fSubInFiles.at(1); // Create some config keys nuiskey NuMuCC0piOKey = Config::CreateKey("sample"); NuMuCC0piOKey.SetS("input", inFileNuMuO); NuMuCC0piOKey.SetS("type", fSettings.GetS("type")); NuMuCC0piOKey.SetS("name", "T2K_NuMu_CC0pi_O_XSec_2DPcos"); NuMuCC0piO = new T2K_NuMu_CC0pi_OC_XSec_2DPcos(NuMuCC0piOKey); nuiskey NuMuCC0piCKey = Config::CreateKey("sample"); NuMuCC0piCKey.SetS("input", inFileNuMuC); NuMuCC0piCKey.SetS("type", fSettings.GetS("type")); NuMuCC0piCKey.SetS("name", "T2K_NuMu_CC0pi_C_XSec_2DPcos"); NuMuCC0piC = new T2K_NuMu_CC0pi_OC_XSec_2DPcos(NuMuCC0piCKey); // Sort out the data hist this->CombineDataHists(); // Set the covariance SetCovariance(); // Add to chain for processing fSubChain.clear(); fSubChain.push_back(NuMuCC0piO); fSubChain.push_back(NuMuCC0piC); // This saves information from the sub-measurements fSaveSubMeas = true; + fSaveFine = false; FinaliseMeasurement(); }; //******************************************************************** void T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint::SetCovariance(){ //******************************************************************** // Read covariance matrix fInputFileCov = new TFile( (FitPar::GetDataBase() + "/T2K/CC0pi/JointO-C/covmatrix_noreg.root").c_str(),"READ"); TMatrixDSym* tempcov = (TMatrixDSym*) fInputFileCov->Get("covmatrixOeCbin"); fFullCovar = new TMatrixDSym(tempcov->GetNrows()); for(int ibin=0; ibinGetNrows(); ibin++) { for(int jbin=0; jbinGetNrows(); jbin++) { // The factor 1E-2 needed since the covariance matrix in the // data release is divided by 1E-78 (*fFullCovar)(ibin,jbin) = (*tempcov)(ibin,jbin)*1E-2; } } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); return; } //******************************************************************** void T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint::CombineDataHists(){ //******************************************************************** TH1D *hNuMuOData = (TH1D*)NuMuCC0piO->GetDataHistogram(); TH1D *hNuMuCData = (TH1D*)NuMuCC0piC->GetDataHistogram(); int nbins = hNuMuOData->GetNbinsX() + hNuMuCData->GetNbinsX(); fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), nbins, 0, nbins); fDataHist->SetDirectory(0); int count = 0; for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, hNuMuOData->GetBinContent(x+1)); fDataHist->SetBinError(count+1, hNuMuOData->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("NuMu CC0pi %.1f-%.1f", hNuMuOData->GetXaxis()->GetBinLowEdge(x+1), hNuMuOData->GetXaxis()->GetBinUpEdge(x+1))); count++; } for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, hNuMuCData->GetBinContent(x+1)); fDataHist->SetBinError(count+1, hNuMuCData->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("AntiNuMu CC0pi %.1f-%.1f", hNuMuCData->GetXaxis()->GetBinLowEdge(x+1), hNuMuCData->GetXaxis()->GetBinUpEdge(x+1))); count++; } } //******************************************************************** void T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint::SetHistograms() { //******************************************************************** NuMuCC0piO->SetHistograms(); NuMuCC0piC->SetHistograms(); return; } //******************************************************************** void T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint::FillHistograms() { //******************************************************************** NuMuCC0piO->FillHistograms(); NuMuCC0piC->FillHistograms(); return; } //******************************************************************** void T2K_NuMu_CC0pi_OC_XSec_2DPcos_joint::ConvertEventRates() { //******************************************************************** NuMuCC0piO->ConvertEventRates(); NuMuCC0piC->ConvertEventRates(); TH1D* hNuMuCC0piO = (TH1D*)NuMuCC0piO->GetMCHistogram(); TH1D* hNuMuCC0piC = (TH1D*)NuMuCC0piC->GetMCHistogram(); int count = 0; for (int i = 0; i < hNuMuCC0piO->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, hNuMuCC0piO->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, hNuMuCC0piO->GetBinError(i + 1)); count++; } for (int i = 0; i < hNuMuCC0piC->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, hNuMuCC0piC->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, hNuMuCC0piC->GetBinError(i + 1)); count++; } return; } diff --git a/src/T2K/T2K_SignalDef.cxx b/src/T2K/T2K_SignalDef.cxx index 1fc01a6..1b78778 100644 --- a/src/T2K/T2K_SignalDef.cxx +++ b/src/T2K/T2K_SignalDef.cxx @@ -1,328 +1,328 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "T2K_SignalDef.h" #include "FitUtils.h" namespace SignalDef { // T2K H2O signal definition // https://doi.org/10.1103/PhysRevD.97.012001 bool isCC1pip_T2K_PRD97_012001(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) { 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 // // https://arxiv.org/abs/1909.03936 bool isCC1pip_T2K_arxiv1909_03936(FitEvent *event, double EnuMin, double EnuMax, int pscuts) { // ****************************************************** if (!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 (pscuts == kMuonFwd) { return (cos_th_mu > 0); } double p_mu = FitUtils::p(Pmu) * 1000; if (pscuts & kMuonHighEff) { if ((cos_th_mu <= 0.2) || (p_mu <= 200)) { return false; } } TLorentzVector Ppip = event->GetHMFSParticle(211)->fP; double cos_th_pi = cos(FitUtils::th(Pnu, Ppip)); double p_pi = FitUtils::p(Ppip) * 1000; if ((pscuts & kPionFwd) && (cos_th_pi <= 0)) { return false; } if ((pscuts & kPionVFwd) && (cos_th_pi <= 0.2)) { return false; } if ((pscuts & kPionHighMom) && (p_pi <= 200)) { return false; } return true; }; bool isT2K_CC0pi(FitEvent *event, double EnuMin, double EnuMax, int ana) { // 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 = cos(Pnu.Vect().Angle(Pmu.Vect())); double p_mu = Pmu.Vect().Mag(); // If we're doing a restricted phase space, Analysis II asks for: // Cos(theta_mu) > 0.0 and p_mu > 200 MeV if (ana == kAnalysis_II) { if ((CosThetaMu < 0.0) || (p_mu < 200)) { return false; } } return true; } bool isT2K_CC0pi1p(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; // Proton phase space if (pp.Vect().Mag() < 500) { return false; } // Need exactly one proton with 500 MeV or more momentum std::vector protons = event->GetAllFSProton(); int nProtonsAboveThresh = 0; for (size_t i = 0; i < protons.size(); i++) { if (protons[i]->p() > 500) nProtonsAboveThresh++; } if (nProtonsAboveThresh != 1) return false; return true; } bool isT2K_CC0piNp(FitEvent *event, double EnuMin, double EnuMax) { // In this case, we specifically mean N>2, as defined in the T2K CC0pi 2018 paper // 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; // Proton phase space if (pp.Vect().Mag() < 500) { return false; } // Need exactly one proton with 500 MeV or more momentum std::vector protons = event->GetAllFSProton(); int nProtonsAboveThresh = 0; for (size_t i = 0; i < protons.size(); i++) { if (protons[i]->p() > 500) nProtonsAboveThresh++; } if (nProtonsAboveThresh <= 1) return false; return true; } bool isT2K_CC0pi0p(FitEvent *event, double EnuMin, double EnuMax) { // Require a numu CC0pi event if (!isCC0pi(event, 14, EnuMin, EnuMax)) return false; // Return true if no FS proton if (event->NumFSParticle(2212) == 0) return true; // Otherwise, check momentum of highest-momentum proton, and require it is below threshold TLorentzVector pnu = event->GetHMISParticle(14)->fP; TLorentzVector pmu = event->GetHMFSParticle(13)->fP; TLorentzVector pp = event->GetHMFSParticle(2212)->fP; // Proton phase space if (pp.Vect().Mag() < 500) { return true; } // If there are FS protons and the highest-momentum one is above threshold, return false return false; } // CC0pi antinu in the P0D https://arxiv.org/abs/1908.10249 bool isT2K_CC0piAnuP0D(FitEvent *event, double EnuMin, double EnuMax) { // Require a anumu CC0pi event if (!isCC0pi(event, -14, EnuMin, EnuMax)) return false; TLorentzVector pnu = event->GetHMISParticle(-14)->fP; TLorentzVector pmu = event->GetHMFSParticle(-13)->fP; double Pmu = pmu.Vect().Mag(); double CosThetaMu = cos(pnu.Vect().Angle(pmu.Vect())); // Muon phase space if (Pmu < 400 || Pmu > 3410) return false; if (Pmu < 530 && Pmu>=400 && CosThetaMu<0.84) return false; if (Pmu < 670 && Pmu>=530 && CosThetaMu<0.85) return false; if (Pmu < 800 && Pmu>=670 && CosThetaMu<0.88) return false; if (Pmu < 1000 &&Pmu>=800 && CosThetaMu<0.9) return false; if (Pmu < 1380 && Pmu>=1000 && CosThetaMu<0.91) return false; if (Pmu < 2010 && Pmu>=1380 && CosThetaMu<0.92) return false; if (Pmu < 3410 && Pmu>=2010 && CosThetaMu<0.95) 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; // Muon phase space // Pmu > 250 MeV, cos(theta_mu) > -0.6 (Sweet phase space!) if ((pmu.Vect().Mag() < 250) || cos(pnu.Vect().Angle(pmu.Vect())) < -0.6) { return false; } // Proton phase space // Pprot > 450 MeV, cos(theta_proton) > 0.4 if ((pp.Vect().Mag() < 450) || (pp.Vect().Mag() > 1E3) || (cos(pnu.Vect().Angle(pp.Vect())) < 0.4)) { return false; } return true; } bool isT2K_CC0pi_ifk(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; // Proton phase space // Pprot > 450 MeV, cos(theta_proton) > 0.4 if ((pp.Vect().Mag() < 450) || (cos(pnu.Vect().Angle(pp.Vect())) < 0.4)) { return false; } return true; } bool isT2K_CC0pi_1bin(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; // Muon phase space // if ((pmu.Vect().Mag() < 250) || cos(pnu.Vect().Angle(pmu.Vect())) < -0.6) { // return false; //} // Proton phase space if ((pp.Vect().Mag() < 450) || (cos(pnu.Vect().Angle(pp.Vect())) < 0.4)) { return false; } return true; } } // namespace SignalDef diff --git a/src/T2K/T2K_SignalDef.h b/src/T2K/T2K_SignalDef.h index 0d0f965..ba1256b 100644 --- a/src/T2K/T2K_SignalDef.h +++ b/src/T2K/T2K_SignalDef.h @@ -1,56 +1,56 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef T2K_SIGNALDEF_H_SEEN #define T2K_SIGNALDEF_H_SEEN #include "SignalDef.h" namespace SignalDef { bool isCC1pip_T2K_PRD97_012001(FitEvent *event, double EnuMin, double EnuMax); enum arxiv1909_03936_PScuts { kMuonFwd = (1 << 0), // cos(th_mu) > 0 kMuonHighEff = (1 << 1), // cos(th_mu) > 0.2, pmu > 200 kPionFwd = (1 << 2), // cos(th_pi) > 0 kPionVFwd = (1 << 3), // cos(th_pi) > 0.2 kPionHighMom = (1 << 4) // ppi > 200 }; bool isCC1pip_T2K_arxiv1909_03936(FitEvent *event, double EnuMin, double EnuMax, int cuts); enum PRD93112012_Ana { kAnalysis_I, kAnalysis_II, }; bool isT2K_CC0pi(FitEvent *event, double EnuMin, double EnuMax, int analysis); bool isT2K_CC0piNp(FitEvent *event, double EnuMin, double EnuMax); bool isT2K_CC0pi1p(FitEvent *event, double EnuMin, double EnuMax); bool isT2K_CC0pi0p(FitEvent *event, double EnuMin, double EnuMax); bool isT2K_CC0pi_STV(FitEvent *event, double EnuMin, double EnuMax); bool isT2K_CC0pi_1bin(FitEvent *event, double EnuMin, double EnuMax); bool isT2K_CC0pi_ifk(FitEvent *event, double EnuMin, double EnuMax); bool isT2K_CC0piAnuP0D(FitEvent *event, double EnuMin, double EnuMax); // TN328 } // namespace SignalDef #endif diff --git a/src/T2K/T2K_nueCCinc_XSec_joint.cxx b/src/T2K/T2K_nueCCinc_XSec_joint.cxx index 8665271..f799f34 100644 --- a/src/T2K/T2K_nueCCinc_XSec_joint.cxx +++ b/src/T2K/T2K_nueCCinc_XSec_joint.cxx @@ -1,245 +1,246 @@ #include "T2K_nueCCinc_XSec_joint.h" //******************************************************************** T2K_nueCCinc_XSec_joint::T2K_nueCCinc_XSec_joint(nuiskey samplekey){ //******************************************************************** fSettings = LoadSampleSettings(samplekey); std::string descrip = "T2K_nueCCinc_XSec_joint. \n" "Target: CH \n" "Flux: T2K FHC nue \n" "Signal: CC-inclusive \n"; fSettings.SetTitle("T2K #nu_{e}-CC-inclusive p_{e} and cos#theta_{e} joint"); fSettings.DefineAllowedSpecies("nue, nueb"); fSettings.SetCovarInput(FitPar::GetDataBase() + "/T2K/CCinc/nue_2019/fract_covar_both.txt"); fSettings.SetDescription(descrip); - fSettings.SetXTitle(""); + fSettings.SetXTitle("p_{e}-cos#theta_{e}"); fSettings.SetYTitle("#frac{d#sigma}{dx} (cm^{2}/nucleon)"); fSettings.SetEnuRange(0.0, 30.0); fSettings.DefineAllowedTargets("C,H"); FinaliseSampleSettings(); if (fSubInFiles.size() != 3) { NUIS_ABORT("T2K nue joint requires input files in format: FHC nue; RHC nue; RHC nuebar"); } std::string inFileFHCNue = fSubInFiles.at(0); std::string inFileRHCNue = fSubInFiles.at(1); std::string inFileRHCNuebar = fSubInFiles.at(2); // Make the Pe distributions nuiskey FHCNuePeKey = Config::CreateKey("sample"); FHCNuePeKey.SetS("input", inFileFHCNue); FHCNuePeKey.SetS("type", fSettings.GetS("type")); FHCNuePeKey.SetS("name", "T2K_nueCCinc_XSec_1Dpe_FHC"); FHC_nue_pe = new T2K_nueCCinc_XSec_1Dpe(FHCNuePeKey); nuiskey RHCNuePeKey = Config::CreateKey("sample"); RHCNuePeKey.SetS("input", inFileRHCNue); RHCNuePeKey.SetS("type", fSettings.GetS("type")); RHCNuePeKey.SetS("name", "T2K_nueCCinc_XSec_1Dpe_RHC"); RHC_nue_pe = new T2K_nueCCinc_XSec_1Dpe(RHCNuePeKey); nuiskey RHCNuebarPeKey = Config::CreateKey("sample"); RHCNuebarPeKey.SetS("input", inFileRHCNuebar); RHCNuebarPeKey.SetS("type", fSettings.GetS("type")); RHCNuebarPeKey.SetS("name", "T2K_nuebarCCinc_XSec_1Dpe_RHC"); RHC_nuebar_pe = new T2K_nueCCinc_XSec_1Dpe(RHCNuebarPeKey); // Now the thetae distributions nuiskey FHCNueTheKey = Config::CreateKey("sample"); FHCNueTheKey.SetS("input", inFileFHCNue); FHCNueTheKey.SetS("type", fSettings.GetS("type")); FHCNueTheKey.SetS("name", "T2K_nueCCinc_XSec_1Dthe_FHC"); FHC_nue_the = new T2K_nueCCinc_XSec_1Dthe(FHCNueTheKey); nuiskey RHCNueTheKey = Config::CreateKey("sample"); RHCNueTheKey.SetS("input", inFileRHCNue); RHCNueTheKey.SetS("type", fSettings.GetS("type")); RHCNueTheKey.SetS("name", "T2K_nueCCinc_XSec_1Dthe_RHC"); RHC_nue_the = new T2K_nueCCinc_XSec_1Dthe(RHCNueTheKey); nuiskey RHCNuebarTheKey = Config::CreateKey("sample"); RHCNuebarTheKey.SetS("input", inFileRHCNuebar); RHCNuebarTheKey.SetS("type", fSettings.GetS("type")); RHCNuebarTheKey.SetS("name", "T2K_nuebarCCinc_XSec_1Dthe_RHC"); RHC_nuebar_the = new T2K_nueCCinc_XSec_1Dthe(RHCNuebarTheKey); // Sort out the data hist this->CombineDataHists(); // This is a fractional covariance. Need to account for that SetFractCovarFromTextFile(fSettings.GetCovarInput()); SetShapeCovar(); // Add to chain for processing fSubChain.clear(); fSubChain.push_back(FHC_nue_pe); fSubChain.push_back(RHC_nue_pe); fSubChain.push_back(RHC_nuebar_pe); fSubChain.push_back(FHC_nue_the); fSubChain.push_back(RHC_nue_the); fSubChain.push_back(RHC_nuebar_the); // This saves information from the sub-measurements fSaveSubMeas = true; + fSaveFine = false; FinaliseMeasurement(); }; //******************************************************************** void T2K_nueCCinc_XSec_joint::SetFractCovarFromTextFile(std::string covfile){ //******************************************************************** if (!fDataHist){ NUIS_ERR(FTL, "fDataHist is required to call T2K_nueCCinc_XSec_joint::SetFractCovarFromTextFile"); throw; } NUIS_LOG(SAM, "Reading fractional covariance from text file: " << covfile); int dim = fDataHist->GetNbinsX(); TMatrixD *tempmat = StatUtils::GetMatrixFromTextFile(covfile, dim, dim); // Make a symmetric covariance fFullCovar = new TMatrixDSym(tempmat->GetNrows()); for (int i = 0; i < tempmat->GetNrows(); i++) { for (int j = 0; j < tempmat->GetNrows(); j++) { (*fFullCovar)(i, j) = fDataHist->GetBinContent(i+1)*1E38 *(*tempmat)(i, j)*fDataHist->GetBinContent(j+1)*1E38; } } covar = StatUtils::GetInvert(fFullCovar); fDecomp = StatUtils::GetDecomp(fFullCovar); } //******************************************************************** void T2K_nueCCinc_XSec_joint::CombineDataHists(){ //******************************************************************** TH1D *FHC_nue_pe_data = (TH1D*)FHC_nue_pe->GetDataHistogram(); TH1D *RHC_nue_pe_data = (TH1D*)RHC_nue_pe->GetDataHistogram(); TH1D *RHC_nuebar_pe_data = (TH1D*)RHC_nuebar_pe->GetDataHistogram(); TH1D *FHC_nue_the_data = (TH1D*)FHC_nue_the->GetDataHistogram(); TH1D *RHC_nue_the_data = (TH1D*)RHC_nue_the->GetDataHistogram(); TH1D *RHC_nuebar_the_data = (TH1D*)RHC_nuebar_the->GetDataHistogram(); int nbins = FHC_nue_pe_data->GetNbinsX() + RHC_nue_pe_data->GetNbinsX() + RHC_nuebar_pe_data->GetNbinsX() + FHC_nue_the_data->GetNbinsX() + RHC_nue_the_data->GetNbinsX() + RHC_nuebar_the_data->GetNbinsX(); fDataHist = new TH1D((fSettings.GetName() + "_data").c_str(), (fSettings.GetFullTitles()).c_str(), nbins, 0, nbins); fDataHist->SetDirectory(0); // Bit ugly, but... int count = 0; // Start with pe for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, FHC_nue_pe_data->GetBinContent(x+1)); fDataHist->SetBinError(count+1, FHC_nue_pe_data->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("FHC #nu_{e} %.1f #leq p_{e} #leq %.1f", FHC_nue_pe_data->GetXaxis()->GetBinLowEdge(x+1), FHC_nue_pe_data->GetXaxis()->GetBinUpEdge(x+1))); count++; } for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, RHC_nue_pe_data->GetBinContent(x+1)); fDataHist->SetBinError(count+1, RHC_nue_pe_data->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("RHC #nu_{e} %.1f #leq p_{e} #leq %.1f", RHC_nue_pe_data->GetXaxis()->GetBinLowEdge(x+1), RHC_nue_pe_data->GetXaxis()->GetBinUpEdge(x+1))); count++; } for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, RHC_nuebar_pe_data->GetBinContent(x+1)); fDataHist->SetBinError(count+1, RHC_nuebar_pe_data->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("RHC #bar{#nu}_{e} %.1f #leq p_{e} #leq %.1f", RHC_nuebar_pe_data->GetXaxis()->GetBinLowEdge(x+1), RHC_nuebar_pe_data->GetXaxis()->GetBinUpEdge(x+1))); count++; } // Now thetee for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, FHC_nue_the_data->GetBinContent(x+1)); fDataHist->SetBinError(count+1, FHC_nue_the_data->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("FHC #nu_{e} %.1f #leq cos#theta_e #leq %.1f", FHC_nue_the_data->GetXaxis()->GetBinLowEdge(x+1), FHC_nue_the_data->GetXaxis()->GetBinUpEdge(x+1))); count++; } for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, RHC_nue_the_data->GetBinContent(x+1)); fDataHist->SetBinError(count+1, RHC_nue_the_data->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("RHC #nu_{e} %.1f #leq cos#theta_e #leq %.1f", RHC_nue_the_data->GetXaxis()->GetBinLowEdge(x+1), RHC_nue_the_data->GetXaxis()->GetBinUpEdge(x+1))); count++; } for (int x=0; xGetNbinsX(); ++x){ fDataHist->SetBinContent(count+1, RHC_nuebar_the_data->GetBinContent(x+1)); fDataHist->SetBinError(count+1, RHC_nuebar_the_data->GetBinError(x+1)); fDataHist->GetXaxis()->SetBinLabel(count+1, Form("RHC #bar{#nu}_{e} %.1f #leq cos#theta_e #leq %.1f", RHC_nuebar_the_data->GetXaxis()->GetBinLowEdge(x+1), RHC_nuebar_the_data->GetXaxis()->GetBinUpEdge(x+1))); count++; } } //******************************************************************** void T2K_nueCCinc_XSec_joint::MakePlots() { //******************************************************************** TH1D *FHC_nue_pe_mc = (TH1D*)FHC_nue_pe->GetMCHistogram(); TH1D *RHC_nue_pe_mc = (TH1D*)RHC_nue_pe->GetMCHistogram(); TH1D *RHC_nuebar_pe_mc = (TH1D*)RHC_nuebar_pe->GetMCHistogram(); TH1D *FHC_nue_the_mc = (TH1D*)FHC_nue_the->GetMCHistogram(); TH1D *RHC_nue_the_mc = (TH1D*)RHC_nue_the->GetMCHistogram(); TH1D *RHC_nuebar_the_mc = (TH1D*)RHC_nuebar_the->GetMCHistogram(); int count = 0; // Start with pe for (int i = 0; i < FHC_nue_pe_mc->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, FHC_nue_pe_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, FHC_nue_pe_mc->GetBinError(i + 1)); count++; } for (int i = 0; i < RHC_nue_pe_mc->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, RHC_nue_pe_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, RHC_nue_pe_mc->GetBinError(i + 1)); count++; } for (int i = 0; i < RHC_nuebar_pe_mc->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, RHC_nuebar_pe_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, RHC_nuebar_pe_mc->GetBinError(i + 1)); count++; } // Now thetae for (int i = 0; i < FHC_nue_the_mc->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, FHC_nue_the_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, FHC_nue_the_mc->GetBinError(i + 1)); count++; } for (int i = 0; i < RHC_nue_the_mc->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, RHC_nue_the_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, RHC_nue_the_mc->GetBinError(i + 1)); count++; } for (int i = 0; i < RHC_nuebar_the_mc->GetNbinsX(); ++i) { fMCHist->SetBinContent(count + 1, RHC_nuebar_the_mc->GetBinContent(i + 1)); fMCHist->SetBinError(count + 1, RHC_nuebar_the_mc->GetBinError(i + 1)); count++; } return; } diff --git a/src/Tests/CMakeLists.txt b/src/Tests/CMakeLists.txt index f02aea6..e72fcf7 100644 --- a/src/Tests/CMakeLists.txt +++ b/src/Tests/CMakeLists.txt @@ -1,58 +1,58 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ include_directories(${MINIMUM_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/Routines) include_directories(${CMAKE_SOURCE_DIR}/src/FCN) include_directories(${CMAKE_SOURCE_DIR}/src/MCStudies) include_directories(${CMAKE_SOURCE_DIR}/src/Smearceptance) include_directories(${EXP_INCLUDE_DIRECTORIES}) SET(TESTAPPS SignalDefTests ParserTests SmearceptanceTests) if(USE_MINIMIZER) # LIST(APPEND TESTAPPS FitMechanicsTests) endif() foreach(appimpl ${TESTAPPS}) add_executable(${appimpl} ${appimpl}.cxx) set(TARGETS_TO_BUILD ${TARGETS_TO_BUILD};${appimpl}) target_link_libraries(${appimpl} ${MODULETargets}) target_link_libraries(${appimpl} ${CMAKE_DEPENDLIB_FLAGS}) target_link_libraries(${appimpl} ${ROOT_LIBS}) if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "") set_target_properties(${appimpl} PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS}) endif() install(TARGETS ${appimpl} DESTINATION tests) add_test(${appimpl} ${appimpl} 1) endforeach() list (FIND TESTAPPS FitMechanicsTests _index) if (${_index} GREATER -1) add_library(DummySample SHARED DummySample.cxx) target_link_libraries(DummySample ${MODULETargets}) target_link_libraries(DummySample ${CMAKE_DEPENDLIB_FLAGS}) target_link_libraries(DummySample ${ROOT_LIBS}) if(NOT "${CMAKE_LINK_FLAGS}" STREQUAL "") set_target_properties(DummySample PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS}) endif() install(TARGETS DummySample DESTINATION tests) endif() diff --git a/src/Utils/BeamUtils.cxx b/src/Utils/BeamUtils.cxx index 0e996f6..54ff78a 100644 --- a/src/Utils/BeamUtils.cxx +++ b/src/Utils/BeamUtils.cxx @@ -1,327 +1,327 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "BeamUtils.h" std::vector BeamUtils::ParseSpeciesToIntVect(std::string spc) { // Split by comma std::vector splitspc = GeneralUtils::ParseToStr(spc, ","); std::vector convspc; // Run through hard coded list for (size_t i = 0; i < splitspc.size(); i++) { std::string type = splitspc[i]; if (!type.compare("electron")) convspc.push_back(11); else if (!type.compare("positron")) convspc.push_back(-11); else if (!type.compare("muon")) convspc.push_back(13); else if (!type.compare("antimuon")) convspc.push_back(-13); else if (!type.compare("nue")) convspc.push_back(12); else if (!type.compare("numu")) convspc.push_back(14); else if (!type.compare("antinue")) convspc.push_back(12); else if (!type.compare("antinumu")) convspc.push_back(14); else { convspc.push_back(GeneralUtils::StrToInt(type)); } } return convspc; } ///____________________________________________________________________________ void BeamUtils::ListFluxIDs() { // Keep in sync with ConvertTargetIDs NUIS_LOG( FIT, "Possible Flux IDs: \n" << "\n MINERvA_fhc_numu : " << BeamUtils::ConvertFluxIDs("MINERvA_fhc_numu") << "\n MINERvA_fhc_numunumubar : " << BeamUtils::ConvertFluxIDs("MINERvA_fhc_numunumubar") << "\n MINERvA_fhc_nue : " << BeamUtils::ConvertFluxIDs("MINERvA_fhc_nue") << "\n MINERvA_fhc_nuenuebar : " << BeamUtils::ConvertFluxIDs("MINERvA_fhc_nuenuebar") << "\n MINERvA_fhc_all : " << BeamUtils::ConvertFluxIDs("MINERvA_fhc_all") << "\n MINERvA_rhc_numubar : " << BeamUtils::ConvertFluxIDs("MINERvA_rhc_numubar") << "\n MINERvA_rhc_numubarnumu : " << BeamUtils::ConvertFluxIDs("MINERvA_rhc_numubarnumu") << "\n MINERvA_rhc_nuebar : " << BeamUtils::ConvertFluxIDs("MINERvA_rhc_nuebar") << "\n MINERvA_rhc_nuebarnue : " << BeamUtils::ConvertFluxIDs("MINERvA_rhc_nuebarnue") << "\n MINERvA_rhc_all : " << BeamUtils::ConvertFluxIDs("MINERvA_rhc_all") << "\n MiniBooNE_fhc_numu : " << BeamUtils::ConvertFluxIDs("MiniBooNE_fhc_numu") << "\n MiniBooNE_fhc_numubar : " << BeamUtils::ConvertFluxIDs("MiniBooNE_fhc_numubar") << "\n MiniBooNE_fhc_numunumubar : " << BeamUtils::ConvertFluxIDs("MiniBooNE_fhc_numunumubar") << "\n MiniBooNE_fhc_all : " << BeamUtils::ConvertFluxIDs("MiniBooNE_fhc_all") << "\n MiniBooNE_rhc_numubar : " << BeamUtils::ConvertFluxIDs("MiniBooNE_rhc_numubar") << "\n MiniBooNE_rhc_numu : " << BeamUtils::ConvertFluxIDs("MiniBooNE_rhc_numu") << "\n MiniBooNE_rhc_numubarnumu : " << BeamUtils::ConvertFluxIDs("MiniBooNE_rhc_numubarnumu") << "\n MiniBooNE_rhc_all : " << BeamUtils::ConvertFluxIDs("MiniBooNE_rhc_all") << "\n ArgoNeut_fhc_numu : " << BeamUtils::ConvertFluxIDs("ArgoNeut_fhc_numu") << "\n ArgoNeut_rhc_numubar : " << BeamUtils::ConvertFluxIDs("ArgoNeut_rhc_numubar") << "\n K2K_fhc_numu : " << BeamUtils::ConvertFluxIDs("K2K_fhc_numu") << "\n ND280_fhc_numu : " << BeamUtils::ConvertFluxIDs("ND280_fhc_numu") << "\n ND280_fhc_numubar : " << BeamUtils::ConvertFluxIDs("ND280_fhc_numubar") << "\n ND280_fhc_numunumubar : " << BeamUtils::ConvertFluxIDs("ND280_fhc_numunumubar") << "\n ND280_fhc_nue : " << BeamUtils::ConvertFluxIDs("ND280_fhc_nue") << "\n ND280_fhc_nuebar : " << BeamUtils::ConvertFluxIDs("ND280_fhc_nuebar") << "\n ND280_fhc_nuenuebar : " << BeamUtils::ConvertFluxIDs("ND280_fhc_nuenuebar") << "\n ND280_fhc_all : " << BeamUtils::ConvertFluxIDs("ND280_fhc_all") << "\n ND280_rhc_numubar : " << BeamUtils::ConvertFluxIDs("ND280_rhc_numubar") << "\n ND280_rhc_numu : " << BeamUtils::ConvertFluxIDs("ND280_rhc_numu") << "\n ND280_rhc_numubarnumu : " << BeamUtils::ConvertFluxIDs("ND280_rhc_numubarnumu") << "\n ND280_rhc_nuebar : " << BeamUtils::ConvertFluxIDs("ND280_rhc_nuebar") << "\n ND280_rhc_nue : " << BeamUtils::ConvertFluxIDs("ND280_rhc_nue") << "\n ND280_rhc_nuebarnue : " << BeamUtils::ConvertFluxIDs("ND280_rhc_nuebarnue") << "\n ND280_rhc_all : " << BeamUtils::ConvertFluxIDs("ND280_rhc_all") << "\n SK_fhc_numu : " << BeamUtils::ConvertFluxIDs("SK_fhc_numu") << "\n SK_fhc_numubar : " << BeamUtils::ConvertFluxIDs("SK_fhc_numubar") << "\n SK_fhc_numunumubar : " << BeamUtils::ConvertFluxIDs("SK_fhc_numunumubar") << "\n SK_fhc_nue : " << BeamUtils::ConvertFluxIDs("SK_fhc_nue") << "\n SK_fhc_nuebar : " << BeamUtils::ConvertFluxIDs("SK_fhc_nuebar") << "\n SK_fhc_nuenuebar : " << BeamUtils::ConvertFluxIDs("SK_fhc_nuenuebar") << "\n SK_fhc_all : " << BeamUtils::ConvertFluxIDs("SK_fhc_all") << "\n SK_rhc_numubar : " << BeamUtils::ConvertFluxIDs("SK_rhc_numubar") << "\n SK_rhc_numu : " << BeamUtils::ConvertFluxIDs("SK_rhc_numu") << "\n SK_rhc_numubarnumu : " << BeamUtils::ConvertFluxIDs("SK_rhc_numubarnumu") << "\n SK_rhc_nuebar : " << BeamUtils::ConvertFluxIDs("SK_rhc_nuebar") << "\n SK_rhc_nue : " << BeamUtils::ConvertFluxIDs("SK_rhc_nue") << "\n SK_rhc_nuebarnue : " << BeamUtils::ConvertFluxIDs("SK_rhc_nuebarnue") << "\n SK_rhc_all : " << BeamUtils::ConvertFluxIDs("SK_rhc_all") << "\n ANL_fhc_numu : " << BeamUtils::ConvertFluxIDs("ANL_fhc_numu") << "\n BNL_fhc_numu : " << BeamUtils::ConvertFluxIDs("BNL_fhc_numu") << "\n BNL_fhc_numu_ALT1986 : " << BeamUtils::ConvertFluxIDs("BNL_fhc_numu_ALT1986") << "\n BNL_fhc_numu_ALT1981 : " << BeamUtils::ConvertFluxIDs("BNL_fhc_numu_ALT1981") << "\n BEBC_fhc_numu : " << BeamUtils::ConvertFluxIDs("BEBC_fhc_numu") << "\n FNAL_fhc_numu : " << BeamUtils::ConvertFluxIDs("FNAL_fhc_numu") << "\n FNAL_rhc_numub : " << BeamUtils::ConvertFluxIDs("FNAL_rhc_numub") << "\n GGM_fhc_numu : " << BeamUtils::ConvertFluxIDs("GGM_fhc_numu")); } //____________________________________________________________________________ std::string BeamUtils::ConvertFluxIDs(std::string id) { char *const var = getenv("NUISANCE"); if (!var) { std::cout << "Cannot find top level directory! Set the NUISANCE " "environmental variable" << std::endl; exit(-1); } std::string topnuisancedir = std::string(var); std::string fluxfolder = topnuisancedir + "/data/flux/"; std::string inputs = ""; if (!id.compare("MINERvA_fhc_numu")) inputs = "minerva_flux.root,numu_fhc[14]"; else if (!id.compare("MINERvA_fhc_numunumubar")) inputs = "minerva_flux.root,numu_fhc[14],numubar_fhc[-14]"; else if (!id.compare("MINERvA_fhc_nue")) inputs = "minerva_flux.root,nue_fhc[12]"; else if (!id.compare("MINERvA_fhc_nuenuebar")) inputs = "minerva_flux.root,nue_fhc[12],nuebar_fhc[-12]"; else if (!id.compare("MINERvA_fhc_all")) inputs = "minerva_flux.root,numu_fhc[14],numubar_fhc[-14],nue_fhc[12]," "nuebar_fhc[-12]"; else if (!id.compare("MINERvA_rhc_numubar")) inputs = "minerva_flux.root,numubar_rhc[-14]"; else if (!id.compare("MINERvA_rhc_numubarnumu")) inputs = "minerva_flux.root,numubar_rhc[-14],numu_rhc[14]"; else if (!id.compare("MINERvA_rhc_nuebar")) inputs = "minerva_flux.root,nuebar_rhc[-12]"; else if (!id.compare("MINERvA_rhc_nuebarnue")) inputs = "minerva_flux.root,nuebar_rhc[-12],nue_rhc[12]"; else if (!id.compare("MINERvA_rhc_all")) inputs = "minerva_flux.root,numu_rhc[14],numubar_rhc[-14],nue_rhc[12]," "nuebar_rhc[-12]"; else if (!id.compare("MiniBooNE_fhc_numu")) inputs = "MiniBooNE_numu_flux.root,numu_mb[14]"; else if (!id.compare("MiniBooNE_fhc_numubar")) inputs = "MiniBooNE_numu_flux.root,numub_mb[-14]"; else if (!id.compare("MiniBooNE_fhc_numunumubar")) inputs = "MiniBooNE_numu_flux.root,numu_mb[14],numub_mb[-14]"; else if (!id.compare("MiniBooNE_fhc_all")) inputs = "MiniBooNE_numu_flux.root,numu_mb[14],numub_mb[-14],nue_mb[12]," "nueb_mb[-12]"; else if (!id.compare("MiniBooNE_rhc_numubar")) inputs = "MiniBooNE_numubar_flux.root,numub_mb[-14]"; else if (!id.compare("MiniBooNE_rhc_numu")) inputs = "MiniBooNE_numubar_flux.root,numu_mb[14]"; else if (!id.compare("MiniBooNE_rhc_numubarnumu")) inputs = "MiniBooNE_numubar_flux.root,numub_mb[-14],numu_mb[14]"; else if (!id.compare("MiniBooNE_rhc_all")) inputs = "MiniBooNE_numubar_flux.root,numub_mb[-14],numu_mb[14],nueb_mb[-" "12],nue_mb[12]"; else if (!id.compare("ArgoNeut_fhc_numu")) inputs = "ArgoNeut_numu_flux.root,numu[14]"; else if (!id.compare("ArgoNeut_rhc_numub")) inputs = "ArgoNeut_numub_flux,numub[-14]"; else if (!id.compare("K2K_fhc_numu")) inputs = "K2K_flux.root,numu_flux[14]"; else if (!id.compare("ND280_fhc_numu")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_numu[14]"; else if (!id.compare("ND280_fhc_numubar")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_numub[-14]"; else if (!id.compare("ND280_fhc_numunumubar")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_numu[14],enu_nd280_numub[-14]"; else if (!id.compare("ND280_fhc_nue")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_nue[12]"; else if (!id.compare("ND280_fhc_nuebar")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_nueb[-12]"; else if (!id.compare("ND280_fhc_nuenuebar")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_nue[12],enu_nd280_nueb[-12]"; else if (!id.compare("ND280_fhc_all")) inputs = "t2kflux_2016_plus250kA.root,enu_nd280_numu[14],enu_nd280_numub[-" "14],enu_nd280_nue[12],enu_nd280_nueb[-12]"; else if (!id.compare("ND280_rhc_numubar")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_numub[-14]"; else if (!id.compare("ND280_rhc_numu")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_numu[14]"; else if (!id.compare("ND280_rhc_numubarnumu")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_numub[-14],enu_nd280_numu[14]"; else if (!id.compare("ND280_rhc_nuebar")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_nueb[-12]"; else if (!id.compare("ND280_rhc_nue")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_nue[12]"; else if (!id.compare("ND280_rhc_nuebarnue")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_nueb[-12],enu_nd280_nue[12]"; else if (!id.compare("ND280_rhc_all")) inputs = "t2kflux_2016_minus250kA.root,enu_nd280_numub[-14],enu_nd280_numu[" "14],enu_nd280_nueb[-12],enu_nd280_nue[12]"; else if (!id.compare("SK_fhc_numu")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_numu[14]"; else if (!id.compare("SK_fhc_numubar")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_numub[-14]"; else if (!id.compare("SK_fhc_numunumubar")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_numu[14],enu_sk_numub[-14]"; else if (!id.compare("SK_fhc_nue")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_nue[12]"; else if (!id.compare("SK_fhc_nuebar")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_nueb[-12]"; else if (!id.compare("SK_fhc_nuenuebar")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_nue[12],enu_sk_nueb[-12]"; else if (!id.compare("SK_fhc_all")) inputs = "t2kflux_2016_plus250kA.root,enu_sk_numu[14],enu_sk_numub[-14]," "enu_sk_nue[12],enu_sk_nueb[-12]"; else if (!id.compare("SK_rhc_numubar")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_numub[-14]"; else if (!id.compare("SK_rhc_numu")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_numu[14]"; else if (!id.compare("SK_rhc_numubarnumu")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_numub[-14],enu_sk_numu[14]"; else if (!id.compare("SK_rhc_nuebar")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_nueb[-12]"; else if (!id.compare("SK_rhc_nue")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_nue[12]"; else if (!id.compare("SK_rhc_nuebarnue")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_nueb[-12],enu_sk_nue[12]"; else if (!id.compare("SK_rhc_all")) inputs = "t2kflux_2016_minus250kA.root,enu_sk_numub[-14],enu_sk_numu[14]," "enu_sk_nueb[-12],enu_nd280_nue[12]"; else if (!id.compare("ANL_fhc_numu")) inputs = "ANL_1977_2horn_rescan.root, numu_flux[14]"; else if (!id.compare("BNL_fhc_numu")) inputs = "BNL_NuInt02_rescan.root, numu_flux[14]"; else if (!id.compare("BNL_fhc_numu_ALT1986")) inputs = "BNL_1986_flux - ALTERNATIVE.root, numu_flux[14]"; else if (!id.compare("BNL_fhc_numu_ALT1981")) inputs = "BNL_CCQE_1981_rescan - ALTERNATIVE.root, numu_flux[14]"; else if (!id.compare("BEBC_fhc_numu")) inputs = "BEBC_Wachsmuth_numu_table.root, numu_flux[14]"; else if (!id.compare("FNAL_fhc_numu")) inputs = "FNAL_CCinc_1982_nu_MCadj.root, numu_flux[14]"; else if (!id.compare("FNAL_rhc_numub")) inputs = "FNAL_coh_1993_anu.root, numu_flux[-14]"; else if (!id.compare("GGM_fhc_numu")) inputs = "GGM_nu_flux_1979_rescan.root, numu_flux[14]"; else return ""; return fluxfolder + inputs; }; diff --git a/src/Utils/BeamUtils.h b/src/Utils/BeamUtils.h index 50d4efb..54dc2ee 100644 --- a/src/Utils/BeamUtils.h +++ b/src/Utils/BeamUtils.h @@ -1,47 +1,47 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef BEAM_UTILS_H #define BEAM_UTILS_H #include #include "FitLogger.h" #include "GeneralUtils.h" /*! * \addtogroup Utils * @{ */ /// Namespace for any global util functions related to beam simulation namespace BeamUtils{ /// @brief Converts comma separated string of beam ids into PDG vector /// /// e.g. 'numu,nue,numub,e,16' = <14,12,-14,11,16> std::vector ParseSpeciesToIntVect(std::string spc); /// @brief Convert flux ID to a flux definition for use in gen_nuisance std::string ConvertFluxIDs (std::string); /// @brief Lists all possible flux ids, should be kept in sync with convert function. void ListFluxIDs (void); } /*! @} */ #endif diff --git a/src/Utils/CMakeLists.txt b/src/Utils/CMakeLists.txt index a1dad16..7c86547 100644 --- a/src/Utils/CMakeLists.txt +++ b/src/Utils/CMakeLists.txt @@ -1,77 +1,77 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ set(HEADERFILES FitUtils.h GeneralUtils.h ParserUtils.h PlotUtils.h SignalDef.h BeamUtils.h TargetUtils.h OpenMPWrapper.h PhysConst.h ) set(IMPLFILES FitUtils.cxx GeneralUtils.cxx PlotUtils.cxx SignalDef.cxx BeamUtils.cxx TargetUtils.cxx ParserUtils.cxx ) set(LIBNAME Utils) 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(${MINIMUM_INCLUDE_DIRECTORIES}) include_directories(${CMAKE_SOURCE_DIR}/src/Logger) include_directories(${CMAKE_SOURCE_DIR}/src/Statistical) set_target_properties(${LIBNAME} PROPERTIES VERSION "${NUISANCE_VERSION_MAJOR}.${NUISANCE_VERSION_MINOR}.${NUISANCE_VERSION_REVISION}") #set_target_properties(${LIBNAME} PROPERTIES LINK_FLAGS ${ROOT_LD_FLAGS}) if(DEFINED PROJECTWIDE_EXTRA_DEPENDENCIES) add_dependencies(${LIBNAME} ${PROJECTWIDE_EXTRA_DEPENDENCIES}) endif() install(TARGETS ${LIBNAME} DESTINATION lib) #Can uncomment this to install the headers... but is it really neccessary? install(FILES ${HEADERFILES} DESTINATION include/Utils) set(MODULETargets ${MODULETargets} ${LIBNAME} PARENT_SCOPE) #add_executable(DumpROOTClassesFromVector DumpROOTClassesFromVector.cxx GeneralUtils.cxx FitLogger.cxx PythiaQuiet.f) # # #Strip out -lNuWro_event1 # string(REPLACE "-lNuWro_event1" "" NWEVSTRIPPED_CDF ${CMAKE_DEPENDLIB_FLAGS}) # cmessage(DEBUG "Attempted to strip out nuwro library: \"${CMAKE_DEPENDLIB_FLAGS}\" -> \"${NWEVSTRIPPED_CDF}\"") # target_link_libraries(DumpROOTClassesFromVector ${NWEVSTRIPPED_CDF}) # if(NOT CMAKE_LINK_FLAGS STREQUAL "") # set_target_properties(DumpROOTClassesFromVector PROPERTIES LINK_FLAGS ${CMAKE_LINK_FLAGS}) # endif() #install(TARGETS DumpROOTClassesFromVector DESTINATION bin) diff --git a/src/Utils/FitUtils.cxx b/src/Utils/FitUtils.cxx index 484f5f7..a79099b 100644 --- a/src/Utils/FitUtils.cxx +++ b/src/Utils/FitUtils.cxx @@ -1,1103 +1,1103 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitUtils.h" /* MISC Functions */ //******************************************************************** double *FitUtils::GetArrayFromMap(std::vector invals, std::map inmap) { //******************************************************************** double *outarr = new double[invals.size()]; int count = 0; for (size_t i = 0; i < invals.size(); i++) { outarr[count++] = inmap[invals.at(i)]; } return outarr; } /* MISC Event */ //******************************************************************** // Returns the kinetic energy of a particle in GeV double FitUtils::T(TLorentzVector part) { //******************************************************************** double E_part = part.E() / 1000.; double p_part = part.Vect().Mag() / 1000.; double m_part = sqrt(E_part * E_part - p_part * p_part); double KE_part = E_part - m_part; return KE_part; }; //******************************************************************** // Returns the momentum of a particle in GeV double FitUtils::p(TLorentzVector part) { //******************************************************************** double p_part = part.Vect().Mag() / 1000.; return p_part; }; double FitUtils::p(FitParticle *part) { return FitUtils::p(part->fP); }; //******************************************************************** // Returns the angle between two particles in radians double FitUtils::th(TLorentzVector part1, TLorentzVector part2) { //******************************************************************** double th = part1.Vect().Angle(part2.Vect()); return th; }; double FitUtils::th(FitParticle *part1, FitParticle *part2) { return FitUtils::th(part1->fP, part2->fP); }; // T2K CC1pi+ helper functions // //******************************************************************** // Returns the angle between q3 and the pion defined in Raquel's CC1pi+ on CH // paper // Uses "MiniBooNE formula" for Enu, here called EnuCC1pip_T2K_MB //******************************************************************** double FitUtils::thq3pi_CC1pip_T2K(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi) { // Want this in GeV TVector3 p_mu = pmu.Vect() * (1. / 1000.); // Get the reconstructed Enu // We are not using Michel e sample, so we have pion kinematic information double Enu = EnuCC1piprec(pnu, pmu, ppi, true); // Get neutrino unit direction, multiply by reconstructed Enu TVector3 p_nu = pnu.Vect() * (1. / (pnu.Vect().Mag())) * Enu; TVector3 p_pi = ppi.Vect() * (1. / 1000.); // This is now in GeV TVector3 q3 = (p_nu - p_mu); // Want this in GeV double th_q3_pi = q3.Angle(p_pi); return th_q3_pi; } //******************************************************************** // Returns the q3 defined in Raquel's CC1pi+ on CH paper // Uses "MiniBooNE formula" for Enu //******************************************************************** double FitUtils::q3_CC1pip_T2K(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi) { // Can't use the true Enu here; need to reconstruct it // We do have Michel e- here so reconstruct Enu by "MiniBooNE formula" without // pion kinematics // The bool false refers to that we don't have pion kinematics // Last bool refers to if we have pion kinematic information or not double Enu = EnuCC1piprec(pnu, pmu, ppi, false); TVector3 p_mu = pmu.Vect() * (1. / 1000.); TVector3 p_nu = pnu.Vect() * (1. / pnu.Vect().Mag()) * Enu; double q3 = (p_nu - p_mu).Mag(); return q3; } //******************************************************************** // Returns the W reconstruction from Raquel CC1pi+ CH thesis // Uses the MiniBooNE formula Enu //******************************************************************** double FitUtils::WrecCC1pip_T2K_MB(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi) { double E_mu = pmu.E() / 1000.; double p_mu = pmu.Vect().Mag() / 1000.; double E_nu = EnuCC1piprec(pnu, pmu, ppi, false); double a1 = (E_nu + PhysConst::mass_neutron) - E_mu; double a2 = E_nu - p_mu; double wrec = sqrt(a1 * a1 - a2 * a2); return wrec; } //******************************************************** double FitUtils::ProtonQ2QErec(double pE, double binding) { //******************************************************** const double V = binding / 1000.; // binding potential const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass const double mn_eff = mn - V; // effective proton mass const double pki = (pE / 1000.0) - mp; double q2qe = mn_eff * mn_eff - mp * mp + 2 * mn_eff * (pki + mp - mn_eff); return q2qe; }; //******************************************************************** double FitUtils::EnuQErec(TLorentzVector pmu, double costh, double binding, bool neutrino) { //******************************************************************** // Convert all values to GeV const double V = binding / 1000.; // binding potential const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass double mN_eff = mn - V; double mN_oth = mp; if (!neutrino) { mN_eff = mp - V; mN_oth = mn; } double el = pmu.E() / 1000.; double pl = (pmu.Vect().Mag()) / 1000.; // momentum of lepton double ml = sqrt(el * el - pl * pl); // lepton mass double rEnu = (2 * mN_eff * el - ml * ml + mN_oth * mN_oth - mN_eff * mN_eff) / (2 * (mN_eff - el + pl * costh)); return rEnu; }; // Another good old helper function double FitUtils::EnuQErec(TLorentzVector pmu, TLorentzVector pnu, double binding, bool neutrino) { return EnuQErec(pmu, cos(pnu.Vect().Angle(pmu.Vect())), binding, neutrino); } double FitUtils::Q2QErec(TLorentzVector pmu, double costh, double binding, bool neutrino) { double el = pmu.E() / 1000.; double pl = (pmu.Vect().Mag()) / 1000.; // momentum of lepton double ml = sqrt(el * el - pl * pl); // lepton mass double rEnu = EnuQErec(pmu, costh, binding, neutrino); double q2 = -ml * ml + 2. * rEnu * (el - pl * costh); return q2; }; double FitUtils::Q2QErec(TLorentzVector Pmu, TLorentzVector Pnu, double binding, bool neutrino) { double q2qe = Q2QErec(Pmu, cos(Pnu.Vect().Angle(Pmu.Vect())), binding, neutrino); return q2qe; } double FitUtils::EnuQErec(double pl, double costh, double binding, bool neutrino) { if (pl < 0) return 0.; // Make sure nobody is silly double mN_eff = PhysConst::mass_neutron - binding / 1000.; double mN_oth = PhysConst::mass_proton; if (!neutrino) { mN_eff = PhysConst::mass_proton - binding / 1000.; mN_oth = PhysConst::mass_neutron; } double ml = PhysConst::mass_muon; double el = sqrt(pl * pl + ml * ml); double rEnu = (2 * mN_eff * el - ml * ml + mN_oth * mN_oth - mN_eff * mN_eff) / (2 * (mN_eff - el + pl * costh)); return rEnu; }; double FitUtils::Q2QErec(double pl, double costh, double binding, bool neutrino) { if (pl < 0) return 0.; // Make sure nobody is silly double ml = PhysConst::mass_muon; double el = sqrt(pl * pl + ml * ml); double rEnu = EnuQErec(pl, costh, binding, neutrino); double q2 = -ml * ml + 2. * rEnu * (el - pl * costh); return q2; }; //******************************************************************** // Reconstructs Enu for CC1pi0 // Very similar for CC1pi+ reconstruction double FitUtils::EnuCC1pi0rec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi0) { //******************************************************************** double E_mu = pmu.E() / 1000; double p_mu = pmu.Vect().Mag() / 1000; double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); double E_pi0 = ppi0.E() / 1000; double p_pi0 = ppi0.Vect().Mag() / 1000; double m_pi0 = sqrt(E_pi0 * E_pi0 - p_pi0 * p_pi0); double th_nu_pi0 = pnu.Vect().Angle(ppi0.Vect()); const double m_n = PhysConst::mass_neutron; // neutron mass const double m_p = PhysConst::mass_proton; // proton mass double th_pi0_mu = ppi0.Vect().Angle(pmu.Vect()); double rEnu = (m_mu * m_mu + m_pi0 * m_pi0 + m_n * m_n - m_p * m_p - 2 * m_n * (E_pi0 + E_mu) + 2 * E_pi0 * E_mu - 2 * p_pi0 * p_mu * cos(th_pi0_mu)) / (2 * (E_pi0 + E_mu - p_pi0 * cos(th_nu_pi0) - p_mu * cos(th_nu_mu) - m_n)); return rEnu; }; //******************************************************************** // Reconstruct Q2 for CC1pi0 // Beware: uses true Enu, not reconstructed Enu double FitUtils::Q2CC1pi0rec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi0) { //******************************************************************** double E_mu = pmu.E() / 1000.; // energy of lepton in GeV double p_mu = pmu.Vect().Mag() / 1000.; // momentum of lepton double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); // lepton mass double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); // double rEnu = EnuCC1pi0rec(pnu, pmu, ppi0); //reconstructed neutrino energy // Use true neutrino energy double rEnu = pnu.E() / 1000.; double q2 = -m_mu * m_mu + 2. * rEnu * (E_mu - p_mu * cos(th_nu_mu)); return q2; }; //******************************************************************** // Reconstruct Enu for CC1pi+ // pionInfo reflects if we're using pion kinematics or not // In T2K CC1pi+ CH the Michel tag is used for pion in which pion kinematic info // is lost and Enu is reconstructed without pion kinematics double FitUtils::EnuCC1piprec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi, bool pionInfo) { //******************************************************************** double E_mu = pmu.E() / 1000.; double p_mu = pmu.Vect().Mag() / 1000.; double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); double E_pi = ppi.E() / 1000.; double p_pi = ppi.Vect().Mag() / 1000.; double m_pi = sqrt(E_pi * E_pi - p_pi * p_pi); const double m_n = PhysConst::mass_neutron; // neutron/proton mass // should really take proton mass for proton interaction, neutron for neutron // interaction. However, difference is pretty much negligable here! // need this angle too double th_nu_pi = pnu.Vect().Angle(ppi.Vect()); double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); double th_pi_mu = ppi.Vect().Angle(pmu.Vect()); double rEnu = -999; // If experiment doesn't have pion kinematic information (T2K CC1pi+ CH // example of this; Michel e sample has no directional information on pion) // We'll need to modify the reconstruction variables if (!pionInfo) { // Assumes that pion angle contribution contributes net zero // Also assumes the momentum of reconstructed pions when using Michel // electrons is 130 MeV // So need to redefine E_pi and p_pi // It's a little unclear what happens to the pmu . ppi term (4-vector); do // we include the angular contribution? // This below doesn't th_nu_pi = M_PI / 2.; p_pi = 0.130; E_pi = sqrt(p_pi * p_pi + m_pi * m_pi); // rEnu = (m_mu*m_mu + m_pi*m_pi - 2*m_n*(E_mu + E_pi) + 2*E_mu*E_pi - // 2*p_mu*p_pi) / (2*(E_mu + E_pi - p_mu*cos(th_nu_mu) - m_n)); } rEnu = (m_mu * m_mu + m_pi * m_pi - 2 * m_n * (E_pi + E_mu) + 2 * E_pi * E_mu - 2 * p_pi * p_mu * cos(th_pi_mu)) / (2 * (E_pi + E_mu - p_pi * cos(th_nu_pi) - p_mu * cos(th_nu_mu) - m_n)); return rEnu; }; //******************************************************************** // Reconstruct neutrino energy from outgoing particles; will differ from the // actual neutrino energy. Here we use assumption of a Delta resonance double FitUtils::EnuCC1piprecDelta(TLorentzVector pnu, TLorentzVector pmu) { //******************************************************************** const double m_Delta = PhysConst::mass_delta; // PDG value for Delta mass in GeV const double m_n = PhysConst::mass_neutron; // neutron/proton mass // should really take proton mass for proton interaction, neutron for neutron // interaction. However, difference is pretty much negligable here! double E_mu = pmu.E() / 1000; double p_mu = pmu.Vect().Mag() / 1000; double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); double rEnu = (m_Delta * m_Delta - m_n * m_n - m_mu * m_mu + 2 * m_n * E_mu) / (2 * (m_n - E_mu + p_mu * cos(th_nu_mu))); return rEnu; }; // MOVE TO T2K UTILS! //******************************************************************** // Reconstruct Enu using "extended MiniBooNE" as defined in Raquel's T2K TN // // Supposedly includes pion direction and binding energy of target nucleon // I'm not convinced (yet), maybe double FitUtils::EnuCC1piprec_T2K_eMB(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi) { //******************************************************************** // Unit vector for neutrino momentum TVector3 p_nu_vect_unit = pnu.Vect() * (1. / pnu.E()); double E_mu = pmu.E() / 1000.; TVector3 p_mu_vect = pmu.Vect() * (1. / 1000.); double E_pi = ppi.E() / 1000.; TVector3 p_pi_vect = ppi.Vect() * (1. / 1000.); double E_bind = 25. / 1000.; double m_p = PhysConst::mass_proton; // Makes life a little easier, gonna square this one double a1 = m_p - E_bind - E_mu - E_pi; // Just gets the magnitude square of the muon and pion momentum vectors double a2 = (p_mu_vect + p_pi_vect).Mag2(); // Gets the somewhat complicated scalar product between neutrino and // (p_mu+p_pi), scaled to Enu double a3 = p_nu_vect_unit * (p_mu_vect + p_pi_vect); double rEnu = (m_p * m_p - a1 * a1 + a2) / (2 * (m_p - E_bind - E_mu - E_pi + a3)); return rEnu; } //******************************************************************** // Reconstructed Q2 for CC1pi+ // // enuType describes how the neutrino energy is reconstructed // 0 uses true neutrino energy; case for MINERvA and MiniBooNE // 1 uses "extended MiniBooNE" reconstructed (T2K CH) // 2 uses "MiniBooNE" reconstructed (EnuCC1piprec with pionInfo = true) (T2K CH) // "MiniBooNE" reconstructed (EnuCC1piprec with pionInfo = false, the // case for T2K when using Michel tag) (T2K CH) // 3 uses Delta for reconstruction (T2K CH) double FitUtils::Q2CC1piprec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi, int enuType, bool pionInfo) { //******************************************************************** double E_mu = pmu.E() / 1000.; // energy of lepton in GeV double p_mu = pmu.Vect().Mag() / 1000.; // momentum of lepton double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); // lepton mass double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); // Different ways of reconstructing the neutrino energy; default is just to // use the truth (case 0) double rEnu = -999; switch (enuType) { case 0: // True neutrino energy, default; this is the case for when Q2 // defined as Q2 true (MiniBooNE, MINERvA) rEnu = pnu.E() / 1000.; break; case 1: // Extended MiniBooNE reconstructed, as defined by Raquel's CC1pi+ // CH T2K analysis rEnu = EnuCC1piprec_T2K_eMB(pnu, pmu, ppi); break; case 2: // MiniBooNE reconstructed, as defined by MiniBooNE and Raquel's // CC1pi+ CH T2K analysis and Linda's CC1pi+ H2O // Can have this with and without pion info, depending on if Michel tag // used (Raquel) rEnu = EnuCC1piprec(pnu, pmu, ppi, pionInfo); break; case 3: rEnu = EnuCC1piprecDelta(pnu, pmu); break; } // No need for default here since default value of enuType = 0, defined in // header double q2 = -m_mu * m_mu + 2. * rEnu * (E_mu - p_mu * cos(th_nu_mu)); return q2; }; //******************************************************************** // Returns the reconstructed W from a nucleon and an outgoing pion // // Could do this a lot more clever (pp + ppi).Mag() would do the job, but this // would be less instructive //******************************************************************** double FitUtils::MpPi(TLorentzVector pp, TLorentzVector ppi) { double E_p = pp.E(); double p_p = pp.Vect().Mag(); double m_p = sqrt(E_p * E_p - p_p * p_p); double E_pi = ppi.E(); double p_pi = ppi.Vect().Mag(); double m_pi = sqrt(E_pi * E_pi - p_pi * p_pi); double th_p_pi = pp.Vect().Angle(ppi.Vect()); // fairly easy thing to derive since bubble chambers measure the proton! double invMass = sqrt(m_p * m_p + m_pi * m_pi + 2 * E_p * E_pi - 2 * p_pi * p_p * cos(th_p_pi)); return invMass; }; //******************************************************** // Reconstruct the hadronic mass using neutrino and muon // Could technically do E_nu = EnuCC1pipRec(pnu,pmu,ppi) too, but this wwill be // reconstructed Enu; so gives reconstructed Wrec which most of the time isn't // used! // // Only MINERvA uses this so far; and the Enu is Enu_true // If we want W_true need to take initial state nucleon motion into account // Return value is in MeV!!! double FitUtils::Wrec(TLorentzVector pnu, TLorentzVector pmu) { //******************************************************** double E_mu = pmu.E(); double p_mu = pmu.Vect().Mag(); double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); // The factor of 1000 is necessary for downstream functions const double m_p = PhysConst::mass_proton * 1000; // MINERvA cut on W_exp which is tuned to W_true; so use true Enu from // generators double E_nu = pnu.E(); double w_rec = sqrt(m_p * m_p + m_mu * m_mu - 2 * m_p * E_mu + 2 * E_nu * (m_p - E_mu + p_mu * cos(th_nu_mu))); return w_rec; }; //******************************************************** // Reconstruct the true hadronic mass using the initial state and muon // Could technically do E_nu = EnuCC1pipRec(pnu,pmu,ppi) too, but this wwill be // reconstructed Enu; so gives reconstructed Wrec which most of the time isn't // used! // // No one seems to use this because it's fairly MC dependent! // Return value is in MeV!!! double FitUtils::Wtrue(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector pnuc) { //******************************************************** // Could simply do the TLorentzVector operators here but this is more // instructive? // ... and prone to errors ... double E_mu = pmu.E(); double p_mu = pmu.Vect().Mag(); double m_mu = sqrt(E_mu * E_mu - p_mu * p_mu); double th_nu_mu = pnu.Vect().Angle(pmu.Vect()); double E_nuc = pnuc.E(); double p_nuc = pnuc.Vect().Mag(); double m_nuc = sqrt(E_nuc * E_nuc - p_nuc * p_nuc); double th_nuc_mu = pmu.Vect().Angle(pnuc.Vect()); double th_nu_nuc = pnu.Vect().Angle(pnuc.Vect()); double E_nu = pnu.E(); double w_rec = sqrt(m_nuc * m_nuc + m_mu * m_mu - 2 * E_nu * E_mu + 2 * E_nu * p_mu * cos(th_nu_mu) - 2 * E_nuc * E_mu + 2 * p_nuc * p_mu * cos(th_nuc_mu) + 2 * E_nu * E_nuc - 2 * E_nu * p_nuc * cos(th_nu_nuc)); return w_rec; }; double FitUtils::SumKE_PartVect(std::vector const fps) { double sum = 0.0; for (size_t p_it = 0; p_it < fps.size(); ++p_it) { sum += fps[p_it]->KE(); } return sum; } double FitUtils::SumTE_PartVect(std::vector const fps) { double sum = 0.0; for (size_t p_it = 0; p_it < fps.size(); ++p_it) { sum += fps[p_it]->E(); } return sum; } /* E Recoil */ double FitUtils::GetErecoil_TRUE(FitEvent *event) { // Get total energy of hadronic system. double Erecoil = 0.0; for (unsigned int i = 2; i < event->Npart(); i++) { // Only final state if (!event->PartInfo(i)->fIsAlive) continue; if (event->PartInfo(i)->fNEUTStatusCode != 0) continue; // Skip Lepton if (abs(event->PartInfo(i)->fPID) == abs(event->PartInfo(0)->fPID) - 1) continue; // Add Up KE of protons and TE of everything else if (event->PartInfo(i)->fPID == 2212 || event->PartInfo(i)->fPID == 2112) { Erecoil += fabs(event->PartInfo(i)->fP.E()) - fabs(event->PartInfo(i)->fP.Mag()); } else { Erecoil += event->PartInfo(i)->fP.E(); } } return Erecoil; } double FitUtils::GetErecoil_CHARGED(FitEvent *event) { // Get total energy of hadronic system. double Erecoil = 0.0; for (unsigned int i = 2; i < event->Npart(); i++) { // Only final state if (!event->PartInfo(i)->fIsAlive) continue; if (event->PartInfo(i)->fNEUTStatusCode != 0) continue; // Skip Lepton if (abs(event->PartInfo(i)->fPID) == abs(event->PartInfo(0)->fPID) - 1) continue; // Skip Neutral particles if (event->PartInfo(i)->fPID == 2112 || event->PartInfo(i)->fPID == 111 || event->PartInfo(i)->fPID == 22) continue; // Add Up KE of protons and TE of everything else if (event->PartInfo(i)->fPID == 2212) { Erecoil += fabs(event->PartInfo(i)->fP.E()) - fabs(event->PartInfo(i)->fP.Mag()); } else { Erecoil += event->PartInfo(i)->fP.E(); } } return Erecoil; } // MOVE TO MINERVA Utils! double FitUtils::GetErecoil_MINERvA_LowRecoil(FitEvent *event) { // Get total energy of hadronic system. double Erecoil = 0.0; for (unsigned int i = 2; i < event->Npart(); i++) { // Only final state if (!event->PartInfo(i)->fIsAlive) continue; if (event->PartInfo(i)->Status() != kFinalState) continue; // Skip Lepton if (abs(event->PartInfo(i)->fPID) == 13) continue; // Skip Neutrons particles if (event->PartInfo(i)->fPID == 2112) continue; int PID = event->PartInfo(i)->fPID; // KE of Protons and charged pions if (PID == 2212 or PID == 211 or PID == -211) { // Erecoil += FitUtils::T(event->PartInfo(i)->fP); Erecoil += fabs(event->PartInfo(i)->fP.E()) - fabs(event->PartInfo(i)->fP.Mag()); // Total Energy of non-neutrons // } else if (PID != 2112 and PID < 999 and PID != 22 and abs(PID) != // 14) { } else if (PID == 111 || PID == 11 || PID == -11 || PID == 22) { Erecoil += (event->PartInfo(i)->fP.E()); } } return Erecoil; } // MOVE TO MINERVA Utils! // The alternative Eavailable definition takes true q0 and subtracts the kinetic // energy of neutrons and pion masses returns in MeV double FitUtils::Eavailable(FitEvent *event) { double Eav = 0.0; // Now take q0 and subtract Eav double q0 = event->GetBeamPart()->fP.E(); // Get the pdg of incoming neutrino int ISPDG = event->GetBeamPartPDG(); // For CC if (event->IsCC() && event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))){ q0 -= event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.E(); } else if (event->GetHMFSParticle(ISPDG)) { q0 -= event->GetHMFSParticle(ISPDG)->fP.E(); } for (unsigned int i = 2; i < event->Npart(); i++) { // Only final state if (!event->PartInfo(i)->fIsAlive) continue; if (event->PartInfo(i)->Status() != kFinalState) continue; int PID = event->PartInfo(i)->fPID; // Neutrons if (PID == 2112) { // Adding kinetic energy of neutron Eav += FitUtils::T(event->PartInfo(i)->fP) * 1000.; // All pion masses } else if (abs(PID) == 211 || PID == 111) { Eav += event->PartInfo(i)->fP.M(); } } return q0 - Eav; } TVector3 GetVectorInTPlane(const TVector3 &inp, const TVector3 &planarNormal) { TVector3 pnUnit = planarNormal.Unit(); double inpProjectPN = inp.Dot(pnUnit); TVector3 InPlanarInput = inp - (inpProjectPN * pnUnit); return InPlanarInput; } TVector3 GetUnitVectorInTPlane(const TVector3 &inp, const TVector3 &planarNormal) { return GetVectorInTPlane(inp, planarNormal).Unit(); } Double_t FitUtils::GetDeltaPhiT(TVector3 const &V_lepton, TVector3 const &V_other, TVector3 const &Normal, bool PiMinus) { TVector3 V_lepton_T = GetUnitVectorInTPlane(V_lepton, Normal); TVector3 V_other_T = GetUnitVectorInTPlane(V_other, Normal); return PiMinus ? acos(V_lepton_T.Dot(V_other_T)) : (M_PI - acos(V_lepton_T.Dot(V_other_T))); } TVector3 FitUtils::GetDeltaPT(TVector3 const &V_lepton, TVector3 const &V_other, TVector3 const &Normal) { TVector3 V_lepton_T = GetVectorInTPlane(V_lepton, Normal); TVector3 V_other_T = GetVectorInTPlane(V_other, Normal); return V_lepton_T + V_other_T; } Double_t FitUtils::GetDeltaAlphaT(TVector3 const &V_lepton, TVector3 const &V_other, TVector3 const &Normal, bool PiMinus) { TVector3 DeltaPT = GetDeltaPT(V_lepton, V_other, Normal); return GetDeltaPhiT(V_lepton, DeltaPT, Normal, PiMinus); } double FitUtils::Get_STV_dpt_HMProton(FitEvent *event, int ISPDG, bool Is0pi) { // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; // Get highest momentum proton in allowed proton range TVector3 HadronP = Pprot.Vect(); // If we don't have a CC0pi signal definition we also add in pion momentum if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } // Count up pion momentum TLorentzVector ppi = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += ppi.Vect(); } return GetDeltaPT(LeptonP, HadronP, NuP).Mag(); } double FitUtils::Get_STV_dphit_HMProton(FitEvent *event, int ISPDG, bool Is0pi) { // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; TVector3 HadronP = Pprot.Vect(); if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector ppi = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += ppi.Vect(); } return GetDeltaPhiT(LeptonP, HadronP, NuP); } double FitUtils::Get_STV_dalphat_HMProton(FitEvent *event, int ISPDG, bool Is0pi) { // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); // Find the highest momentum proton in the event between ProtonMinCut_MeV and // ProtonMaxCut_MeV MeV with cos(theta_p) > ProtonCosThetaCut TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; TVector3 HadronP = Pprot.Vect(); if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector ppi = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += ppi.Vect(); } return GetDeltaAlphaT(LeptonP, HadronP, NuP); } // As defined in PhysRevC.95.065501 // Using prescription from arXiv 1805.05486 // Returns in GeV double FitUtils::Get_pn_reco_C_HMProton(FitEvent *event, int ISPDG, bool Is0pi) { const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; TVector3 HadronP = Pprot.Vect(); double const el = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->E() / 1000.; double const eh = Pprot.E() / 1000.; if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector ppi = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += ppi.Vect(); } TVector3 dpt = GetDeltaPT(LeptonP, HadronP, NuP); double dptMag = dpt.Mag() / 1000.; double ma = 6 * mn + 6 * mp - 0.09216; // target mass (E is from PhysRevC.95.065501) double map = ma - mn + 0.02713; // remnant mass double pmul = LeptonP.Dot(NuP.Unit()) / 1000.; double phl = HadronP.Dot(NuP.Unit()) / 1000.; // double pmul = GetVectorInTPlane(LeptonP, dpt).Mag()/1000.; // double phl = GetVectorInTPlane(HadronP, dpt).Mag()/1000.; double R = ma + pmul + phl - el - eh; double dpl = 0.5 * R - (map * map + dptMag * dptMag) / (2 * R); // double dpl = ((R*R)-(dptMag*dptMag)-(map*map))/(2*R); // as in in // PhysRevC.95.065501 - gives same result double pn_reco = sqrt((dptMag * dptMag) + (dpl * dpl)); // std::cout << "Diagnostics: " << std::endl; // std::cout << "mn: " << mn << std::endl; // std::cout << "ma: " << ma << std::endl; // std::cout << "map: " << map << std::endl; // std::cout << "pmu: " << LeptonP.Mag()/1000. << std::endl; // std::cout << "ph: " << HadronP.Mag()/1000. << std::endl; // std::cout << "pmul: " << pmul << std::endl; // std::cout << "phl: " << phl << std::endl; // std::cout << "el: " << el << std::endl; // std::cout << "eh: " << eh << std::endl; // std::cout << "R: " << R << std::endl; // std::cout << "dptMag: " << dptMag << std::endl; // std::cout << "dpl: " << dpl << std::endl; // std::cout << "pn_reco: " << pn_reco << std::endl; return pn_reco; } double FitUtils::Get_pn_reco_Ar_HMProton(FitEvent *event, int ISPDG, bool Is0pi) { const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass // Check that the neutrino exists if (event->NumISParticle(ISPDG) == 0) { return -9999; } // Return 0 if the proton or muon are missing if (event->NumFSParticle(2212) == 0 || event->NumFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1)) == 0) { return -9999; } // Now get the TVector3s for each particle TVector3 const &NuP = event->GetHMISParticle(ISPDG)->fP.Vect(); TVector3 const &LeptonP = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->fP.Vect(); TLorentzVector Pprot = event->GetHMFSParticle(2212)->fP; TVector3 HadronP = Pprot.Vect(); double const el = event->GetHMFSParticle(ISPDG + ((ISPDG < 0) ? 1 : -1))->E() / 1000.; double const eh = Pprot.E() / 1000.; if (!Is0pi) { if (event->NumFSParticle(PhysConst::pdg_pions) == 0) { return -9999; } TLorentzVector ppi = event->GetHMFSParticle(PhysConst::pdg_pions)->fP; HadronP += ppi.Vect(); } TVector3 dpt = GetDeltaPT(LeptonP, HadronP, NuP); double dptMag = dpt.Mag() / 1000.; // double ma = 6*mn + 6*mp - 0.09216; // target mass (E is from // PhysRevC.95.065501) double map = ma - mn + 0.02713; // remnant mass double ma = 6 * mn + 6 * mp - 0.34381; // target mass (E is from PhysRevC.95.065501) double map = ma - mn + 0.02713; // remnant mass double pmul = LeptonP.Dot(NuP.Unit()) / 1000.; double phl = HadronP.Dot(NuP.Unit()) / 1000.; // double pmul = GetVectorInTPlane(LeptonP, dpt).Mag()/1000.; // double phl = GetVectorInTPlane(HadronP, dpt).Mag()/1000.; double R = ma + pmul + phl - el - eh; double dpl = 0.5 * R - (map * map + dptMag * dptMag) / (2 * R); // double dpl = ((R*R)-(dptMag*dptMag)-(map*map))/(2*R); // as in in // PhysRevC.95.065501 - gives same result double pn_reco = sqrt((dptMag * dptMag) + (dpl * dpl)); return pn_reco; } // Get Cos theta with Adler angles double FitUtils::CosThAdler(TLorentzVector Pnu, TLorentzVector Pmu, TLorentzVector Ppi, TLorentzVector Pprot) { // Get the "resonance" lorentz vector (pion proton system) TLorentzVector Pres = Pprot + Ppi; // Boost the particles into the resonance rest frame so we can define the // x,y,z axis Pnu.Boost(-Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Ppi.Boost(-Pres.BoostVector()); // The z-axis is defined as the axis of three-momentum transfer, \vec{k} // Also unit normalise the axis TVector3 zAxis = (Pnu.Vect() - Pmu.Vect()) * (1.0 / ((Pnu.Vect() - Pmu.Vect()).Mag())); // Then the angle between the pion in the "resonance" rest-frame and the // z-axis is the theta Adler angle double costhAdler = cos(Ppi.Vect().Angle(zAxis)); return costhAdler; } // Get phi with Adler angles, a bit more complicated... double FitUtils::PhiAdler(TLorentzVector Pnu, TLorentzVector Pmu, TLorentzVector Ppi, TLorentzVector Pprot) { // Get the "resonance" lorentz vector (pion proton system) TLorentzVector Pres = Pprot + Ppi; // Boost the particles into the resonance rest frame so we can define the // x,y,z axis Pnu.Boost(-Pres.BoostVector()); Pmu.Boost(-Pres.BoostVector()); Ppi.Boost(-Pres.BoostVector()); // The z-axis is defined as the axis of three-momentum transfer, \vec{k} // Also unit normalise the axis TVector3 zAxis = (Pnu.Vect() - Pmu.Vect()) * (1.0 / ((Pnu.Vect() - Pmu.Vect()).Mag())); // The y-axis is then defined perpendicular to z and muon momentum in the // resonance frame TVector3 yAxis = Pnu.Vect().Cross(Pmu.Vect()); yAxis *= 1.0 / double(yAxis.Mag()); // And the x-axis is then simply perpendicular to z and x TVector3 xAxis = yAxis.Cross(zAxis); xAxis *= 1.0 / double(xAxis.Mag()); // Project the pion on to x and y axes double x = Ppi.Vect().Dot(xAxis); double y = Ppi.Vect().Dot(yAxis); double newphi = atan2(y, x) * (180. / M_PI); // Convert negative angles to positive if (newphi < 0.0) newphi += 360.0; return newphi; } //******************************************************************** double FitUtils::ppInfK(TLorentzVector pmu, double costh, double binding, bool neutrino) { //******************************************************************** // Convert all values to GeV // const double V = binding / 1000.; // binding potential // const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass double el = pmu.E() / 1000.; // double pl = (pmu.Vect().Mag()) / 1000.; // momentum of lepton double enu = EnuQErec(pmu, costh, binding, neutrino); double ep_inf = enu - el + mp; double pp_inf = sqrt(ep_inf * ep_inf - mp * mp); return pp_inf; }; //******************************************************************** TVector3 FitUtils::tppInfK(TLorentzVector pmu, double costh, double binding, bool neutrino) { //******************************************************************** // Convert all values to GeV // const double V = binding / 1000.; // binding potential // const double mn = PhysConst::mass_neutron; // neutron mass // const double mp = PhysConst::mass_proton; // proton mass double pl_x = pmu.X() / 1000.; double pl_y = pmu.Y() / 1000.; double pl_z = pmu.Z() / 1000.; double enu = EnuQErec(pmu, costh, binding, neutrino); TVector3 tpp_inf(-pl_x, -pl_y, -pl_z + enu); return tpp_inf; }; //******************************************************************** double FitUtils::cthpInfK(TLorentzVector pmu, double costh, double binding, bool neutrino) { //******************************************************************** // Convert all values to GeV // const double V = binding / 1000.; // binding potential // const double mn = PhysConst::mass_neutron; // neutron mass const double mp = PhysConst::mass_proton; // proton mass double el = pmu.E() / 1000.; double pl = (pmu.Vect().Mag()) / 1000.; // momentum of lepton double enu = EnuQErec(pmu, costh, binding, neutrino); double ep_inf = enu - el + mp; double pp_inf = sqrt(ep_inf * ep_inf - mp * mp); double cth_inf = (enu * enu + pp_inf * pp_inf - pl * pl) / (2 * enu * pp_inf); return cth_inf; }; diff --git a/src/Utils/FitUtils.h b/src/Utils/FitUtils.h index a993314..d8ddec1 100644 --- a/src/Utils/FitUtils.h +++ b/src/Utils/FitUtils.h @@ -1,197 +1,197 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef FITUTILS_H_SEEN #define FITUTILS_H_SEEN #include #include #include #include #include #include #include "FitEvent.h" #include "TGraph.h" #include "TH2Poly.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include "FitLogger.h" /*! * \addtogroup Utils * @{ */ /// Functions needed by individual samples for calculating kinematic quantities. namespace FitUtils { /// Return a vector of all values saved in map double *GetArrayFromMap(std::vector invals, std::map inmap); /// Returns kinetic energy of particle double T(TLorentzVector part); /// Returns momentum of particle double p(TLorentzVector part); double p(FitParticle *part); /// Returns angle between particles (_NOT_ cosine!) double th(TLorentzVector part, TLorentzVector part2); double th(FitParticle *part1, FitParticle *part2); /// Hadronic mass reconstruction double Wrec(TLorentzVector pnu, TLorentzVector pmu); /// Hadronic mass true from initial state particles and muon; useful if the full /// FSI vectors aren't not saved and we for some reasons need W_true double Wtrue(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector pnuc); double SumKE_PartVect(std::vector const fps); double SumTE_PartVect(std::vector const fps); /// Return E Hadronic for all FS Particles in Hadronic System double GetErecoil_TRUE(FitEvent *event); /// Return E Hadronic for all Charged FS Particles in Hadronic System double GetErecoil_CHARGED(FitEvent *event); double Eavailable(FitEvent *event); /* CCQE MiniBooNE/MINERvA */ /// Function to calculate the reconstructed Q^{2}_{QE} double Q2QErec(TLorentzVector pmu, double costh, double binding, bool neutrino = true); /// Function returns the reconstructed E_{nu} values double EnuQErec(TLorentzVector pmu, double costh, double binding, bool neutrino = true); /// Function returns the reconstructed E_{nu} values double EnuQErec(TLorentzVector pmu, TLorentzVector pnu, double binding, bool neutrino = true); //! Function to calculate the reconstructed Q^{2}_{QE} double Q2QErec(double pl, double costh, double binding, bool neutrino = true); //! Function to calculate the reconstructed Q^{2}_{QE} double Q2QErec(TLorentzVector Pmu, TLorentzVector Pnu, double binding, bool neutrino = true); //! Function returns the reconstructed E_{nu} values double EnuQErec(double pl, double costh, double binding, bool neutrino = true); Double_t GetDeltaPhiT(TVector3 const &V_lepton, TVector3 const &V_other, TVector3 const &Normal, bool PiMinus = false); TVector3 GetDeltaPT(TVector3 const &V_lepton, TVector3 const &V_other, TVector3 const &Normal); Double_t GetDeltaAlphaT(TVector3 const &V_lepton, TVector3 const &V_other, TVector3 const &Normal, bool PiMinus = false); double Get_STV_dpt_HMProton(FitEvent *event, int ISPDG, bool Is0pi); double Get_STV_dphit_HMProton(FitEvent *event, int ISPDG, bool Is0pi); double Get_STV_dalphat_HMProton(FitEvent *event, int ISPDG, bool Is0pi); double Get_pn_reco_C_HMProton(FitEvent *event, int ISPDG, bool Is0pi); double Get_pn_reco_Ar_HMProton(FitEvent *event, int ISPDG, bool Is0pi); /* CCQE1p MINERvA */ /// Reconstruct Q2QE given just the maximum energy proton. double ProtonQ2QErec(double pE, double binding); /* E Recoil MINERvA */ double GetErecoil_MINERvA_LowRecoil(FitEvent *event); /* CC1pi0 MiniBooNE */ /// Reconstruct Enu from CCpi0 vectors and binding energy double EnuCC1pi0rec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi0 = TLorentzVector(0, 0, 0, 0)); /// Reconstruct Q2 from CCpi0 vectors and binding energy double Q2CC1pi0rec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi0 = TLorentzVector(0, 0, 0, 0)); /* CC1pi+ MiniBooNE */ /// returns reconstructed Enu a la MiniBooNE CCpi+ /// returns reconstructed Enu a la MiniBooNE CCpi+ // Also for when not having pion info (so when we have a Michel tag in T2K) double EnuCC1piprec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppip, bool pionInfo = true); /// returns reconstructed Enu assumming resonance interaction where intermediate /// resonance was a Delta double EnuCC1piprecDelta(TLorentzVector pnu, TLorentzVector pmu); /// returns reconstructed in a variety of flavours double Q2CC1piprec(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppip, int enuType = 0, bool pionInfo = true); /* T2K CC1pi+ on CH */ double thq3pi_CC1pip_T2K(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi); double q3_CC1pip_T2K(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi); double WrecCC1pip_T2K_MB(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppip); double EnuCC1piprec_T2K_eMB(TLorentzVector pnu, TLorentzVector pmu, TLorentzVector ppi); /* nucleon single pion */ double MpPi(TLorentzVector pp, TLorentzVector ppi); // For T2K inferred kinematics analyis - variables defined as on page 7 of T2K // TN287v11 (and now arXiv 1802.05078) double ppInfK(TLorentzVector pmu, double costh, double binding, bool neutrino); TVector3 tppInfK(TLorentzVector pmu, double costh, double binding, bool neutrino); double cthpInfK(TLorentzVector pmu, double costh, double binding, bool neutrino); double CosThAdler(TLorentzVector Pnu, TLorentzVector Pmu, TLorentzVector Ppi, TLorentzVector Pprot); double PhiAdler(TLorentzVector Pnu, TLorentzVector Pmu, TLorentzVector Ppi, TLorentzVector Pprot); } // namespace FitUtils /*! @} */ #endif diff --git a/src/Utils/GeneralUtils.cxx b/src/Utils/GeneralUtils.cxx index 9b32531..7fe4331 100644 --- a/src/Utils/GeneralUtils.cxx +++ b/src/Utils/GeneralUtils.cxx @@ -1,195 +1,195 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "GeneralUtils.h" std::string GeneralUtils::BoolToStr(bool val) { std::ostringstream ss; ss << val; return ss.str(); } std::string GeneralUtils::IntToStr(int val) { std::ostringstream ss; ss << val; return ss.str(); }; std::string GeneralUtils::DblToStr(double val) { std::ostringstream ss; ss << val; return ss.str(); }; std::vector GeneralUtils::LoadCharToVectStr(int argc, char* argv[]) { std::vector vect; for (int i = 1; i < argc; i++) { vect.push_back(std::string(argv[i])); } return vect; } std::vector GeneralUtils::ParseToStr(std::string str, const char* del) { std::istringstream stream(str); std::string temp_string; std::vector vals; while (std::getline(stream >> std::ws, temp_string, *del)) { if (temp_string.empty()) continue; vals.push_back(temp_string); } return vals; } std::vector GeneralUtils::ParseToDbl(std::string str, const char* del) { std::istringstream stream(str); std::string temp_string; std::vector vals; while (std::getline(stream >> std::ws, temp_string, *del)) { if (temp_string.empty()) continue; std::istringstream stream(temp_string); double entry; stream >> entry; vals.push_back(entry); } return vals; } std::vector GeneralUtils::ParseToInt(std::string str, const char* del) { std::istringstream stream(str); std::string temp_string; std::vector vals; while (std::getline(stream >> std::ws, temp_string, *del)) { if (temp_string.empty()) continue; std::istringstream stream(temp_string); int entry; stream >> entry; vals.push_back(entry); } return vals; } double GeneralUtils::StrToDbl(std::string str) { std::istringstream stream(str); double val; stream >> val; return val; } int GeneralUtils::StrToInt(std::string str) { std::istringstream stream(str); int val; stream >> val; return val; } bool GeneralUtils::StrToBool(std::string str) { // convert result to lower case for (uint i = 0; i < str.size(); i++) str[i] = std::tolower(str[i]); // Test for true/false if (!str.compare("false")) return false; else if (!str.compare("true")) return true; if (str.empty()) return false; // Push into bool std::istringstream stream(str); bool val; stream >> val; return val; } std::vector GeneralUtils::ParseFileToStr(std::string str, const char* del) { std::vector linevect; std::string line; std::ifstream read; read.open(str.c_str()); if (!read.is_open()) { NUIS_ERR(FTL, "Cannot open file " << str << " in ParseFileToStr"); throw; } while (std::getline(read >> std::ws, line, *del)) { linevect.push_back(line); } read.close(); return linevect; } std::string GeneralUtils::GetTopLevelDir() { static bool first = true; static std::string topLevelVarVal; if (first) { char* const var = getenv("NUISANCE"); if (!var) { NUIS_ERR(FTL, "Cannot find top level directory! Set the NUISANCE environmental " "variable"); throw; } topLevelVarVal = std::string(var); first = false; } return topLevelVarVal; } std::string GeneralUtils::ReplaceAll(std::string const& inp, std::string const& from, std::string const& to) { std::stringstream ss(""); size_t nextOccurence = 0; size_t prevOccurence = 0; bool AtEnd = false; while (!AtEnd) { nextOccurence = inp.find(from, prevOccurence); if (nextOccurence == std::string::npos) { if (prevOccurence == inp.length()) { break; } AtEnd = true; } if ((nextOccurence != prevOccurence) || (nextOccurence == 0)) { ss << inp.substr(prevOccurence, (nextOccurence - prevOccurence)); if (!AtEnd) { ss << to; } } prevOccurence = nextOccurence + from.size(); } return ss.str(); } diff --git a/src/Utils/GeneralUtils.h b/src/Utils/GeneralUtils.h index 0c0f0c0..ae1cd59 100644 --- a/src/Utils/GeneralUtils.h +++ b/src/Utils/GeneralUtils.h @@ -1,135 +1,135 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef GENERALUTILS_H_SEEN #define GENERALUTILS_H_SEEN #include #include #include #include #include #include #include #include #include #include #include #include #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 ParseToDbl(std::string str, const char* del); /// Parse a string into a vector of ints given a delimiter "del" std::vector ParseToInt(std::string str, const char* del); /// Parse a string into a vector of strings given a delimiter "del" std::vector ParseToStr(std::string str, const char* del); /// Parse text file into a vector of strings std::vector 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); /// Convert a bool to string std::string BoolToStr(bool val); /// Convert Int to string std::string IntToStr(int val); /// Convert Double to String std::string DblToStr(double val); /// Return the top level environmental variable for the fitter std::string GetTopLevelDir(); // /// A utility function to return a std::vector from an array // template // std::vector makeVector(const T (&data)[N]) { // return std::vector(data, data + N); // } std::vector LoadCharToVectStr(int argc, char* argv[]); template size_t GetArraySize(const T (&data)[N]) { return N; } template 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 size_t GetFirstOnBit(T const& d) { T c = d; size_t fob = 0; while (bool(c)) { if (c & 1) { return fob; } else { c = (c >> 1); } fob++; } return fob; } template size_t IsSmallNum(T const& d) { if (std::numeric_limits::is_integer) { return (d == 0); } return (((d > 0) && (d < std::numeric_limits::epsilon())) || ((d < 0) && (d > -std::numeric_limits::epsilon()))); } std::string ReplaceAll(std::string const &inp, std::string const &from, std::string const &to); } /*! @} */ #endif diff --git a/src/Utils/OpenMPWrapper.h b/src/Utils/OpenMPWrapper.h index 811732d..4ba37e4 100644 --- a/src/Utils/OpenMPWrapper.h +++ b/src/Utils/OpenMPWrapper.h @@ -1,36 +1,36 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef OPENMPWRAPPER_H #define OPENMPWRAPPER_H // Have to define dummy opemmp variables incase its not enabled #ifdef __USE_OPENMP__ #include #else typedef int omp_int_t; inline omp_int_t omp_get_thread_num() { return 0; } inline omp_int_t omp_get_max_threads() { return 1; } #endif #endif \ No newline at end of file diff --git a/src/Utils/PhysConst.h b/src/Utils/PhysConst.h index e093ceb..0b1be08 100644 --- a/src/Utils/PhysConst.h +++ b/src/Utils/PhysConst.h @@ -1,114 +1,114 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef PHYSCONST_H_SEEN #define PHYSCONST_H_SEEN #include #include #include #include #include #include #include #include #include #include #include #include #include "FitLogger.h" /// namespace to contain all physical constants used by NUISANCE 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_nucleon = (mass_proton + mass_neutron) / 2.; const double mass_proton_kg = 1.6727E-27; // Proton mass in kg const double mass_neutron_kg = 1.6750E-27; // Neutron mass in kg const double mass_nucleon_kg = (mass_proton_kg + mass_neutron_kg) / 2.; const double mass_delta = 1.232; // Delta mass in GeV const double mass_muon = 0.10565837; // Muon mass in GeV const double mass_electron = 0.000510998928; // Electron mass in GeV const double mass_cpi = 0.13957; // charged pion mass in GeV const double mass_pi0 = 0.13498; // neutral pion mass in GeV const double mass_cK = 0.493677; // charged kaon mass in GeV const double mass_K0 = 0.497611; // neutral kaon mass in GeV inline double GetMass(int pdg) { switch (abs(pdg)) { case 11: return mass_electron; case 13: return mass_muon; case 111: return mass_pi0; case 211: return mass_cpi; case 321: return mass_cK; case 311: case 310: case 130: return mass_K0; case 2112: return mass_neutron; case 2212: return mass_proton; default: { NUIS_ERR(WRN, "Attempted to get mass for PDG: " << pdg << ", but it is not catered for. Please add it to " "src/Utils/PhysConst.h"); return -1; } } } const double mass_MeV = 1000; // MeV/GeV const int pdg_neutrinos[] = {12, -12, 14, -14 /*, 16, -16*/}; const int pdg_muons[] = {13, -13}; const int pdg_leptons[] = {11, -11, 13, -13, 15, -15}; const int pdg_all_leptons[] = {11, -11, 13, -13, 15, -15, 12, -12, 14, -14, 16, -16}; 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}; const int pdg_nucleons[] = {2112, 2212}; // 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/PlotUtils.cxx b/src/Utils/PlotUtils.cxx index 009ad71..cb6a8be 100644 --- a/src/Utils/PlotUtils.cxx +++ b/src/Utils/PlotUtils.cxx @@ -1,1210 +1,1231 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "PlotUtils.h" #include "FitEvent.h" #include "StatUtils.h" -// MOVE TO MB UTILS! -// This function is intended to be modified to enforce a consistent masking for -// all models. -TH2D *PlotUtils::SetMaskHist(std::string type, TH2D *data) { - TH2D *fMaskHist = (TH2D *)data->Clone("fMaskHist"); - - for (int xBin = 0; xBin < fMaskHist->GetNbinsX(); ++xBin) { - for (int yBin = 0; yBin < fMaskHist->GetNbinsY(); ++yBin) { - if (data->GetBinContent(xBin + 1, yBin + 1) == 0) - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 0); - else - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 0.5); - - if (!type.compare("MB_numu_2D")) { - if (yBin == 19 && xBin < 8) - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 1.0); - } else { - if (yBin == 19 && xBin < 11) - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 1.0); - } - if (yBin == 18 && xBin < 3) - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 1.0); - if (yBin == 17 && xBin < 2) - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 1.0); - if (yBin == 16 && xBin < 1) - fMaskHist->SetBinContent(xBin + 1, yBin + 1, 1.0); - } - } - - return fMaskHist; -}; - // MOVE TO GENERAL UTILS? bool PlotUtils::CheckObjectWithName(TFile *inFile, std::string substring) { TIter nextkey(inFile->GetListOfKeys()); TKey *key; while ((key = (TKey *)nextkey())) { std::string test(key->GetName()); if (test.find(substring) != std::string::npos) return true; } return false; }; // MOVE TO GENERAL UTILS? std::string PlotUtils::GetObjectWithName(TFile *inFile, std::string substring) { TIter nextkey(inFile->GetListOfKeys()); TKey *key; std::string output = ""; while ((key = (TKey *)nextkey())) { std::string test(key->GetName()); if (test.find(substring) != std::string::npos) output = test; } return output; }; void PlotUtils::CreateNeutModeArray(TH1 *hist, TH1 *neutarray[]) { for (int i = 0; i < 60; i++) { neutarray[i] = (TH1 *)hist->Clone(Form("%s_NMODE_%i", hist->GetName(), i)); } return; }; void PlotUtils::DeleteNeutModeArray(TH1 *neutarray[]) { for (int i = 0; i < 60; i++) { delete neutarray[i]; } return; }; void PlotUtils::FillNeutModeArray(TH1D *hist[], int mode, double xval, double weight) { if (abs(mode) > 60) return; hist[abs(mode)]->Fill(xval, weight); return; }; void PlotUtils::FillNeutModeArray(TH2D *hist[], int mode, double xval, double yval, double weight) { if (abs(mode) > 60) return; hist[abs(mode)]->Fill(xval, yval, weight); return; }; THStack PlotUtils::GetNeutModeStack(std::string title, TH1 *ModeStack[], int option) { (void)option; THStack allmodes = THStack(title.c_str(), title.c_str()); for (int i = 0; i < 60; i++) { allmodes.Add(ModeStack[i]); } // Credit to Clarence for copying all this out. // CC ModeStack[1]->SetTitle("CCQE"); ModeStack[1]->SetFillColor(kBlue); // ModeStack[1]->SetFillStyle(3444); ModeStack[1]->SetLineColor(kBlue); ModeStack[2]->SetTitle("2p/2h Nieves"); ModeStack[2]->SetFillColor(kRed); // ModeStack[2]->SetFillStyle(3344); ModeStack[2]->SetLineColor(kRed); // ModeStack[11]->SetTitle("#it{#nu + p #rightarrow l^{-} + p + #pi^{+}}"); ModeStack[11]->SetTitle("CC1#pi^{+} on p"); ModeStack[11]->SetFillColor(kGreen); // ModeStack[11]->SetFillStyle(3004); ModeStack[11]->SetLineColor(kGreen); // ModeStack[12]->SetTitle("#it{#nu + n #rightarrow l^{-} + p + #pi^{0}}"); ModeStack[12]->SetTitle("CC1#pi^{0} on n"); ModeStack[12]->SetFillColor(kGreen + 3); // ModeStack[12]->SetFillStyle(3005); ModeStack[12]->SetLineColor(kGreen); // ModeStack[13]->SetTitle("#it{#nu + n #rightarrow l^{-} + n + #pi^{+}}"); ModeStack[13]->SetTitle("CC1#pi^{+} on n"); ModeStack[13]->SetFillColor(kGreen - 2); // ModeStack[13]->SetFillStyle(3004); ModeStack[13]->SetLineColor(kGreen); ModeStack[16]->SetTitle("CC coherent"); - ModeStack[16]->SetFillColor(kBlue); + ModeStack[16]->SetFillColor(kBlue-6); // ModeStack[16]->SetFillStyle(3644); - ModeStack[16]->SetLineColor(kBlue); + ModeStack[16]->SetLineColor(kBlue-6); // ModeStack[17]->SetTitle("#it{#nu + n #rightarrow l^{-} + p + #gamma}"); ModeStack[17]->SetTitle("CC1#gamma"); ModeStack[17]->SetFillColor(kMagenta); // ModeStack[17]->SetFillStyle(3001); ModeStack[17]->SetLineColor(kMagenta); ModeStack[21]->SetTitle("Multi #pi (1.3 < W < 2.0)"); ModeStack[21]->SetFillColor(kYellow); // ModeStack[21]->SetFillStyle(3005); ModeStack[21]->SetLineColor(kYellow); // ModeStack[22]->SetTitle("#it{#nu + n #rightarrow l^{-} + p + #eta^{0}}"); ModeStack[22]->SetTitle("CC1#eta^{0} on n"); ModeStack[22]->SetFillColor(kYellow - 2); // ModeStack[22]->SetFillStyle(3013); ModeStack[22]->SetLineColor(kYellow - 2); // ModeStack[23]->SetTitle("#it{#nu + n #rightarrow l^{-} + #Lambda + // K^{+}}"); ModeStack[23]->SetTitle("CC1#Labda1K^{+}"); ModeStack[23]->SetFillColor(kYellow - 6); // ModeStack[23]->SetFillStyle(3013); ModeStack[23]->SetLineColor(kYellow - 6); ModeStack[26]->SetTitle("DIS (W > 2.0)"); - ModeStack[26]->SetFillColor(kRed); + ModeStack[26]->SetFillColor(kRed-6); // ModeStack[26]->SetFillStyle(3006); - ModeStack[26]->SetLineColor(kRed); + ModeStack[26]->SetLineColor(kRed-6); // NC // ModeStack[31]->SetTitle("#it{#nu + n #rightarrow #nu + n + #pi^{0}}"); ModeStack[31]->SetTitle("NC1#pi^{0} on n"); - ModeStack[31]->SetFillColor(kBlue); + ModeStack[31]->SetFillColor(kBlue-4); // ModeStack[31]->SetFillStyle(3004); - ModeStack[31]->SetLineColor(kBlue); + ModeStack[31]->SetLineColor(kBlue-4); // ModeStack[32]->SetTitle("#it{#nu + p #rightarrow #nu + p + #pi^{0}}"); ModeStack[32]->SetTitle("NC1#pi^{0} on p"); ModeStack[32]->SetFillColor(kBlue + 3); // ModeStack[32]->SetFillStyle(3004); ModeStack[32]->SetLineColor(kBlue + 3); // ModeStack[33]->SetTitle("#it{#nu + n #rightarrow #nu + p + #pi^{-}}"); ModeStack[33]->SetTitle("NC1#pi^{-} on n"); ModeStack[33]->SetFillColor(kBlue - 2); // ModeStack[33]->SetFillStyle(3005); ModeStack[33]->SetLineColor(kBlue - 2); // ModeStack[34]->SetTitle("#it{#nu + p #rightarrow #nu + n + #pi^{+}}"); ModeStack[34]->SetTitle("NC1#pi^{+} on p"); ModeStack[34]->SetFillColor(kBlue - 8); // ModeStack[34]->SetFillStyle(3005); ModeStack[34]->SetLineColor(kBlue - 8); ModeStack[36]->SetTitle("NC Coherent"); ModeStack[36]->SetFillColor(kBlue + 8); // ModeStack[36]->SetFillStyle(3644); ModeStack[36]->SetLineColor(kBlue + 8); // ModeStack[38]->SetTitle("#it{#nu + n #rightarrow #nu + n + #gamma}"); ModeStack[38]->SetTitle("NC1#gamma on n"); ModeStack[38]->SetFillColor(kMagenta); // ModeStack[38]->SetFillStyle(3001); ModeStack[38]->SetLineColor(kMagenta); // ModeStack[39]->SetTitle("#it{#nu + p #rightarrow #nu + p + #gamma}"); ModeStack[39]->SetTitle("NC1#gamma on p"); ModeStack[39]->SetFillColor(kMagenta - 10); // ModeStack[39]->SetFillStyle(3001); ModeStack[39]->SetLineColor(kMagenta - 10); ModeStack[41]->SetTitle("Multi #pi (1.3 < W < 2.0)"); ModeStack[41]->SetFillColor(kBlue - 10); // ModeStack[41]->SetFillStyle(3005); ModeStack[41]->SetLineColor(kBlue - 10); // ModeStack[42]->SetTitle("#it{#nu + n #rightarrow #nu + n + #eta^{0}}"); ModeStack[42]->SetTitle("NC1#eta^{0} on n"); ModeStack[42]->SetFillColor(kYellow - 2); // ModeStack[42]->SetFillStyle(3013); ModeStack[42]->SetLineColor(kYellow - 2); // ModeStack[43]->SetTitle("#it{#nu + p #rightarrow #nu + p + #eta^{0}}"); ModeStack[43]->SetTitle("NC1#eta^{0} on p"); ModeStack[43]->SetFillColor(kYellow - 4); // ModeStack[43]->SetFillStyle(3013); ModeStack[43]->SetLineColor(kYellow - 4); // ModeStack[44]->SetTitle("#it{#nu + n #rightarrow #nu + #Lambda + K^{0}}"); ModeStack[44]->SetTitle("NC1#Lambda1K^{0} on n"); ModeStack[44]->SetFillColor(kYellow - 6); // ModeStack[44]->SetFillStyle(3014); ModeStack[44]->SetLineColor(kYellow - 6); // ModeStack[45]->SetTitle("#it{#nu + p #rightarrow #nu + #Lambda + K^{+}}"); ModeStack[45]->SetTitle("NC1#Lambda1K^{+}"); ModeStack[45]->SetFillColor(kYellow - 10); // ModeStack[45]->SetFillStyle(3014); ModeStack[45]->SetLineColor(kYellow - 10); ModeStack[46]->SetTitle("DIS (W > 2.0)"); - ModeStack[46]->SetFillColor(kRed); + ModeStack[46]->SetFillColor(kRed-6); // ModeStack[46]->SetFillStyle(3006); - ModeStack[46]->SetLineColor(kRed); + ModeStack[46]->SetLineColor(kRed-6); // ModeStack[51]->SetTitle("#it{#nu + p #rightarrow #nu + p}"); ModeStack[51]->SetTitle("NC on p"); ModeStack[51]->SetFillColor(kBlack); // ModeStack[51]->SetFillStyle(3444); ModeStack[51]->SetLineColor(kBlack); // ModeStack[52]->SetTitle("#it{#nu + n #rightarrow #nu + n}"); ModeStack[52]->SetTitle("NC on n"); ModeStack[52]->SetFillColor(kGray); // ModeStack[52]->SetFillStyle(3444); ModeStack[52]->SetLineColor(kGray); return allmodes; }; TLegend PlotUtils::GenerateStackLegend(THStack stack, int xlow, int ylow, int xhigh, int yhigh) { TLegend leg = TLegend(xlow, ylow, xhigh, yhigh); TObjArray *histarray = stack.GetStack(); int nhist = histarray->GetEntries(); for (int i = 0; i < nhist; i++) { TH1 *hist = (TH1 *)(histarray->At(i)); leg.AddEntry((hist), ((TH1 *)histarray->At(i))->GetTitle(), "fl"); } leg.SetName(Form("%s_LEG", stack.GetName())); return leg; }; void PlotUtils::ScaleNeutModeArray(TH1 *hist[], double factor, std::string option) { for (int i = 0; i < 60; i++) { if (hist[i]) hist[i]->Scale(factor, option.c_str()); } return; }; void PlotUtils::ResetNeutModeArray(TH1 *hist[]) { for (int i = 0; i < 60; i++) { if (hist[i]) hist[i]->Reset(); } return; }; //******************************************************************** // This assumes the Enu axis is the x axis, as is the case for MiniBooNE 2D // distributions void PlotUtils::FluxUnfoldedScaling(TH2D *fMCHist, TH1D *fhist, TH1D *ehist, double scalefactor) { //******************************************************************** // Make clones to avoid changing stuff TH1D *eventhist = (TH1D *)ehist->Clone(); TH1D *fFluxHist = (TH1D *)fhist->Clone(); // Undo width integral in SF fMCHist->Scale(scalefactor / eventhist->Integral(1, eventhist->GetNbinsX() + 1, "width")); // Standardise The Flux eventhist->Scale(1.0 / fFluxHist->Integral()); fFluxHist->Scale(1.0 / fFluxHist->Integral()); // Do interpolation for 2D plots? // fFluxHist = PlotUtils::InterpolateFineHistogram(fFluxHist,100,"width"); // eventhist = PlotUtils::InterpolateFineHistogram(eventhist,100,"width"); // eventhist->Scale(1.0/fFluxHist->Integral()); // fFluxHist->Scale(1.0/fFluxHist->Integral()); // Scale fMCHist by eventhist integral fMCHist->Scale(eventhist->Integral(1, eventhist->GetNbinsX() + 1)); // Find which axis is the Enu axis bool EnuOnXaxis = false; std::string xaxis = fMCHist->GetXaxis()->GetTitle(); if (xaxis.find("E") != std::string::npos && xaxis.find("nu") != std::string::npos) EnuOnXaxis = true; std::string yaxis = fMCHist->GetYaxis()->GetTitle(); if (yaxis.find("E") != std::string::npos && xaxis.find("nu") != std::string::npos) { // First check that xaxis didn't also find Enu if (EnuOnXaxis) { NUIS_ERR(FTL, fMCHist->GetTitle() << " error:"); NUIS_ERR(FTL, "Found Enu in xaxis title: " << xaxis); NUIS_ERR(FTL, "AND"); NUIS_ERR(FTL, "Found Enu in yaxis title: " << yaxis); NUIS_ABORT("Enu on x and Enu on y flux unfolded scaling isn't " "implemented, please modify " << __FILE__ << ":" << __LINE__); } EnuOnXaxis = false; } // Now Get a flux PDF assuming X axis is Enu TH1D *pdfflux = NULL; // If xaxis is Enu if (EnuOnXaxis) pdfflux = (TH1D *)fMCHist->ProjectionX()->Clone(); // If yaxis is Enu else pdfflux = (TH1D *)fMCHist->ProjectionY()->Clone(); // pdfflux->Write( (std::string(fMCHist->GetName()) + "_PROJX").c_str()); pdfflux->Reset(); // Awful MiniBooNE Check for the time being // Needed because the flux is in GeV whereas the measurement is in MeV bool ismb = std::string(fMCHist->GetName()).find("MiniBooNE") != std::string::npos; for (int i = 0; i < pdfflux->GetNbinsX(); i++) { double Ml = pdfflux->GetXaxis()->GetBinLowEdge(i + 1); double Mh = pdfflux->GetXaxis()->GetBinLowEdge(i + 2); // double Mc = pdfflux->GetXaxis()->GetBinCenter(i+1); // double Mw = pdfflux->GetBinWidth(i+1); double fluxint = 0.0; // Scaling to match flux for MB if (ismb) { Ml /= 1.E3; Mh /= 1.E3; // Mc /= 1.E3; // Mw /= 1.E3; } for (int j = 0; j < fFluxHist->GetNbinsX(); j++) { // double Fc = fFluxHist->GetXaxis()->GetBinCenter(j+1); double Fl = fFluxHist->GetXaxis()->GetBinLowEdge(j + 1); double Fh = fFluxHist->GetXaxis()->GetBinLowEdge(j + 2); double Fe = fFluxHist->GetBinContent(j + 1); double Fw = fFluxHist->GetXaxis()->GetBinWidth(j + 1); if (Fl >= Ml and Fh <= Mh) { fluxint += Fe; } else if (Fl < Ml and Fl < Mh and Fh > Ml and Fh < Mh) { fluxint += Fe * (Fh - Ml) / Fw; } else if (Fh > Mh and Fl < Mh and Fh > Ml and Fl > Ml) { fluxint += Fe * (Mh - Fl) / Fw; } else if (Ml >= Fl and Mh <= Fh) { fluxint += Fe * (Mh - Ml) / Fw; } else { continue; } } pdfflux->SetBinContent(i + 1, fluxint); } // Then finally divide by the bin-width in for (int i = 0; i < fMCHist->GetNbinsX(); i++) { for (int j = 0; j < fMCHist->GetNbinsY(); j++) { if (pdfflux->GetBinContent(i + 1) == 0.0) continue; // Different scaling depending on if Enu is on x or y axis double scaling = 1.0; // If Enu is on the x-axis, we want the ith entry of the flux // And to divide by the bin width of the jth bin if (EnuOnXaxis) { double binWidth = fMCHist->GetYaxis()->GetBinLowEdge(j + 2) - fMCHist->GetYaxis()->GetBinLowEdge(j + 1); scaling = pdfflux->GetBinContent(i + 1) * binWidth; } else { double binWidth = fMCHist->GetXaxis()->GetBinLowEdge(i + 2) - fMCHist->GetXaxis()->GetBinLowEdge(i + 1); scaling = pdfflux->GetBinContent(j + 1) * binWidth; } // fMCHist->SetBinContent(i + 1, j + 1, // fMCHist->GetBinContent(i + 1, j + 1) / // pdfflux->GetBinContent(i + 1) / binWidth); // fMCHist->SetBinError(i + 1, j + 1, fMCHist->GetBinError(i + 1, j + 1) / // pdfflux->GetBinContent(i + 1) / // binWidth); fMCHist->SetBinContent(i + 1, j + 1, fMCHist->GetBinContent(i + 1, j + 1) / scaling); fMCHist->SetBinError(i + 1, j + 1, fMCHist->GetBinError(i + 1, j + 1) / scaling); } } delete eventhist; delete fFluxHist; }; TH1D *PlotUtils::InterpolateFineHistogram(TH1D *hist, int res, std::string opt) { int nbins = hist->GetNbinsX(); double elow = hist->GetXaxis()->GetBinLowEdge(1); double ehigh = hist->GetXaxis()->GetBinLowEdge(nbins + 1); bool width = true; // opt.find("width") != std::string::npos; TH1D *fine = new TH1D("fine", "fine", nbins * res, elow, ehigh); TGraph *temp = new TGraph(); for (int i = 0; i < nbins; i++) { double E = hist->GetXaxis()->GetBinCenter(i + 1); double C = hist->GetBinContent(i + 1); double W = hist->GetXaxis()->GetBinWidth(i + 1); if (!width) W = 1.0; if (W != 0.0) temp->SetPoint(temp->GetN(), E, C / W); } for (int i = 0; i < fine->GetNbinsX(); i++) { double E = fine->GetXaxis()->GetBinCenter(i + 1); double W = fine->GetBinWidth(i + 1); if (!width) W = 1.0; fine->SetBinContent(i + 1, temp->Eval(E, 0, "S") * W); } fine->Scale(hist->Integral(1, hist->GetNbinsX() + 1) / fine->Integral(1, fine->GetNbinsX() + 1)); // std::cout << "Interpolation Difference = " //<< fine->Integral(1, fine->GetNbinsX() + 1) << "/" //<< hist->Integral(1, hist->GetNbinsX() + 1) << std::endl; return fine; } //******************************************************************** // This interpolates the flux by a TGraph instead of requiring the flux and MC // flux to have the same binning void PlotUtils::FluxUnfoldedScaling(TH1D *mcHist, TH1D *fhist, TH1D *ehist, double scalefactor, int nevents) { //******************************************************************** TH1D *eventhist = (TH1D *)ehist->Clone(); TH1D *fFluxHist = (TH1D *)fhist->Clone(); std::string name = std::string(mcHist->GetName()); if (FitPar::Config().GetParB("save_flux_debug")) { mcHist->Write((name + "_UNF_MC").c_str()); fFluxHist->Write((name + "_UNF_FLUX").c_str()); eventhist->Write((name + "_UNF_EVT").c_str()); TH1D *scalehist = new TH1D("scalehist", "scalehist", 1, 0.0, 1.0); scalehist->SetBinContent(1, scalefactor); scalehist->SetBinContent(2, nevents); scalehist->Write((name + "_UNF_SCALE").c_str()); } // Undo width integral in SF mcHist->Scale(scalefactor / eventhist->Integral(1, eventhist->GetNbinsX() + 1, "width")); // Standardise The Flux eventhist->Scale(1.0 / fFluxHist->Integral()); fFluxHist->Scale(1.0 / fFluxHist->Integral()); // Scale mcHist by eventhist integral mcHist->Scale(eventhist->Integral(1, eventhist->GetNbinsX() + 1)); // Now Get a flux PDF TH1D *pdfflux = (TH1D *)mcHist->Clone(); pdfflux->Reset(); for (int i = 0; i < mcHist->GetNbinsX(); i++) { double Ml = mcHist->GetXaxis()->GetBinLowEdge(i + 1); double Mh = mcHist->GetXaxis()->GetBinLowEdge(i + 2); // double Mc = mcHist->GetXaxis()->GetBinCenter(i+1); // double Me = mcHist->GetBinContent(i+1); // double Mw = mcHist->GetBinWidth(i+1); double fluxint = 0.0; for (int j = 0; j < fFluxHist->GetNbinsX(); j++) { // double Fc = fFluxHist->GetXaxis()->GetBinCenter(j+1); double Fl = fFluxHist->GetXaxis()->GetBinLowEdge(j + 1); double Fh = fFluxHist->GetXaxis()->GetBinLowEdge(j + 2); double Fe = fFluxHist->GetBinContent(j + 1); double Fw = fFluxHist->GetXaxis()->GetBinWidth(j + 1); if (Fl >= Ml and Fh <= Mh) { fluxint += Fe; } else if (Fl < Ml and Fl < Mh and Fh > Ml and Fh < Mh) { fluxint += Fe * (Fh - Ml) / Fw; } else if (Fh > Mh and Fl < Mh and Fh > Ml and Fl > Ml) { fluxint += Fe * (Mh - Fl) / Fw; } else if (Ml >= Fl and Mh <= Fh) { fluxint += Fe * (Mh - Ml) / Fw; } else { continue; } } pdfflux->SetBinContent(i + 1, fluxint); } if (FitPar::Config().GetParB("save_flux_debug")) { pdfflux->Write((name + "_UNF_SCALEHIST").c_str()); } // Scale MC hist by pdfflux for (int i = 0; i < mcHist->GetNbinsX(); i++) { if (pdfflux->GetBinContent(i + 1) == 0.0) continue; mcHist->SetBinContent(i + 1, mcHist->GetBinContent(i + 1) / pdfflux->GetBinContent(i + 1)); mcHist->SetBinError(i + 1, mcHist->GetBinError(i + 1) / pdfflux->GetBinContent(i + 1)); } delete eventhist; delete fFluxHist; }; // MOVE TO GENERAL UTILS //******************************************************************** void PlotUtils::Set2DHistFromText(std::string dataFile, TH2 *hist, double norm, bool skipbins) { //******************************************************************** std::string line; std::ifstream data(dataFile.c_str(), std::ifstream::in); int yBin = 0; while (std::getline(data >> std::ws, line, '\n')) { std::vector entries = GeneralUtils::ParseToDbl(line, " "); // Loop over entries and insert them into the histogram for (uint xBin = 0; xBin < entries.size(); xBin++) { if (!skipbins || entries[xBin] != -1.0) hist->SetBinContent(xBin + 1, yBin + 1, entries[xBin] * norm); } yBin++; } return; } // MOVE TO GENERAL UTILS TH1D *PlotUtils::GetTH1DFromFile(std::string dataFile, std::string title, std::string fPlotTitles, std::string alt_name) { TH1D *tempPlot; // If format is a root file if (dataFile.find(".root") != std::string::npos) { TFile *temp_infile = new TFile(dataFile.c_str(), "READ"); tempPlot = (TH1D *)temp_infile->Get(title.c_str()); tempPlot->SetDirectory(0); temp_infile->Close(); delete temp_infile; // Else its a space separated txt file } else { // Make a TGraph Errors TGraphErrors *gr = new TGraphErrors(dataFile.c_str(), "%lg %lg %lg"); if (gr->IsZombie()) { NUIS_ABORT( dataFile << " is a zombie and could not be read. Are you sure it exists?" << std::endl); } double *bins = gr->GetX(); double *values = gr->GetY(); double *errors = gr->GetEY(); int npoints = gr->GetN(); // Fill the histogram from it tempPlot = new TH1D(title.c_str(), title.c_str(), npoints - 1, bins); for (int i = 0; i < npoints; ++i) { tempPlot->SetBinContent(i + 1, values[i]); // If only two columns are present in the input file, use the sqrt(values) // as the error equivalent to assuming that the error is statistical. Also // check that we're looking at an event rate rather than a cross section if (!errors[i] && values[i] > 1E-30) { tempPlot->SetBinError(i + 1, sqrt(values[i])); } else { tempPlot->SetBinError(i + 1, errors[i]); } } delete gr; } // Allow alternate naming for root files if (!alt_name.empty()) { tempPlot->SetNameTitle(alt_name.c_str(), alt_name.c_str()); } // Allow alternate axis titles if (!fPlotTitles.empty()) { tempPlot->SetNameTitle( tempPlot->GetName(), (std::string(tempPlot->GetTitle()) + fPlotTitles).c_str()); } return tempPlot; }; -TH1D *PlotUtils::GetRatioPlot(TH1D *hist1, TH1D *hist2) { - // make copy of first hist - TH1D *new_hist = (TH1D *)hist1->Clone(); +TH1D *PlotUtils::GetRatioPlot(TH1D *hist1, TH1D *hist2, TH1D *new_hist) { + + // If the hist to save into doesn't exist, make copy of first hist + if (!new_hist) new_hist = (TH1D *)hist1->Clone(); // Do bins and errors ourselves as scales can go awkward for (int i = 0; i < new_hist->GetNbinsX(); i++) { - if (hist2->GetBinContent(i + 1) == 0.0) { - new_hist->SetBinContent(i + 1, 0.0); + + double binVal = 0; + double binErr = 0; + + if (hist2->GetBinContent(i+1) && hist1->GetBinContent(i+1)) { + binVal = hist1->GetBinContent(i+1)/hist2->GetBinContent(i+1); + double fractErr1 = hist1->GetBinError(i+1)/hist1->GetBinContent(i+1); + double fractErr2 = hist2->GetBinError(i+1)/hist2->GetBinContent(i+1); + binErr = binVal * sqrt(fractErr1*fractErr1 + fractErr2*fractErr2); } - new_hist->SetBinContent(i + 1, hist1->GetBinContent(i + 1) / - hist2->GetBinContent(i + 1)); - new_hist->SetBinError(i + 1, hist1->GetBinError(i + 1) / - hist2->GetBinContent(i + 1)); + new_hist->SetBinContent(i+1, binVal); + new_hist->SetBinError(i+1, binErr); } - return new_hist; }; TH1D *PlotUtils::GetRenormalisedPlot(TH1D *hist1, TH1D *hist2) { // make copy of first hist TH1D *new_hist = (TH1D *)hist1->Clone(); if (hist1->Integral("width") == 0 or hist2->Integral("width") == 0) { new_hist->Reset(); return new_hist; } Double_t scaleF = hist2->Integral("width") / hist1->Integral("width"); new_hist->Scale(scaleF); return new_hist; }; TH1D *PlotUtils::GetShapePlot(TH1D *hist1) { // make copy of first hist TH1D *new_hist = (TH1D *)hist1->Clone(); if (hist1->Integral("width") == 0) { new_hist->Reset(); return new_hist; } Double_t scaleF1 = 1.0 / hist1->Integral("width"); new_hist->Scale(scaleF1); return new_hist; }; TH1D *PlotUtils::GetShapeRatio(TH1D *hist1, TH1D *hist2) { TH1D *new_hist1 = GetShapePlot(hist1); TH1D *new_hist2 = GetShapePlot(hist2); // Do bins and errors ourselves as scales can go awkward for (int i = 0; i < new_hist1->GetNbinsX(); i++) { if (hist2->GetBinContent(i + 1) == 0) { new_hist1->SetBinContent(i + 1, 0.0); } new_hist1->SetBinContent(i + 1, new_hist1->GetBinContent(i + 1) / new_hist2->GetBinContent(i + 1)); new_hist1->SetBinError(i + 1, new_hist1->GetBinError(i + 1) / new_hist2->GetBinContent(i + 1)); } delete new_hist2; return new_hist1; }; TH2D *PlotUtils::GetCovarPlot(TMatrixDSym *cov, std::string name, std::string title) { TH2D *CovarPlot; if (cov) CovarPlot = new TH2D((*cov)); else CovarPlot = new TH2D(name.c_str(), title.c_str(), 1, 0, 1, 1, 0, 1); CovarPlot->SetName(name.c_str()); CovarPlot->SetTitle(title.c_str()); return CovarPlot; } TH2D *PlotUtils::GetFullCovarPlot(TMatrixDSym *cov, std::string name) { return PlotUtils::GetCovarPlot( cov, name + "_COV", name + "_COV;Bins;Bins;Covariance (#times10^{-76})"); } TH2D *PlotUtils::GetInvCovarPlot(TMatrixDSym *cov, std::string name) { return PlotUtils::GetCovarPlot( cov, name + "_INVCOV", name + "_INVCOV;Bins;Bins;Inv. Covariance (#times10^{-76})"); } TH2D *PlotUtils::GetDecompCovarPlot(TMatrixDSym *cov, std::string name) { return PlotUtils::GetCovarPlot( cov, name + "_DECCOV", name + "_DECCOV;Bins;Bins;Decomp Covariance (#times10^{-76})"); } TH1D *PlotUtils::GetTH1DFromRootFile(std::string file, std::string name) { if (name.empty()) { std::vector tempfile = GeneralUtils::ParseToStr(file, ";"); file = tempfile[0]; name = tempfile[1]; } TFile *rootHistFile = new TFile(file.c_str(), "READ"); TH1D *tempHist = (TH1D *)rootHistFile->Get(name.c_str())->Clone(); if (tempHist == NULL) { NUIS_ABORT("Could not find distribution " << name << " in file " << file); } tempHist->SetDirectory(0); rootHistFile->Close(); return tempHist; } TH2D *PlotUtils::GetTH2DFromRootFile(std::string file, std::string name) { if (name.empty()) { std::vector tempfile = GeneralUtils::ParseToStr(file, ";"); file = tempfile[0]; name = tempfile[1]; } TFile *rootHistFile = new TFile(file.c_str(), "READ"); TH2D *tempHist = (TH2D *)rootHistFile->Get(name.c_str())->Clone(); tempHist->SetDirectory(0); rootHistFile->Close(); delete rootHistFile; return tempHist; } TH1 *PlotUtils::GetTH1FromRootFile(std::string file, std::string name) { if (name.empty()) { std::vector tempfile = GeneralUtils::ParseToStr(file, ";"); file = tempfile[0]; name = tempfile[1]; } TFile *rootHistFile = new TFile(file.c_str(), "READ"); if (!rootHistFile || rootHistFile->IsZombie()) { NUIS_ABORT("Couldn't open root file: \"" << file << "\"."); } TH1 *tempHist = dynamic_cast(rootHistFile->Get(name.c_str())->Clone()); if (!tempHist) { NUIS_ABORT("Couldn't retrieve: \"" << name << "\" from root file: \"" << file << "\"."); } tempHist->SetDirectory(0); rootHistFile->Close(); delete rootHistFile; return tempHist; } TGraph *PlotUtils::GetTGraphFromRootFile(std::string file, std::string name) { if (name.empty()) { std::vector tempfile = GeneralUtils::ParseToStr(file, ";"); file = tempfile[0]; name = tempfile[1]; } TDirectory *olddir = gDirectory; TFile *rootHistFile = new TFile(file.c_str(), "READ"); if (!rootHistFile || rootHistFile->IsZombie()) { NUIS_ABORT("Couldn't open root file: \"" << file << "\"."); } TDirectory *newdir = gDirectory; TGraph *temp = dynamic_cast(rootHistFile->Get(name.c_str())->Clone()); if (!temp) { NUIS_ABORT("Couldn't retrieve: \"" << name << "\" from root file: \"" << file << "\"."); } newdir->Remove(temp); olddir->Append(temp); rootHistFile->Close(); olddir->cd(); return temp; } /// Returns a vector of named TH1*s found in a single input file. /// /// Expects a descriptor like: file.root[hist1|hist2|...] std::vector PlotUtils::GetTH1sFromRootFile(std::string const &descriptor) { std::vector descriptors = GeneralUtils::ParseToStr(descriptor, ","); std::vector hists; for (size_t d_it = 0; d_it < descriptors.size(); ++d_it) { std::string &d = descriptors[d_it]; std::vector fname = GeneralUtils::ParseToStr(d, "["); if (!fname.size() || !fname[0].length()) { NUIS_ABORT("Couldn't find input file when attempting to parse : \"" << d << "\". Expected input.root[hist1|hist2|...]."); } if (fname[1][fname[1].length() - 1] == ']') { fname[1] = fname[1].substr(0, fname[1].length() - 1); } std::vector histnames = GeneralUtils::ParseToStr(fname[1], "|"); if (!histnames.size()) { NUIS_ABORT( "Couldn't find any histogram name specifiers when attempting to " "parse " ": \"" << fname[1] << "\". Expected hist1|hist2|..."); } TFile *rootHistFile = new TFile(fname[0].c_str(), "READ"); if (!rootHistFile || rootHistFile->IsZombie()) { NUIS_ABORT("Couldn't open root file: \"" << fname[0] << "\"."); } for (size_t i = 0; i < histnames.size(); ++i) { TH1 *tempHist = dynamic_cast(rootHistFile->Get(histnames[i].c_str())->Clone()); if (!tempHist) { NUIS_ABORT("Couldn't retrieve: \"" << histnames[i] << "\" from root file: \"" << fname[0] << "\"."); } tempHist->SetDirectory(0); hists.push_back(tempHist); } rootHistFile->Close(); } return hists; } // Create an array from an input file std::vector PlotUtils::GetArrayFromTextFile(std::string DataFile) { std::string line; std::ifstream data(DataFile.c_str(), std::ifstream::in); // Get first line std::getline(data >> std::ws, line, '\n'); // Convert from a string into a vector of double std::vector entries = GeneralUtils::ParseToDbl(line, " "); return entries; } // Get a 2D array from a text file std::vector > PlotUtils::Get2DArrayFromTextFile(std::string DataFile) { std::string line; std::vector > DataArray; std::ifstream data(DataFile.c_str(), std::ifstream::in); while (std::getline(data >> std::ws, line, '\n')) { std::vector entries = GeneralUtils::ParseToDbl(line, " "); DataArray.push_back(entries); } return DataArray; } TH2D *PlotUtils::GetTH2DFromTextFile(std::string data, std::string binx, std::string biny) { // First read in the binning // Array of x binning std::vector xbins = GetArrayFromTextFile(binx); // Array of y binning std::vector ybins = GetArrayFromTextFile(biny); // Read in the data std::vector > Data = Get2DArrayFromTextFile(data); // And finally fill the data TH2D *DataPlot = new TH2D("TempHist", "TempHist", xbins.size() - 1, &xbins[0], ybins.size() - 1, &ybins[0]); int nBinsX = 0; int nBinsY = 0; for (std::vector >::iterator it = Data.begin(); it != Data.end(); ++it) { nBinsX++; // Get the inner vector std::vector temp = *it; // Save the previous number[of bins to make sure it's uniform binning int oldBinsY = nBinsY; // Reset the counter nBinsY = 0; for (std::vector::iterator jt = temp.begin(); jt != temp.end(); ++jt) { nBinsY++; DataPlot->SetBinContent(nBinsX, nBinsY, *jt); DataPlot->SetBinError(nBinsX, nBinsY, 0.0); } if (oldBinsY > 0 && oldBinsY != nBinsY) { NUIS_ERR(FTL, "Found non-uniform y-binning in " << data); NUIS_ERR(FTL, "Previous slice: " << oldBinsY); NUIS_ERR(FTL, "Current slice: " << nBinsY); NUIS_ABORT("Non-uniform binning is not supported in " "PlotUtils::GetTH2DFromTextFile"); } } // Check x bins if (size_t(nBinsX + 1) != xbins.size()) { NUIS_ERR(FTL, "Number of x bins in data histogram does not match the binning " "histogram!"); NUIS_ERR( FTL, "Are they the wrong way around (i.e. xbinning should be ybinning)?"); NUIS_ERR(FTL, "Data: " << nBinsX); NUIS_ABORT("From " << binx << " binning: " << xbins.size()); } // Check y bins if (size_t(nBinsY + 1) != ybins.size()) { NUIS_ERR(FTL, "Number of y bins in data histogram does not match the binning " "histogram!"); NUIS_ERR( FTL, "Are they the wrong way around (i.e. xbinning should be ybinning)?"); NUIS_ERR(FTL, "Data: " << nBinsY); NUIS_ABORT("From " << biny << " binning: " << ybins.size()); } return DataPlot; } TH1D *PlotUtils::GetSliceY(TH2D *Hist, int SliceNo) { TH1D *Slice = Hist->ProjectionX(Form("%s_SLICEY%i", Hist->GetName(), SliceNo), SliceNo, SliceNo, "e"); Slice->SetTitle(Form("%s, %.2f-%.2f", Hist->GetYaxis()->GetTitle(), Hist->GetYaxis()->GetBinLowEdge(SliceNo), Hist->GetYaxis()->GetBinLowEdge(SliceNo + 1))); Slice->GetYaxis()->SetTitle(Hist->GetZaxis()->GetTitle()); return Slice; } TH1D *PlotUtils::GetSliceX(TH2D *Hist, int SliceNo) { TH1D *Slice = Hist->ProjectionY(Form("%s_SLICEX%i", Hist->GetName(), SliceNo), SliceNo, SliceNo, "e"); Slice->SetTitle(Form("%s, %.2f-%.2f", Hist->GetXaxis()->GetTitle(), Hist->GetXaxis()->GetBinLowEdge(SliceNo), Hist->GetXaxis()->GetBinLowEdge(SliceNo + 1))); Slice->GetYaxis()->SetTitle(Hist->GetZaxis()->GetTitle()); return Slice; } void PlotUtils::AddNeutModeArray(TH1D *hist1[], TH1D *hist2[], double scaling) { for (int i = 0; i < 60; i++) { if (!hist2[i]) continue; if (!hist1[i]) continue; hist1[i]->Add(hist2[i], scaling); } return; } void PlotUtils::ScaleToData(TH1D *data, TH1D *mc, TH1I *mask) { double scaleF = GetDataMCRatio(data, mc, mask); mc->Scale(scaleF); return; } void PlotUtils::MaskBins(TH1D *hist, TH1I *mask) { for (int i = 0; i < hist->GetNbinsX(); i++) { if (mask->GetBinContent(i + 1) <= 0.5) continue; hist->SetBinContent(i + 1, 0.0); hist->SetBinError(i + 1, 0.0); NUIS_LOG(DEB, "MaskBins: Set " << hist->GetName() << " Bin " << i + 1 << " to 0.0 +- 0.0"); } return; } void PlotUtils::MaskBins(TH2D *hist, TH2I *mask) { for (int i = 0; i < hist->GetNbinsX(); i++) { for (int j = 0; j < hist->GetNbinsY(); j++) { if (mask->GetBinContent(i + 1, j + 1) <= 0.5) continue; hist->SetBinContent(i + 1, j + 1, 0.0); hist->SetBinError(i + 1, j + 1, 0.0); NUIS_LOG(DEB, "MaskBins: Set " << hist->GetName() << " Bin " << i + 1 << " " << j + 1 << " to 0.0 +- 0.0"); } } return; } double PlotUtils::GetDataMCRatio(TH1D *data, TH1D *mc, TH1I *mask) { double rat = 1.0; TH1D *newmc = (TH1D *)mc->Clone(); TH1D *newdt = (TH1D *)data->Clone(); if (mask) { MaskBins(newmc, mask); MaskBins(newdt, mask); } rat = newdt->Integral() / newmc->Integral(); return rat; } TH2D *PlotUtils::GetCorrelationPlot(TH2D *cov, std::string name) { TH2D *cor = (TH2D *)cov->Clone(); cor->Reset(); for (int i = 0; i < cov->GetNbinsX(); i++) { for (int j = 0; j < cov->GetNbinsY(); j++) { if (cov->GetBinContent(i + 1, i + 1) != 0.0 and cov->GetBinContent(j + 1, j + 1) != 0.0) cor->SetBinContent(i + 1, j + 1, cov->GetBinContent(i + 1, j + 1) / (sqrt(cov->GetBinContent(i + 1, i + 1) * cov->GetBinContent(j + 1, j + 1)))); } } if (!name.empty()) { cor->SetNameTitle(name.c_str(), (name + ";;correlation").c_str()); } cor->SetMinimum(-1); cor->SetMaximum(1); return cor; } TH2D *PlotUtils::GetDecompPlot(TH2D *cov, std::string name) { TMatrixDSym *covarmat = new TMatrixDSym(cov->GetNbinsX()); for (int i = 0; i < cov->GetNbinsX(); i++) for (int j = 0; j < cov->GetNbinsY(); j++) (*covarmat)(i, j) = cov->GetBinContent(i + 1, j + 1); TMatrixDSym *decompmat = StatUtils::GetDecomp(covarmat); TH2D *dec = (TH2D *)cov->Clone(); for (int i = 0; i < cov->GetNbinsX(); i++) for (int j = 0; j < cov->GetNbinsY(); j++) dec->SetBinContent(i + 1, j + 1, (*decompmat)(i, j)); delete covarmat; delete decompmat; dec->SetNameTitle(name.c_str(), (name + ";;;decomposition").c_str()); return dec; } TH2D *PlotUtils::MergeIntoTH2D(TH1D *xhist, TH1D *yhist, std::string zname) { std::vector xedges, yedges; for (int i = 0; i < xhist->GetNbinsX() + 2; i++) { xedges.push_back(xhist->GetXaxis()->GetBinLowEdge(i + 1)); } for (int i = 0; i < yhist->GetNbinsX() + 2; i++) { yedges.push_back(yhist->GetXaxis()->GetBinLowEdge(i + 1)); } int nbinsx = xhist->GetNbinsX(); int nbinsy = yhist->GetNbinsX(); std::string name = std::string(xhist->GetName()) + "_vs_" + std::string(yhist->GetName()); std::string titles = ";" + std::string(xhist->GetXaxis()->GetTitle()) + ";" + std::string(yhist->GetXaxis()->GetTitle()) + ";" + zname; TH2D *newplot = new TH2D(name.c_str(), (name + titles).c_str(), nbinsx, &xedges[0], nbinsy, &yedges[0]); return newplot; } //*************************************************** void PlotUtils::MatchEmptyBins(TH1D *data, TH1D *mc) { //************************************************** for (int i = 0; i < data->GetNbinsX(); i++) { if (data->GetBinContent(i + 1) == 0.0 or data->GetBinError(i + 1) == 0.0) mc->SetBinContent(i + 1, 0.0); } return; } //*************************************************** void PlotUtils::MatchEmptyBins(TH2D *data, TH2D *mc) { //************************************************** 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 or data->GetBinError(i + 1, j + 1) == 0.0) mc->SetBinContent(i + 1, j + 1, 0.0); } } return; } //*************************************************** TH1D *PlotUtils::GetProjectionX(TH2D *hist, TH2I *mask) { //*************************************************** TH2D *maskedhist = StatUtils::ApplyHistogramMasking(hist, mask); // This includes the underflow/overflow TH1D *hist_X = maskedhist->ProjectionX("_px", 1, maskedhist->GetXaxis()->GetNbins()); hist_X->SetTitle(Form("%s x no under/overflow", hist_X->GetTitle())); delete maskedhist; return hist_X; } //*************************************************** TH1D *PlotUtils::GetProjectionY(TH2D *hist, TH2I *mask) { //*************************************************** TH2D *maskedhist = StatUtils::ApplyHistogramMasking(hist, mask); // This includes the underflow/overflow TH1D *hist_Y = maskedhist->ProjectionY("_py", 1, maskedhist->GetYaxis()->GetNbins()); hist_Y->SetTitle(Form("%s y no under/overflow", hist_Y->GetTitle())); delete maskedhist; return hist_Y; } + + +// A slightly hacky way to restrict the range of a TH1D +TH1D* PlotUtils::RestrictHistRange(TH1D* inHist, double minVal, double maxVal){ + + NUIS_LOG(SAM, "Restricting histogram range to " << minVal << " - " << maxVal); + + std::string name = inHist->GetName(); + std::string title = inHist->GetTitle(); + + std::vector bin_edges; + std::vector bin_vals; + std::vector bin_errs; + + for (int i=0; iGetNbinsX(); ++i){ + + double low_edge = inHist->GetXaxis()->GetBinLowEdge(i+1); + double up_edge = inHist->GetXaxis()->GetBinUpEdge(i+1); + + if (low_edge < minVal) continue; + + // Deal with the slightly special case of the first bin + if (bin_edges.size() == 0) bin_edges.push_back(low_edge); + + // Deal with the rest + if (maxVal >= up_edge) { + bin_edges.push_back(up_edge); + bin_vals .push_back(inHist->GetBinContent(i+1)); + bin_errs .push_back(inHist->GetBinError(i+1)); + } + } + + int nbins = bin_edges.size()-1; + + // Sanity check + if (nbins < 1) return inHist; + + // Now make a new histogram + TH1D *ret = new TH1D("temp", "temp", nbins, bin_edges.data()); + + for (int i=0; iSetBinContent(i+1, bin_vals[i]); + ret->SetBinError(i+1, bin_errs[i]); + } + delete inHist; + ret->SetNameTitle(name.c_str(), title.c_str()); + return ret; +} diff --git a/src/Utils/PlotUtils.h b/src/Utils/PlotUtils.h index b6eed8a..84894aa 100644 --- a/src/Utils/PlotUtils.h +++ b/src/Utils/PlotUtils.h @@ -1,277 +1,277 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef PLOTUTILS_H_SEEN #define PLOTUTILS_H_SEEN #include "TF1.h" #include "TFile.h" #include "TH1.h" #include "TMatrixD.h" #include "TProfile.h" #include "TSystem.h" #include "TVectorD.h" #include #include #include #include #include // C Includes #include #include #include #include #include #include #include #include #include #include // ROOT includes #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "TGraphErrors.h" #include "TH2Poly.h" #include "TMatrixDSym.h" // Fit includes #include "FitEvent.h" #include "FitLogger.h" #include "GeneralUtils.h" #include "StatUtils.h" /*! * \addtogroup Utils * @{ */ //! Functions to handle different TH1s and TFiles namespace PlotUtils { /*! MISC Functions */ //! Check the root file has an object containing the given substring in its name bool CheckObjectWithName(TFile* inFile, std::string substring); //! Get object in a TFile that has a matching substring in its name std::string GetObjectWithName(TFile* inFile, std::string substring); /*! Interaction Mode Histogram Handling */ //! Fill the Histogram Array with 61 new histograms for interaction channels. void CreateNeutModeArray(TH1* hist, TH1* neutarray[]); //! Call Fill on the relevent Mode 1D Histogram void FillNeutModeArray(TH1D* hist[], int mode, double xval, double weight = 1.0); //! Call Fill on the relevant Mode 2D Histogram void FillNeutModeArray(TH2D* hist[], int mode, double xval, double yval, double weight = 1.0); //! Given two arrays of histograms for the NEUT interaction mode, hist1 = hist1 //! + scale*hist2 void AddNeutModeArray(TH1D* hist1[], TH1D* hist2[], double scaling = 1.0); //! Generate a legend for the THStack TLegend GenerateStackLegend(THStack stack, int xlow, int ylow, int xhigh, int yhigh); //! Turn the array of TH1 histograms into a stack of Modes THStack GetNeutModeStack(std::string title, TH1* ModeStack[], int option); //! Get a slice in Y of a TH2D TH1D* GetSliceY(TH2D*, int); //! Get a slice in X of a TH2D TH1D* GetSliceX(TH2D*, int); //! Reset each histogram in the mode array void ResetNeutModeArray(TH1* hist[]); //! Scale each histogram in the mode array by a single scaling factor, option //! can be used to define "width" scaling. void ScaleNeutModeArray(TH1* hist[], double factor, std::string option = ""); //! Free up the memory used by each of the 61 mode histograms void DeleteNeutModeArray(TH1* neutarray[]); /*! Handling Functions */ -//! Fill a mask histogram from a text file -TH2D* SetMaskHist(std::string type, TH2D* data); - //! Divide by the flux histogram for Enu Histograms void DivideByFlux(TH1D* fMCHist, TH1D* fFluxHist); TH1D* InterpolateFineHistogram(TH1D* hist, int res, std::string opt); //! Flux unfolded scaling, like DivideByFlux but uses interpolation. void FluxUnfoldedScaling(TH1D* plot, TH1D* flux, TH1D* events = NULL, double scalefactor = 1.0, int nevents = 1); //! Flux unfolded scaling for 2D histograms void FluxUnfoldedScaling(TH2D* plot, TH1D* flux, TH1D* events = NULL, double scalefactor = 1.0); //! Fill a 2D Histogram from a text file void Set2DHistFromText(std::string dataFile, TH2* hist, double norm, bool skipbins = false); //! Fill a 2D Poly Histogram from a text file void Set2PolyHistFromText(std::string dataFile, TH2Poly* hist, double norm, bool skipbins = false); //! Fill a 1D Histogram from a text file TH1D* GetTH1DFromFile(std::string dataFile, std::string title = "", std::string fPlotTitles = "", std::string alt_name = ""); TH1* GetTH1FromRootFile(std::string file, std::string name); std::vector GetTH1sFromRootFile(std::string const& descriptor); //! Grab a 1D Histrogram from a ROOT File TH1D* GetTH1DFromRootFile(std::string file, std::string name); //! Grab a 2D Histrogram from a ROOT File TH2D* GetTH2DFromRootFile(std::string file, std::string name); //! Grab a 2D Histrogram from a ROOT File template inline TH* GetTH2FromRootFile(std::string file, std::string name){ if (name.empty()) { std::vector tempfile = GeneralUtils::ParseToStr(file, ";"); file = tempfile[0]; name = tempfile[1]; } TFile *rootHistFile = new TFile(file.c_str(), "READ"); TH *tempHist = dynamic_cast(rootHistFile->Get(name.c_str())->Clone()); if(!tempHist){ NUIS_ABORT("Failed to read " << name << " from " << file); } tempHist->SetDirectory(nullptr); rootHistFile->Close(); delete rootHistFile; return tempHist; } //! Get a TGraph from a ROOT file TGraph* GetTGraphFromRootFile(std::string file, std::string name); //! Grab a 2D Histrogram from a ROOT File TH2D* GetTH2DFromTextFile(std::string data, std::string binx, std::string biny); std::vector GetArrayFromTextFile(std::string file); std::vector > Get2DArrayFromTextFile(std::string file); //! Scale mc to match data considering empty and masked bins void ScaleToData(TH1D* data, TH1D* mc, TH1I* mask); //! Apply bin masking (More cosmetic) void MaskBins(TH1D* hist, TH1I* mask); //! Apply bin masking (More cosmetic) void MaskBins(TH2D* hist, TH2I* mask); //! Get the data MC ratio considering empty and masked bins double GetDataMCRatio(TH1D* data, TH1D* mc, TH1I* mask = NULL); /*! Formatting Plot Utils */ //! Create new ratio plot. hist3 = hist1/hist2 -TH1D* GetRatioPlot(TH1D* hist1, TH1D* hist2); +TH1D* GetRatioPlot(TH1D* hist1, TH1D* hist2, TH1D* new_hist=NULL); //! Create new plot of hist2 normalised to hist1. hist2 = hist1 * //! (Integral(hist1)/Integral(hist2)) TH1D* GetRenormalisedPlot(TH1D* hist1, TH1D* hist2); //! Normalise histogram to area of unity. TH1D* GetShapePlot(TH1D* hist1); //! Normalise hist1 and hist2 to unity, before creating a new plot of their //! ratio. TH1D* GetShapeRatio(TH1D* hist1, TH1D* hist2); //! Create a covariance histogram from a TMatrixDSym and add titles given. TH2D* GetCovarPlot(TMatrixDSym* cov, std::string name, std::string title); //! Wrapper function to create full covariance plot TH2D* GetFullCovarPlot(TMatrixDSym* cov, std::string name); //! Wrapper function to create inverted covariance plot TH2D* GetInvCovarPlot(TMatrixDSym* cov, std::string name); //! Wrapper function to create decomposed covariance plot TH2D* GetDecompCovarPlot(TMatrixDSym* cov, std::string name); //! Given a covariance histogram, divide by errors to form a correlation plot. TH2D* GetCorrelationPlot(TH2D* cov, std::string name); //! Given a covariance histogram, calculate the decomposed matrix to form a //! decomposed plot. TH2D* GetDecompPlot(TH2D* cov, std::string name); //! Given two 1D histograms create a 2D histogram which uses their bin edges to //! define both axes. TH2D* MergeIntoTH2D(TH1D* xhist, TH1D* yhist, std::string zname = ""); //! Given a 1D Histogram, set any empty bins in Data to empty bins in MC void MatchEmptyBins(TH1D* data, TH1D* mc); //! Given a 2D Histogram, set any empty bins in Data to empty bins in MC void MatchEmptyBins(TH2D* data, TH2D* mc); //! Return a projection of a 2D Histogram onto X accounting for bin masking TH1D* GetProjectionX(TH2D* hist, TH2I* mask); //! Return a projection of a 2D Histogram onto Y accounting for bin masking TH1D* GetProjectionY(TH2D* hist, TH2I* mask); + +//! Return a histogram with a restricted range +TH1D* RestrictHistRange(TH1D* inHist, double minVal, double maxVal); } /*! @} */ #endif diff --git a/src/Utils/README b/src/Utils/README deleted file mode 100644 index 69faff4..0000000 --- a/src/Utils/README +++ /dev/null @@ -1,2 +0,0 @@ -#All the functions in this folder are to unify the statistical methods for each of the different measurements under a single namespace so new ways to calculate test statistics can be added to all classes quickly. -# Utils Methods \ No newline at end of file diff --git a/src/Utils/SAMPLEREADME b/src/Utils/SAMPLEREADME deleted file mode 100644 index 1607263..0000000 --- a/src/Utils/SAMPLEREADME +++ /dev/null @@ -1,3 +0,0 @@ -./FitUtils.cxx -./PlotUtils.cxx -./StatUtils.cxx diff --git a/src/Utils/SignalDef.cxx b/src/Utils/SignalDef.cxx index f85b4f0..03456ad 100644 --- a/src/Utils/SignalDef.cxx +++ b/src/Utils/SignalDef.cxx @@ -1,289 +1,289 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #include "FitUtils.h" #include "SignalDef.h" bool SignalDef::isCCINC(FitEvent *event, int nuPDG, double EnuMin, double EnuMax) { // Check for the desired PDG code if (!event->HasISParticle(nuPDG)) return false; // Check that it's within the allowed range if set if (EnuMin != EnuMax) { if (!SignalDef::IsEnuInRange(event, EnuMin*1000, EnuMax*1000)) { return false; } } // Check that the charged lepton we expect has been produced if (!event->HasFSParticle(nuPDG > 0 ? nuPDG-1 : nuPDG+1)) return false; return true; } bool SignalDef::isNCINC(FitEvent *event, int nuPDG, double EnuMin, double EnuMax) { // Check for the desired PDG code before and after the interaction if (!event->HasISParticle(nuPDG) || !event->HasFSParticle(nuPDG)) return false; // Check that it's within the allowed range if set if (EnuMin != EnuMax) if (!SignalDef::IsEnuInRange(event, EnuMin*1000, EnuMax*1000)) return false; return true; } bool SignalDef::isCC0pi(FitEvent *event, int nuPDG, double EnuMin, double EnuMax){ // Check it's CCINC if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) return false; // Veto event with mesons if (event->NumFSMesons() != 0) return false; // Veto events which don't have exactly 1 outgoing charged lepton if (event->NumFSLeptons() != 1) return false; return true; } bool SignalDef::isNC0pi(FitEvent *event, int nuPDG, double EnuMin, double EnuMax){ // Check it's NCINC if (!SignalDef::isNCINC(event, nuPDG, EnuMin, EnuMax)) return false; // Veto event with mesons if (event->NumFSMesons() != 0) return false; // Veto events with a charged lepton if (event->NumFSLeptons() != 0) return false; return true; } bool SignalDef::isCCQE(FitEvent *event, int nuPDG, double EnuMin, double EnuMax){ // Check if it's CCINC if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) return false; // Require modes 1 (CCQE) if (abs(event->Mode) != 1) return false; return true; } bool SignalDef::isNCEL(FitEvent *event, int nuPDG, double EnuMin, double EnuMax){ // Check if it's NCINC if (!SignalDef::isNCINC(event, nuPDG, EnuMin, EnuMax)) return false; // Require modes 51/52 (NCEL) if (abs(event->Mode) != 51 && abs(event->Mode) != 52) return false; return true; } bool SignalDef::isCCQELike(FitEvent *event, int nuPDG, double EnuMin, double EnuMax){ // Check if it's CCINC if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) return false; // Require modes 1/2 (CCQE and MEC) if (abs(event->Mode) != 1 && abs(event->Mode) != 2) return false; return true; } // Require one meson, one charged lepton. types specified in the arguments bool SignalDef::isCC1pi(FitEvent *event, int nuPDG, int piPDG, double EnuMin, double EnuMax){ // First, make sure it's CCINC if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPion = event->NumFSParticle(piPDG); // Check that the desired pion exists and is the only meson if (nPion != 1 || nMesons != 1) return false; // Check that there is only one final state lepton if (nLeptons != 1) return false; return true; } // Require one meson, one neutrino. Types specified as arguments bool SignalDef::isNC1pi(FitEvent *event, int nuPDG, int piPDG, double EnuMin, double EnuMax){ // First, make sure it's NCINC if (!SignalDef::isNCINC(event, nuPDG, EnuMin, EnuMax)) return false; int nMesons = event->NumFSMesons(); int nLeptons = event->NumFSLeptons(); int nPion = event->NumFSParticle(piPDG); // Check that the desired pion exists and is the only meson if (nPion != 1 || nMesons != 1) return false; // Check that there are no charged leptons if (nLeptons != 0) return false; return true; } // A slightly ugly function to replace the BC 2pi channels. // All particles which are allowed in the final state are specified bool SignalDef::isCCWithFS(FitEvent *event, int nuPDG, std::vector pdgs, double EnuMin, double EnuMax){ // Check it's CCINC if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) return false; // Remove events where the number of final state particles // do not match the number specified in the signal definition if ((int)pdgs.size() != event->NumFSParticle()) return false; // For every particle in the list, check the number in the FS for (std::vector::iterator it = pdgs.begin(); it != pdgs.end(); ++it){ // Check how many times this pdg is in the vector int nEntries = std::count (pdgs.begin(), pdgs.end(), *it); if (event->NumFSParticle(*it) != nEntries) return false; } return true; } // Require one meson, one charged lepton, AND specify the only other final state particle // This is only suitable for bubble chambers. Types specified in the arguments bool SignalDef::isCC1pi3Prong(FitEvent *event, int nuPDG, int piPDG, int thirdPDG, double EnuMin, double EnuMax){ // First, make sure it's CC1pi if (!SignalDef::isCC1pi(event, nuPDG, piPDG, EnuMin, EnuMax)) return false; // Check we have the third prong if (event->NumFSParticle(thirdPDG) == 0) return false; // Check that there are only three FS particles if (event->NumFSParticle() != 3) return false; return true; } // Require one meson, one neutrino, AND specify the only other final state particle // This is only suitable for bubble chambers. Types specified in the arguments bool SignalDef::isNC1pi3Prong(FitEvent *event, int nuPDG, int piPDG, int thirdPDG, double EnuMin, double EnuMax){ // First, make sure it's NC1pi if (!SignalDef::isNC1pi(event, nuPDG, piPDG, EnuMin, EnuMax)) return false; // Check we have the third prong if (event->NumFSParticle(thirdPDG) == 0) return false; // Check that there are only three FS particles if (event->NumFSParticle() != 3) return false; return true; } bool SignalDef::isCCCOH(FitEvent *event, int nuPDG, int piPDG, double EnuMin, double EnuMax){ // Check this is a CCINC event if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) return false; int nLepton = event->NumFSParticle(nuPDG > 0 ? nuPDG-1 : nuPDG+1); int nPion = event->NumFSParticle(piPDG); int nFS = event->NumFSParticle(); if (nLepton != 1 || nPion != 1) return false; if (nFS != 2) return false; return true; } bool SignalDef::isNCCOH(FitEvent *event, int nuPDG, int piPDG, double EnuMin, double EnuMax){ // Check this is an NCINC event if (!SignalDef::isNCINC(event, nuPDG, EnuMin, EnuMax)) return false; int nLepton = event->NumFSParticle(nuPDG); int nPion = event->NumFSParticle(piPDG); int nFS = event->NumFSParticle(); if (nLepton != 1 || nPion != 1) return false; if (nFS != 2) return false; return true; } bool SignalDef::HasProtonKEAboveThreshold(FitEvent* event, double threshold){ for (uint i = 0; i < event->Npart(); i++){ FitParticle* p = event->PartInfo(i); if (!p->IsFinalState()) continue; if (p->fPID != 2212) continue; if (FitUtils::T(p->fP) > threshold / 1000.0) return true; } return false; } bool SignalDef::HasProtonMomAboveThreshold(FitEvent* event, double threshold){ for (uint i = 0; i < event->Npart(); i++){ FitParticle* p = event->PartInfo(i); if (!p->IsFinalState()) continue; if (p->fPID != 2212) continue; if (p->fP.Vect().Mag() > threshold) return true; } return false; } // Calculate the angle between the neutrino and an outgoing particle, apply a cut bool SignalDef::IsRestrictedAngle(FitEvent* event, int nuPDG, int otherPDG, double angle){ // If the particles don't exist, return false if (!event->HasISParticle(nuPDG) || !event->HasFSParticle(otherPDG)) return false; // Get Mom TVector3 pnu = event->GetHMISParticle(nuPDG)->fP.Vect(); TVector3 p2 = event->GetHMFSParticle(otherPDG)->fP.Vect(); double theta = pnu.Angle(p2) * 180. / TMath::Pi(); return (theta < angle); } bool SignalDef::IsEnuInRange(FitEvent* event, double emin, double emax){ return (event->GetNeutrinoIn()->fP.E() > emin && event->GetNeutrinoIn()->fP.E() < emax); } diff --git a/src/Utils/SignalDef.h b/src/Utils/SignalDef.h index fbf963d..f93d70a 100644 --- a/src/Utils/SignalDef.h +++ b/src/Utils/SignalDef.h @@ -1,98 +1,98 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ // contains signal definitions for various interactions #ifndef SIGNALDEF_H_SEEN #define SIGNALDEF_H_SEEN // C/C++ includes #include // ROOT includes #include -// ExtFit includes +// NUISANCE includes #include "FitEvent.h" namespace SignalDef { bool isCCINC(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isNCINC(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isCC0pi(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isCCQELike(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isCCQE(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isNC0pi(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isNCEL(FitEvent *event, int nuPDG, double EnuMin = 0, double EnuMax = 0); bool isCCCOH(FitEvent *event, int nuPDG, int piPDG, double EnuMin = 0, double EnuMax = 0); bool isNCCOH(FitEvent *event, int nuPDG, int piPDG, double EnuMin = 0, double EnuMax = 0); bool isCC1pi(FitEvent *event, int nuPDG, int piPDG, double EnuMin = 0, double EnuMax = 0); bool isNC1pi(FitEvent *event, int nuPDG, int piPDG, double EnuMin = 0, double EnuMax = 0); bool isCC1pi3Prong(FitEvent *event, int nuPDG, int piPDG, int thirdPDG, double EnuMin = 0, double EnuMax = 0); bool isNC1pi3Prong(FitEvent *event, int nuPDG, int piPDG, int thirdPDG, double EnuMin = 0, double EnuMax = 0); bool isCCWithFS(FitEvent *event, int nuPDG, std::vector pdgs, double EnuMin = 0, double EnuMax = 0); template bool isCCWithFS(FitEvent *event, int nuPDG, int const (&pdgs)[N], double EnuMin = 0, double EnuMax = 0) { // Check it's CCINC if (!SignalDef::isCCINC(event, nuPDG, EnuMin, EnuMax)) { return false; } // Remove events where the number of final state particles // do not match the number specified in the signal definition if (N != event->NumFSParticle()) { return false; } // For every particle in the list, check the number in the FS for (size_t p_it = 0; p_it < N; ++p_it) { // Check how many times this pdg is in the vector size_t nEntries = 0; for(size_t p_it2 = 0; p_it2 < N; ++p_it2) { nEntries += (pdgs[p_it] == pdgs[p_it2]); } if ((size_t)event->NumFSParticle(pdgs[p_it]) != nEntries) { return false; } } return true; } // Generic Signal Functions bool HasProtonKEAboveThreshold(FitEvent *event, double threshold); bool HasProtonMomAboveThreshold(FitEvent* event, double threshold); bool IsRestrictedAngle(FitEvent *event, int nuPDG, int otherPDG, double angle); bool IsEnuInRange(FitEvent *event, double emin, double emax); } #endif diff --git a/src/Utils/TargetUtils.h b/src/Utils/TargetUtils.h index 13cd20e..4878802 100644 --- a/src/Utils/TargetUtils.h +++ b/src/Utils/TargetUtils.h @@ -1,55 +1,55 @@ -// Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +// Copyright 2016-2021 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 . *******************************************************************************/ #ifndef TARGET_UTILS_H #define TARGET_UTILS_H #include "FitLogger.h" #include "GeneralUtils.h" /// Namespace for utils parsing target pdgs namespace TargetUtils { /// Convert comma separated string of targets to vector of PDG codes /// /// e.g. "C,H,10000100010" = "100000600120,10000100010,100000100010" std::vector ParseTargetsToIntVect(std::string targets); /// Convert a target string to pdg code int GetTargetPDGFromString(std::string target); /// Get Nuclear PDG code from Z and A int GetTargetPDGFromZA(int Z, int A); /// Get TargetZ code from the full PDG int GetTargetZFromPDG(int PDG); /// Get TargetA code from the full PDG int GetTargetAFromPDG(int PDG); /// Convert target ids to target that can be used by gen_nuisance std::string ConvertTargetIDs (std::string); /// Lists all possible target IDS, should be kept in sync with convert function void ListTargetIDs(void); } #endif diff --git a/validation/nightly-test/base-comparisons-1/generator-setup.sh b/validation/nightly-test/base-comparisons-1/generator-setup.sh index 27b1cd0..521ef8d 100644 --- a/validation/nightly-test/base-comparisons-1/generator-setup.sh +++ b/validation/nightly-test/base-comparisons-1/generator-setup.sh @@ -1,127 +1,127 @@ -# Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret +# Copyright 2016-2021 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 . ################################################################################ #!/bin/sh if ! [[ ":$PATH:" == *":/home/stowell/t2krep/NIWG/nuisance/branches/master_refactor/master/builds/default/Linux/bin:"* ]]; then export PATH=/home/stowell/t2krep/NIWG/nuisance/branches/master_refactor/master/builds/default/Linux/bin:$PATH fi if ! [[ ":$LD_LIBRARY_PATH:" == *":/home/stowell/t2krep/NIWG/nuisance/branches/master_refactor/master/builds/default/Linux/lib:"* ]]; then export LD_LIBRARY_PATH=/home/stowell/t2krep/NIWG/nuisance/branches/master_refactor/master/builds/default/Linux/lib:$LD_LIBRARY_PATH fi if [[ ! "${ROOTSYS}" ]]; then echo "[INFO]: Sourcing ROOT from: /usr/local/t2k-software/ROOT-NUISANCE/root" source "/usr/local/t2k-software/ROOT-NUISANCE/root/bin/thisroot.sh" fi if [[ "1" != "0" ]]; then echo "[INFO]: Adding NEUT library paths to the environment." export NEUT_ROOT=/data/stowell/NIWG/neut/branches/neut_5.3.6_freenucleonCCQE export CERN=/usr/local/t2k-software/cern/ export CERN_LEVEL=2005 if ! [[ ":$LD_LIBRARY_PATH:" == *":${NEUT_ROOT}/lib/Linux_pc:"* ]]; then export LD_LIBRARY_PATH=${NEUT_ROOT}/lib/Linux_pc:$LD_LIBRARY_PATH fi if ! [[ ":$LD_LIBRARY_PATH:" == *":${NEUT_ROOT}/src/reweight:"* ]]; then export LD_LIBRARY_PATH=${NEUT_ROOT}/src/reweight:$LD_LIBRARY_PATH fi fi if [[ "1" != "0" ]]; then echo "[INFO]: Adding NuWro library paths to the environment." export NUWRO="/usr/local/t2k-software/NuWro-v12" if ! [[ ":$LD_LIBRARY_PATH:" == *":/usr/local/t2k-software/NuWro-v12/build/Linux/lib:"* ]]; then export LD_LIBRARY_PATH=/usr/local/t2k-software/NuWro-v12/build/Linux/lib:$LD_LIBRARY_PATH fi fi if [[ "TRUE" != "0" ]]; then echo "[INFO]: Adding PYTHIA6 library paths to the environment." export PYTHIA6="/usr/local/t2k-software/pythia6" if ! [[ ":$LD_LIBRARY_PATH:" == *":/usr/local/t2k-software/pythia6:"* ]]; then export LD_LIBRARY_PATH=/usr/local/t2k-software/pythia6:$LD_LIBRARY_PATH fi fi if [[ "1" != "0" ]]; then echo "[INFO]: Adding GENIE paths to the environment." export GENIE="/data/stowell/NIWG/genie/branches/R-2_12_6" export LHAPDF_LIB="/usr/local/t2k-software/lhapdf/lib/" export LHAPDF_INC="/usr/local/t2k-software/lhapdf/include/" export LIBXML2_LIB="/usr/lib/" export LIBXML2_INC="/usr/include/libxml2/libxml/" export LOG4CPP_LIB="/usr/local/t2k-software/log4cpp/src/.libs" export LOG4CPP_INC="/usr/local/t2k-software/log4cpp/include" export LHAPATH="/usr/local/t2k-software/lhapdf/share/lhapdf/PDFsets" if ! [[ ":$LD_LIBRARY_PATH:" == *":/data/stowell/NIWG/genie/branches/R-2_12_6/lib:"* ]]; then export LD_LIBRARY_PATH=/data/stowell/NIWG/genie/branches/R-2_12_6/lib:$LD_LIBRARY_PATH fi if ! [[ ":$LD_LIBRARY_PATH:" == *":/usr/local/t2k-software/lhapdf/lib/:"* ]]; then export LD_LIBRARY_PATH=/usr/local/t2k-software/lhapdf/lib/:$LD_LIBRARY_PATH fi if ! [[ ":$LD_LIBRARY_PATH:" == *":/usr/lib/:"* ]]; then export LD_LIBRARY_PATH=/usr/lib/:$LD_LIBRARY_PATH fi if ! [[ ":$LD_LIBRARY_PATH:" == *":/usr/local/t2k-software/log4cpp/src/.libs:"* ]]; then export LD_LIBRARY_PATH=/usr/local/t2k-software/log4cpp/src/.libs:$LD_LIBRARY_PATH fi fi if [[ "0" != "0" ]]; then echo "[INFO]: Adding NIWG paths to the environment." export NIWG= export NIWGREWEIGHT_INPUTS=/inputs if ! [[ ":$LD_LIBRARY_PATH:" == *"::"* ]]; then export LD_LIBRARY_PATH=${NIWG}:${LD_LIBRARY_PATH} fi fi if [[ "0" != "0" ]]; then echo "[INFO]: Adding T2K paths to the environment." export T2KREWEIGHT= if ! [[ ":$LD_LIBRARY_PATH:" == *":/lib:"* ]]; then export LD_LIBRARY_PATH=${T2KREWEIGHT}/lib:${LD_LIBRARY_PATH} fi fi if [[ "0" != "0" ]]; then echo "[INFO]: Sourcing GiBUU tools." source /home/stowell/t2krep/NIWG/nuisance/branches/master_refactor/master/builds/default/GiBUUTools/src/GiBUUTools-build/Linux/setup.sh fi source $GENIE/genie_prereq.sh source $GENIE/genie_setup.sh