diff --git a/cmake/NIWGSetup.cmake b/cmake/NIWGSetup.cmake index 559a225..880e51e 100644 --- a/cmake/NIWGSetup.cmake +++ b/cmake/NIWGSetup.cmake @@ -1,37 +1,47 @@ # Copyright 2016 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret ################################################################################ # This file is part of NUISANCE. # # NUISANCE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # NUISANCE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with NUISANCE. If not, see . ################################################################################ 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}) + 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() + LIST(APPEND RWENGINE_INCLUDE_DIRECTORIES ${NIWG_ROOT}) LIST(APPEND EXTRA_LINK_DIRS ${NIWG_ROOT}) LIST(APPEND EXTRA_LIBS NIWGReWeight) diff --git a/src/Reweight/NIWGWeightEngine.cxx b/src/Reweight/NIWGWeightEngine.cxx index 09f2d3a..f08e882 100644 --- a/src/Reweight/NIWGWeightEngine.cxx +++ b/src/Reweight/NIWGWeightEngine.cxx @@ -1,222 +1,231 @@ #include "NIWGWeightEngine.h" NIWGWeightEngine::NIWGWeightEngine(std::string name) { #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ // Setup the NEUT Reweight engien fCalcName = name; NUIS_LOG(FIT, "Setting up NIWG RW : " << fCalcName); // Create RW Engine suppressing cout StopTalking(); fNIWGRW = new niwg::rew::NIWGReWeight(); // Get List of Veto Calcs (For Debugging) std::string rw_engine_list = FitPar::Config().GetParS("FitWeight_fNIWGRW_veto"); + bool niwg_2012a = rw_engine_list.find("niwg_2012a") == std::string::npos; bool niwg_2014a = rw_engine_list.find("niwg_2014a") == std::string::npos; bool niwg_pimult = rw_engine_list.find("niwg_pimult") == std::string::npos; bool niwg_mec = rw_engine_list.find("niwg_mec") == std::string::npos; bool niwg_rpa = rw_engine_list.find("niwg_rpa") == std::string::npos; bool niwg_eff_rpa = rw_engine_list.find("niwg_eff_rpa") == std::string::npos; bool niwg_proton = rw_engine_list.find("niwg_protonFSIbug") == std::string::npos; bool niwg_hadron = rw_engine_list.find("niwg_HadronMultSwitch") == std::string::npos; bool niwg_qelowq2 = rw_engine_list.find("niwg_LowQEQ2") == std::string::npos; + bool niwg_2p2henu = rw_engine_list.find("niwg_2p2hEnu") == std::string::npos; // Add the RW Calcs if (niwg_2012a) fNIWGRW->AdoptWghtCalc("niwg_2012a", new niwg::rew::NIWGReWeight2012a); if (niwg_2014a) fNIWGRW->AdoptWghtCalc("niwg_2014a", new niwg::rew::NIWGReWeight2014a); if (niwg_pimult) fNIWGRW->AdoptWghtCalc("niwg_pimult", new niwg::rew::NIWGReWeightPiMult); if (niwg_mec) fNIWGRW->AdoptWghtCalc("niwg_mec", new niwg::rew::NIWGReWeightMEC); if (niwg_rpa) fNIWGRW->AdoptWghtCalc("niwg_rpa", new niwg::rew::NIWGReWeightRPA); if (niwg_eff_rpa) fNIWGRW->AdoptWghtCalc("niwg_eff_rpa", new niwg::rew::NIWGReWeightEffectiveRPA); if (niwg_proton) fNIWGRW->AdoptWghtCalc("niwg_protonFSIbug", new niwg::rew::NIWGReWeightProtonFSIbug); if (niwg_hadron) fNIWGRW->AdoptWghtCalc("niwg_HadronMultSwitch", new niwg::rew::NIWGReWeightHadronMultSwitch); // Add in Luke's low Q2 suppression #ifdef HAVE_NIWGRW_LOWQ2 if (niwg_qelowq2) fNIWGRW->AdoptWghtCalc( "niwg_QELowQ2", new niwg::rew::NIWGReWeightEffectiveQELowQ2Suppression); #endif +// Add in Kevin and Laura's 2p2h Enu dependent dial +#ifdef HAVE_NIWGRW_2P2HENU + if (niwg_2p2henu) + fNIWGRW->AdoptWghtCalc( + "niwg_2p2enu", new niwg::rew::NIWGReWeight2p2hEdep); +#endif + fNIWGRW->Reconfigure(); // Set Abs Twk Config fIsAbsTwk = (FitPar::Config().GetParB("setabstwk")); // allow cout again StartTalking(); #else NUIS_ABORT("NIWG RW Enabled but NEUT RW is not!"); #endif #else NUIS_ABORT("NIWG RW NOT ENABLED!"); #endif }; void NIWGWeightEngine::IncludeDial(std::string name, double startval) { #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ // Get First enum int nuisenum = Reweight::ConvDial(name, kNIWG); // 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 niwg::rew::NIWGSyst_t gensyst = niwg::rew::NIWGSyst::FromString(name); // Fill Maps int index = fValues.size(); fValues.push_back(0.0); fNIWGSysts.push_back(gensyst); // Initialize dial NUIS_LOG(FIT, "Registering " << singlename << " from " << name); fNIWGRW->Systematics().Init(fNIWGSysts[index]); // If Absolute if (fIsAbsTwk) { niwg::rew::NIWGSystUncertainty::Instance()->SetUncertainty( fNIWGSysts[index], 1.0, 1.0); } // Setup index fEnumIndex[nuisenum].push_back(index); fNameIndex[name].push_back(index); } // Set Value if given if (startval != -999.9) { SetDialValue(nuisenum, startval); } #endif #endif } void NIWGWeightEngine::SetDialValue(int nuisenum, double val) { #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ std::vector indices = fEnumIndex[nuisenum]; for (uint i = 0; i < indices.size(); i++) { fValues[indices[i]] = val; std::cout << "Setting NIWG Dial Value " << i << " " << indices[i] << " " << fNIWGSysts[indices[i]] << std::endl; fNIWGRW->Systematics().Set(fNIWGSysts[indices[i]], val); } #endif #endif } void NIWGWeightEngine::SetDialValue(std::string name, double val) { #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ std::vector indices = fNameIndex[name]; for (uint i = 0; i < indices.size(); i++) { fValues[indices[i]] = val; fNIWGRW->Systematics().Set(fNIWGSysts[indices[i]], val); } #endif #endif } void NIWGWeightEngine::Reconfigure(bool silent) { #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ // Hush now... if (silent) StopTalking(); // Reconf fNIWGRW->Reconfigure(); // Shout again if (silent) StartTalking(); #endif #endif } double NIWGWeightEngine::CalcWeight(BaseFitEvt *evt) { double rw_weight = 1.0; #ifdef __NEUT_ENABLED__ #ifdef __NIWG_ENABLED__ // Skip Non GENIE if (evt->fType != kNEUT) return 1.0; // Hush now StopTalking(); niwg::rew::NIWGEvent *niwg_event = NIWGWeightEngine::GetNIWGEventLocal(evt->fNeutVect); rw_weight *= fNIWGRW->CalcWeight(*niwg_event); delete niwg_event; // Speak Now StartTalking(); #endif #endif // Return rw_weight return rw_weight; } #ifdef __NEUT_ENABLED__ #ifdef __NIWG_ENABLED__ niwg::rew::NIWGEvent *NIWGWeightEngine::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; ip < nvect->Npart(); ++ip) { niwg::rew::NIWGPartStack fDummyPartStack; fDummyPartStack.p = (nvect->PartInfo(ip)->fP) * 0.001; // Convert to GeV fDummyPartStack.pdg = nvect->PartInfo(ip)->fPID; fDummyPartStack.chase = nvect->PartInfo(ip)->fIsAlive; fDummyPartStack.parent = nvect->ParentIdx(ip) - 1; // WARNING: this needs to be tested with a NeutRoot file fDummyNIWGEvent->part_stack.push_back(fDummyPartStack); } fDummyNIWGEvent->CalcKinematics(); return fDummyNIWGEvent; } #endif #endif diff --git a/src/Reweight/NIWGWeightEngine.h b/src/Reweight/NIWGWeightEngine.h index ae4ce81..809eed6 100644 --- a/src/Reweight/NIWGWeightEngine.h +++ b/src/Reweight/NIWGWeightEngine.h @@ -1,79 +1,82 @@ #ifndef WEIGHT_ENGINE_NIWG_H #define WEIGHT_ENGINE_NIWG_H #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ #include "NIWGReWeight.h" #include "NIWGReWeight1piAngle.h" #include "NIWGReWeight2010a.h" #include "NIWGReWeight2012a.h" #include "NIWGReWeight2014a.h" #include "NIWGReWeightDeltaMass.h" #include "NIWGReWeightEffectiveRPA.h" #ifdef HAVE_NIWGRW_LOWQ2 #include "NIWGReWeightEffectiveQELowQ2Suppression.h" #endif +#ifdef HAVE_NIWGRW_2P2HENU +#include "NIWGReWeight2p2hEdep.h" +#endif #include "NIWGReWeightHadronMultSwitch.h" #include "NIWGReWeightMEC.h" #include "NIWGReWeightPiMult.h" #include "NIWGReWeightProtonFSIbug.h" #include "NIWGReWeightRPA.h" #include "NIWGReWeightSpectralFunc.h" #include "NIWGReWeightSplineEnu.h" #include "NIWGSyst.h" #include "NIWGSystUncertainty.h" #include "NReWeight.h" #include "NReWeightCasc.h" #include "NReWeightNuXSecCCQE.h" #include "NReWeightNuXSecCCRES.h" #include "NReWeightNuXSecCOH.h" #include "NReWeightNuXSecDIS.h" #include "NReWeightNuXSecNC.h" #include "NReWeightNuXSecNCEL.h" #include "NReWeightNuXSecNCRES.h" #include "NReWeightNuXSecRES.h" #include "NReWeightNuclPiless.h" #include "NSyst.h" #include "NSystUncertainty.h" #include "neutpart.h" #include "neutvect.h" #include "NEUTInputHandler.h" #endif #endif #include "FitLogger.h" #include "GeneratorUtils.h" #include "WeightEngineBase.h" #include "FitWeight.h" class NIWGWeightEngine : public WeightEngineBase { public: NIWGWeightEngine(std::string name); ~NIWGWeightEngine() {}; void IncludeDial(std::string name, double startval); void SetDialValue(std::string name, double val); void SetDialValue(int nuisenum, double val); void Reconfigure(bool silent = false); double CalcWeight(BaseFitEvt* evt); inline bool NeedsEventReWeight() { return true; }; #ifdef __NIWG_ENABLED__ #ifdef __NEUT_ENABLED__ std::vector fNIWGSysts; niwg::rew::NIWGEvent* GetNIWGEventLocal(NeutVect* nvect); niwg::rew::NIWGReWeight* fNIWGRW; #endif #endif }; #endif