diff --git a/data/BEBC/CCQE/BEBC_CCQE_1DEnu.csv b/data/BEBC/CCQE/BEBC_CCQE_1DEnu.csv new file mode 100644 index 0000000..3e66f58 --- /dev/null +++ b/data/BEBC/CCQE/BEBC_CCQE_1DEnu.csv @@ -0,0 +1,8 @@ +5 0.804517555835132 0.11304073754437 +10 0.652288847547416 0.0798903972966299 +15 0.668646726185511 0.0788956851617579 +20 0.805653617178933 0.0798903972966309 +30 0.654661933955679 0.080882475595314 +50 0.577389569833093 0.101398303633905 +150 0 0 + diff --git a/src/BEBC/BEBC_CCQE_XSec_1DEnu_nu.cxx b/src/BEBC/BEBC_CCQE_XSec_1DEnu_nu.cxx new file mode 100644 index 0000000..61c5a2f --- /dev/null +++ b/src/BEBC/BEBC_CCQE_XSec_1DEnu_nu.cxx @@ -0,0 +1,133 @@ +// Copyright 2016-2021 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret + +/******************************************************************************* +* This file is part of NUISANCE. +* +* NUISANCE is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* NUISANCE is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU 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_1DEnu_nu.h" + + +//******************************************************************** +BEBC_CCQE_XSec_1DEnu_nu::BEBC_CCQE_XSec_1DEnu_nu(nuiskey samplekey) { +//******************************************************************** + + // Sample overview --------------------------------------------------- + std::string descrip = "BEBC_CCQE_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("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_1DEnu_nu"); + fSettings.DefineAllowedSpecies("numu"); + fSettings.SetDataInput( FitPar::GetDataBase() + "BEBC/CCQE/BEBC_CCQE_1DEnu.csv"); + + // 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_1DEnu_Correction"); + } + + FinaliseSampleSettings(); + + // Scaling Setup --------------------------------------------------- + // ScaleFactor automatically setup for DiffXSec/cm2/Nucleon + fScaleFactor = GetEventHistogram()->Integral("width")*double(1E-38)/(double(fNEvents)); + + // Plot Setup ------------------------------------------------------- + SetDataFromTextFile( fSettings.GetDataInput() ); + // Data is in units of 1E-38 + fDataHist->Scale(1E-38); + 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_1DEnu_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; + + fXVar = Pnu.E()/1E3; + + GetQ2Box()->fQ2 = -(Pnu-Pmu).Mag2(); + return; +}; + +//******************************************************************** +bool BEBC_CCQE_XSec_1DEnu_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_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(); + +} + diff --git a/src/BEBC/BEBC_CCQE_XSec_1DEnu_nu.h b/src/BEBC/BEBC_CCQE_XSec_1DEnu_nu.h new file mode 100644 index 0000000..e4e5d36 --- /dev/null +++ b/src/BEBC/BEBC_CCQE_XSec_1DEnu_nu.h @@ -0,0 +1,57 @@ +// Copyright 2016-2021 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret + +/******************************************************************************* +* This file is part of NUISANCE. +* +* NUISANCE is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published by +* the Free Software Foundation, either version 3 of the License, or +* (at your option) any later version. +* +* NUISANCE is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU 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_1DENU_NU_H_SEEN +#define BEBC_CCQE_XSEC_1DENU_NU_H_SEEN + +#include "Measurement1D.h" +#include "CustomVariableBoxes.h" + +//******************************************************************** +class BEBC_CCQE_XSec_1DEnu_nu : public Measurement1D { +//******************************************************************** +public: + + BEBC_CCQE_XSec_1DEnu_nu(nuiskey samplekey); + virtual ~BEBC_CCQE_XSec_1DEnu_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 f2b2715..35e5014 100644 --- a/src/BEBC/CMakeLists.txt +++ b/src/BEBC/CMakeLists.txt @@ -1,67 +1,69 @@ # Copyright 2016-2021 L. Pickering, P Stowell, R. Terri, C. Wilkinson, C. Wret ################################################################################ # This file is part of NUISANCE. # # NUISANCE is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # NUISANCE is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU 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 +BEBC_CCQE_XSec_1DEnu_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 +BEBC_CCQE_XSec_1DEnu_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)