30 | | == Running a GENIE Minimization == |
31 | | |
32 | | === Preparing Event Samples === |
33 | | |
34 | | === Choosing our samples === |
| 30 | = Running a GENIE Minimization = |
| 31 | |
| 32 | In this example we will take pregenerated GENIE events as our starting model and run a tuning to find a best fit value for some of the CCQE Reweight dials in GENIE ReWeight. |
| 33 | |
| 34 | == Generating GENIE Events == |
| 35 | If we want to see how a given GENIE model behaves, first we need to generate events. This can be done using the standard gevgen application, using the appropriate target and flux for a given data sample. |
| 36 | |
| 37 | If all you want to do is check your NUSIANCE is built correctly, you can skip this step by downloading MC files from our online storage area by following the steps found here:LinkToNUISANCEMCFiles |
| 38 | |
| 39 | === Running gevgen === |
| 40 | |
| 41 | The standard gevgen application options can be ran using |
| 42 | {{{ |
| 43 | $ gevgen -h |
| 44 | Syntax: |
| 45 | |
| 46 | gevgen [-h] |
| 47 | [-r run#] |
| 48 | -n nev |
| 49 | -e energy (or energy range) |
| 50 | -p neutrino_pdg |
| 51 | -t target_pdg |
| 52 | [-f flux_description] |
| 53 | [-o outfile_name] |
| 54 | [-w] |
| 55 | [--seed random_number_seed] |
| 56 | [--cross-sections xml_file] |
| 57 | [--event-generator-list list_name] |
| 58 | [--message-thresholds xml_file] |
| 59 | [--unphysical-event-mask mask] |
| 60 | [--event-record-print-level level] |
| 61 | [--mc-job-status-refresh-rate rate] |
| 62 | [--cache-file root_file] |
| 63 | }}} |
| 64 | |
| 65 | We need to provide a flux and target list to GENIE when running gevgen. |
| 66 | |
| 67 | We want to run comparisons to MiniBooNE muon-neutrino scattering data on a mineral oil target, therefore to generate events we pass it the default GENIE splines, the MiniBooNE flux in root format, and the required target and beam peg settings |
| 68 | {{{ |
| 69 | $ source $GENIE_DIR/environment_setup.sh |
| 70 | $ export GXMLPATH=${GENIE_DIR}/genie_xsec/v2_12_0/NULL/DefaultPlusMECWithNC/data/ |
| 71 | $ gevgen -n 2500000 \ |
| 72 | -t 1000060120[0.85714],1000010010[0.14286] \ |
| 73 | -p 14 --cross-sections $GXMLPATH/gxspl-FNALsmall.xml \ |
| 74 | --event-generator-list Default -f MiniBooNE_numu_flux.root,numu_mb \ |
| 75 | -e 0,10 -o gntp.2063030.ghep.root |
| 76 | }}} |
| 77 | For more information on how to generate events in GENIE please see: https://arxiv.org/abs/1510.05494 |
| 78 | |
| 79 | Once our events have been generated we can check that they have finished correctly by opening the output event file and checking it has a ‘gtree’ object and the checking flux spectrum file contains the correct histogram. |
| 80 | |
| 81 | |
| 82 | {{{ |
| 83 | $ root gntp.2063030.ghep.root |
| 84 | root [0] |
| 85 | Attaching file gntp.2063030.ghep.root as _file0... |
| 86 | Warning in <TClass::TClass>: no dictionary for class genie::NtpMCEventRecord is available |
| 87 | Warning in <TClass::TClass>: no dictionary for class genie::NtpMCRecordI is available |
| 88 | Warning in <TClass::TClass>: no dictionary for class genie::NtpMCRecHeader is available |
| 89 | Warning in <TClass::TClass>: no dictionary for class genie::EventRecord is available |
| 90 | Warning in <TClass::TClass>: no dictionary for class genie::GHepRecord is available |
| 91 | Warning in <TClass::TClass>: no dictionary for class genie::Interaction is available |
| 92 | Warning in <TClass::TClass>: no dictionary for class genie::InitialState is available |
| 93 | Warning in <TClass::TClass>: no dictionary for class genie::Target is available |
| 94 | Warning in <TClass::TClass>: no dictionary for class genie::ProcessInfo is available |
| 95 | Warning in <TClass::TClass>: no dictionary for class genie::Kinematics is available |
| 96 | Warning in <TClass::TClass>: no dictionary for class genie::XclsTag is available |
| 97 | Warning in <TClass::TClass>: no dictionary for class genie::KPhaseSpace is available |
| 98 | Warning in <TClass::TClass>: no dictionary for class genie::GHepParticle is available |
| 99 | Warning in <TClass::TClass>: no dictionary for class pair<genie::EKineVar,double> is available |
| 100 | root [1] _file0->ls(); |
| 101 | TFile** gntp.2063030.ghep.root |
| 102 | TFile* gntp.2063030.ghep.root |
| 103 | KEY: genie::NtpMCTreeHeader header;1 GENIE output tree header |
| 104 | KEY: TFolder gconfig;1 GENIE configs |
| 105 | KEY: TFolder genv;1 GENIE user environment |
| 106 | KEY: TTree gtree;1 GENIE MC Truth TTree, Format: [NtpMCEventRecord] |
| 107 | }}} |
| 108 | |
| 109 | {{{ |
| 110 | $ root input-flux.root |
| 111 | root [0] |
| 112 | Attaching file input-flux.root as _file0... |
| 113 | root [1] _file0->ls(); |
| 114 | TFile** input-flux.root |
| 115 | TFile* input-flux.root |
| 116 | KEY: TH1D spectrum;1 neutrino_flux |
| 117 | }}} |
| 118 | |
| 119 | Now that the event samples have been generated correctly, we need to prepare them for use in NUISANCE. |
| 120 | |
| 121 | === Running PrepareGENIE === |
| 122 | |
| 123 | The standard gevgen application doesn’t save the total event rate predictions into the event file itself. NUISANCE needs these to correctly normalise predictions so before we can use these new events we need to prepare them. |
| 124 | |
| 125 | The PrepareGENIE application is built when NUISANCE is built with GENIE support should be available after the NUISANCE environmental setup script is ran. |
| 126 | |
| 127 | {{{ |
| 128 | $ PrepareGENIE -h |
| 129 | PrepareGENIEEvents NUISANCE app. |
| 130 | Takes GHep Outputs and prepares events for NUISANCE. |
| 131 | |
| 132 | PrepareGENIEEvents [-h,-help,--h,--help] |
| 133 | [-i inputfile1.root,inputfile2.root,inputfile3.root,...] |
| 134 | [-f flux_root_file.root,flux_hist_name] |
| 135 | [-t target1[frac1],target2[frac2],...] |
| 136 | |
| 137 | Prepare Mode [Default] : Takes a single GHep file, reconstructs the original GENIE splines, and creates a duplicate file that |
| 138 | also contains the flux, event rate, and xsec predictions that NUISANCE needs. |
| 139 | Following options are required for Prepare Mode: |
| 140 | [ -i inputfile.root ] : Reads in a single GHep input file that needs the xsec calculation ran on it. |
| 141 | [ -f flux_file.root,hist_name ] : Path to root file containing the flux histogram the GHep records were generated with. A |
| 142 | simple method is to point this to the flux histogram genie generatrs '-f /path/to/events/input-flux.root,spectrum'. |
| 143 | [ -t target ] : Target that GHepRecords were generated with. Comma seperated list. E.g. for CH2 |
| 144 | target=1000060120,1000010010,1000010010 |
| 145 | }}} |
| 146 | |
| 147 | The PrepareGENIE application, when ran, loops over all the events, extracts the cross-section as a function of energy for each discrete interaction mode and uses this information to reconstruct the cross-section splines for each target that were used to generate events. |
| 148 | |
| 149 | These splines are then multiplied by specified flux and added according to the target definition provided to produce total flux and event rate predictions as a function of energy for the sample and saves them into the events file. |
| 150 | |
| 151 | We want to prepare our MiniBooNE events so we pass in the event files, the input flux, and the CH2 target definition. |
| 152 | |
| 153 | {{{ |
| 154 | $ PrepareGENIE -i gntp.2063030.ghep.root -f input-flux.root,spectrum -t 1000060120,1000010010,1000010010 |
| 155 | }}} |
| 156 | |
| 157 | Now when we open our event file again, we should see the flux and event rate histograms are now saved into the file ready for NUISANCE to read them. |
| 158 | |
| 159 | {{{ |
| 160 | KEY: genie::NtpMCTreeHeader header;1 GENIE output tree header |
| 161 | KEY: TFolder gconfig;1 GENIE configs |
| 162 | KEY: TFolder genv;1 GENIE user environment |
| 163 | KEY: TTree gtree;1 GENIE MC Truth TTree, Format: [NtpMCEventRecord] |
| 164 | KEY: TDirectoryFile IndividualGENIESplines;1 IndividualGENIESplines |
| 165 | KEY: TDirectoryFile TargetGENIESplines;1 TargetGENIESplines |
| 166 | KEY: TH1F nuisance_xsec;1 |
| 167 | KEY: TH1F nuisance_events;1 |
| 168 | KEY: TH1F nuisance_flux;1 |
| 169 | }}} |
| 170 | |
| 171 | |
| 172 | == Choosing our samples == |
| 173 | |
| 174 | Now that we have an event sample we can load them load them into NUISANCE so that it can use them to form a joint likelihood by specifying them at run time. |
| 175 | |
| 176 | === Writing a card file === |
| 177 | |
| 178 | To specify samples we need to write a NUISANCE card file that lists all comparisons that should be made and the event files that should be used for each one. |
| 179 | |
| 180 | We want to produce comparisons to MiniBooNE CCQE data, so first we should search the NUISANCE sample list. |
| 181 | |
| 182 | The ‘nuissamples’ script is provided for easy access of the sample list. Running it without any arguments will return a full sample list of available data comparisons. Providing an additional argument will return only samples containing the provided substring. |
| 183 | |
| 184 | We can list the MIniBooNE samples using |
| 185 | {{{ |
| 186 | [stowell@hepgw1 ~]$ nuissamples MiniBooNE |
| 187 | MiniBooNE_CCQE_XSec_1DQ2_nu |
| 188 | MiniBooNE_CCQELike_XSec_1DQ2_nu |
| 189 | MiniBooNE_CCQE_XSec_1DQ2_antinu |
| 190 | MiniBooNE_CCQELike_XSec_1DQ2_antinu |
| 191 | MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu |
| 192 | MiniBooNE_CCQE_XSec_2DTcos_nu |
| 193 | MiniBooNE_CCQELike_XSec_2DTcos_nu |
| 194 | MiniBooNE_CCQE_XSec_2DTcos_antinu |
| 195 | MiniBooNE_CCQELike_XSec_2DTcos_antinu |
| 196 | MiniBooNE_CC1pip_XSec_1DEnu_nu |
| 197 | MiniBooNE_CC1pip_XSec_1DQ2_nu |
| 198 | MiniBooNE_CC1pip_XSec_1DTpi_nu |
| 199 | MiniBooNE_CC1pip_XSec_1DTu_nu |
| 200 | MiniBooNE_CC1pip_XSec_2DQ2Enu_nu |
| 201 | MiniBooNE_CC1pip_XSec_2DTpiCospi_nu |
| 202 | MiniBooNE_CC1pip_XSec_2DTpiEnu_nu |
| 203 | MiniBooNE_CC1pip_XSec_2DTuCosmu_nu |
| 204 | MiniBooNE_CC1pip_XSec_2DTuEnu_nu |
| 205 | MiniBooNE_CC1pi0_XSec_1DEnu_nu |
| 206 | MiniBooNE_CC1pi0_XSec_1DQ2_nu |
| 207 | MiniBooNE_CC1pi0_XSec_1DTu_nu |
| 208 | MiniBooNE_CC1pi0_XSec_1Dcosmu_nu |
| 209 | MiniBooNE_CC1pi0_XSec_1Dcospi0_nu |
| 210 | MiniBooNE_CC1pi0_XSec_1Dppi0_nu |
| 211 | MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu |
| 212 | MiniBooNE_NC1pi0_XSec_1Dcospi0_rhc |
| 213 | MiniBooNE_NC1pi0_XSec_1Dcospi0_nu |
| 214 | MiniBooNE_NC1pi0_XSec_1Dcospi0_fhc |
| 215 | MiniBooNE_NC1pi0_XSec_1Dppi0_antinu |
| 216 | MiniBooNE_NC1pi0_XSec_1Dppi0_rhc |
| 217 | MiniBooNE_NC1pi0_XSec_1Dppi0_nu |
| 218 | MiniBooNE_NC1pi0_XSec_1Dppi0_fhc |
| 219 | MiniBooNE_NCEL_XSec_Treco_nu |
| 220 | }}} |
| 221 | |
| 222 | We only care about CC1pip data therefore the following samples are of interest |
| 223 | {{{ |
| 224 | [stowell@hepgw1 ~]$ nuissamples MiniBooNE_CCQE_ |
| 225 | MiniBooNE_CCQE_XSec_1DQ2_nu |
| 226 | MiniBooNE_CCQE_XSec_1DQ2_antinu |
| 227 | MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu |
| 228 | MiniBooNE_CCQE_XSec_2DTcos_nu |
| 229 | MiniBooNE_CCQE_XSec_2DTcos_antinu |
| 230 | |
| 231 | }}} |
| 232 | |
| 233 | In this example we will compare to the CCQE 1DQ2 distributions, but we could provide a large number of the samples seen in the lists if we wanted. When we specify multiple samples nuismin will automatically calculate the likelihood for each one and **add them uncorrelated** to form a joint likelihood. |
| 234 | |
| 235 | We write our card file with these two datasets using the following sample object format: |
| 236 | {{{ |
| 237 | sample NAME_OF_SAMPLE INPUT_TYPE:FILE_INPUT |
| 238 | }}} |
| 239 | |
| 240 | So if our GENIE file is called 'MiniBooNE_FHC_numu_2.5M.root', our card file will be : |
| 241 | |
| 242 | **genie_tutorial.card** |
| 243 | {{{ |
| 244 | sample MiniBooNE_CCQE_XSec_1DQ2_nu GENIE:MiniBooNE_FHC_numu_2.5M.root |
| 245 | sample MiniBooNE_CCQE_XSec_1DQ2_antinu GENIE:MiniBooNE_FHC_numu_2.5M.root |
| 246 | }}} |
| 247 | |
| 248 | If you want to check this is valid you could run this card file with 'nuiscomp' as shown in the tutorial here [wiki:HowToUseNUISCOMP-GENIE] and check the nominal prediction looks okay. |