| 1 | = NUISCOMP = |
| 2 | |
| 3 | The NUISANCE comparison application can be used to generate MC predictions that can be directly compared with published scatter data by automatically selecting the correct event topologies from a provided event sample and binning them to match the data. |
| 4 | |
| 5 | [[PageOutline(1-3,Wiki content,inline,numbered)]] |
| 6 | |
| 7 | == Running NUISCOMP == |
| 8 | |
| 9 | {{{ |
| 10 | #!div class="important" |
| 11 | '''Author:''' Patrick Stowell |
| 12 | |
| 13 | '''Date:''' June 2017 |
| 14 | |
| 15 | '''Versions:''' `NUISANCE v2r0`, `GENIE 2.12.6` |
| 16 | }}} |
| 17 | |
| 18 | The following example details how to run NUISANCE and produce MiniBooNE pion production comparisons to a generator of choice. Each generator requires very slightly different ways to handle NUISANCE, therefore multiple versions of this tutorial have been provided. Please use the following links to choose what generator you would like to use. |
| 19 | |
| 20 | - [wiki:HowToUseNUISCOMP-GENIE I want to use GENIE] |
| 21 | - [wiki:HowToUseNUISCOMP-NuWro I want to use NuWro] |
| 22 | - [wiki:HowToUseNUISCOMP-NEUT I want to use NEUT] |
| 23 | |
| 24 | |
| 25 | == Generating GENIE Events == |
| 26 | 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. |
| 27 | |
| 28 | 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 |
| 29 | |
| 30 | == Running gevgen == |
| 31 | |
| 32 | The standard gevgen application options can be ran using |
| 33 | {{{ |
| 34 | $ gevgen -f -n -e |
| 35 | }}} |
| 36 | |
| 37 | We need to provide a flux and target list to GENIE when running gevgen. To see our list of compiled flux and target combinations for each sample please see here: |
| 38 | |
| 39 | Note: If building NUISANCE v2r0 or higher against GENIE 2-12-0 or higher an option is provided to use an easier and quicker gevgen_nuisance application to generate NUISANCE-ready event files. Please see section 2.3 if you would like to use this. |
| 40 | |
| 41 | We want to run comparisons to MiniBooNE muon-neutrino scattering data on a mineral oil target, therefore to generate events we can run |
| 42 | {{{ |
| 43 | $ gevgen -f MiniBooNE -t CH |
| 44 | }}} |
| 45 | |
| 46 | Once our events have been generated we can check that they have finished correctly by opening the output event file has a ‘gtree’ object and the flux spectrum file contains the correct histogram. |
| 47 | |
| 48 | |
| 49 | {{{ |
| 50 | $ root gntp.2063030.ghep.root |
| 51 | root [0] |
| 52 | Attaching file gntp.2063030.ghep.root as _file0... |
| 53 | Warning in <TClass::TClass>: no dictionary for class genie::NtpMCEventRecord is available |
| 54 | Warning in <TClass::TClass>: no dictionary for class genie::NtpMCRecordI is available |
| 55 | Warning in <TClass::TClass>: no dictionary for class genie::NtpMCRecHeader is available |
| 56 | Warning in <TClass::TClass>: no dictionary for class genie::EventRecord is available |
| 57 | Warning in <TClass::TClass>: no dictionary for class genie::GHepRecord is available |
| 58 | Warning in <TClass::TClass>: no dictionary for class genie::Interaction is available |
| 59 | Warning in <TClass::TClass>: no dictionary for class genie::InitialState is available |
| 60 | Warning in <TClass::TClass>: no dictionary for class genie::Target is available |
| 61 | Warning in <TClass::TClass>: no dictionary for class genie::ProcessInfo is available |
| 62 | Warning in <TClass::TClass>: no dictionary for class genie::Kinematics is available |
| 63 | Warning in <TClass::TClass>: no dictionary for class genie::XclsTag is available |
| 64 | Warning in <TClass::TClass>: no dictionary for class genie::KPhaseSpace is available |
| 65 | Warning in <TClass::TClass>: no dictionary for class genie::GHepParticle is available |
| 66 | Warning in <TClass::TClass>: no dictionary for class pair<genie::EKineVar,double> is available |
| 67 | root [1] _file0->ls(); |
| 68 | TFile** gntp.2063030.ghep.root |
| 69 | TFile* gntp.2063030.ghep.root |
| 70 | KEY: genie::NtpMCTreeHeader header;1 GENIE output tree header |
| 71 | KEY: TFolder gconfig;1 GENIE configs |
| 72 | KEY: TFolder genv;1 GENIE user environment |
| 73 | KEY: TTree gtree;1 GENIE MC Truth TTree, Format: [NtpMCEventRecord] |
| 74 | }}} |
| 75 | |
| 76 | {{{ |
| 77 | $ root input-flux.root |
| 78 | root [0] |
| 79 | Attaching file input-flux.root as _file0... |
| 80 | root [1] _file0->ls(); |
| 81 | TFile** input-flux.root |
| 82 | TFile* input-flux.root |
| 83 | KEY: TH1D spectrum;1 neutrino_flux |
| 84 | }}} |
| 85 | |
| 86 | Now that the event samples have been generated correctly, we need to prepare them for use in NUISANCE. |
| 87 | |
| 88 | == Running PrepareGENIE == |
| 89 | |
| 90 | 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. |
| 91 | |
| 92 | The PrepareGENIE application is built when NUISANCE is built with GENIE support should be available after the NUISANCE environmental setup script is ran. |
| 93 | |
| 94 | {{{ |
| 95 | $ PrepareGENIE -h |
| 96 | PrepareGENIEEvents NUISANCE app. |
| 97 | Takes GHep Outputs and prepares events for NUISANCE. |
| 98 | |
| 99 | PrepareGENIEEvents [-h,-help,--h,--help] [-i inputfile1.root,inputfile2.root,inputfile3.root,...] [-f flux_root_file.root,flux_hist_name] [-t target1[frac1],target2[frac2],...] |
| 100 | |
| 101 | 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. |
| 102 | Following options are required for Prepare Mode: |
| 103 | [ -i inputfile.root ] : Reads in a single GHep input file that needs the xsec calculation ran on it. |
| 104 | [ -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'. |
| 105 | [ -t target ] : Target that GHepRecords were generated with. Comma seperated list. E.g. for CH2 target=1000060120,1000010010,1000010010 |
| 106 | }}} |
| 107 | |
| 108 | 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. |
| 109 | |
| 110 | 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. |
| 111 | |
| 112 | We want to prepare our MiniBooNE events so we pass in the event files, the input flux, and the CH2 target definition. |
| 113 | |
| 114 | {{{ |
| 115 | $ PrepareGENIE -i gntp.2063030.ghep.root -f input-flux.root,spectrum -t 1000060120,1000010010,1000010010 |
| 116 | }}} |
| 117 | |
| 118 | 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. |
| 119 | |
| 120 | {{{ |
| 121 | KEY: genie::NtpMCTreeHeader header;1 GENIE output tree header |
| 122 | KEY: TFolder gconfig;1 GENIE configs |
| 123 | KEY: TFolder genv;1 GENIE user environment |
| 124 | KEY: TTree gtree;1 GENIE MC Truth TTree, Format: [NtpMCEventRecord] |
| 125 | KEY: TDirectoryFile IndividualGENIESplines;1 IndividualGENIESplines |
| 126 | KEY: TDirectoryFile TargetGENIESplines;1 TargetGENIESplines |
| 127 | KEY: TH1F nuisance_xsec;1 |
| 128 | KEY: TH1F nuisance_events;1 |
| 129 | KEY: TH1F nuisance_flux;1 |
| 130 | }}} |
| 131 | |
| 132 | == Running gevgen_nuisance (optional) == |
| 133 | |
| 134 | Other than the standard gevgen application, if built against GENIE events later than GENIE 2.12.0, NUISANCE can also provide a gevgen_nuisance app, with additional features to support the creation of ‘NUISANCE-ready’ events. |
| 135 | |
| 136 | To build gevgen_nuisance, you will need to build with the option ‘-DBUILD_GEVGEN=ON’ during the cmake configure statement as shown in the build notes here: |
| 137 | |
| 138 | {{{ |
| 139 | $ cmake ../ -DUSE_GENIE=1 -DBUILD_GEVGEN=1 |
| 140 | }}} |
| 141 | |
| 142 | The gevgen_nuisance can be ran in a similar way to the normal gevgen application but flux inputs and target definitions can be provided in simpler formats |
| 143 | |
| 144 | In our example we want to generate events for a MiniBooNE muon neutrino flux on a CH2 target. Therefore we run |
| 145 | |
| 146 | {{{ |
| 147 | $ gevgen_nuisance -n 250000 -f MiniBooNE_fhc_numu -t CH2 |
| 148 | }}} |
| 149 | |
| 150 | We should then open the output event file to check it constrains the GENIE event tree ‘gtree’ object and the flux and event rate predictions. |
| 151 | |
| 152 | Notice that we no longer need to run PrepareGENIE on gevgen_nuisance events before using them nuisance. |
| 153 | |
| 154 | gevgen_nuisance also provides extra support for mixed target and flux specifications. For further notes on these see: |
| 155 | |
| 156 | == Setting up a GENIE Comparison == |
| 157 | |
| 158 | Now that we have an event sample we can load them load them into NUISANCE by specifying them at run time. To do that 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. |
| 159 | |
| 160 | We want to produce comparisons to MiniBooNE pion production data, so first we should search the NUISANCE sample list. |
| 161 | |
| 162 | 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. |
| 163 | |
| 164 | We can list the MIniBooNE samples using |
| 165 | {{{ |
| 166 | [stowell@hepgw1 ~]$ nuissamples MiniBooNE |
| 167 | MiniBooNE_CCQE_XSec_1DQ2_nu |
| 168 | MiniBooNE_CCQELike_XSec_1DQ2_nu |
| 169 | MiniBooNE_CCQE_XSec_1DQ2_antinu |
| 170 | MiniBooNE_CCQELike_XSec_1DQ2_antinu |
| 171 | MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu |
| 172 | MiniBooNE_CCQE_XSec_2DTcos_nu |
| 173 | MiniBooNE_CCQELike_XSec_2DTcos_nu |
| 174 | MiniBooNE_CCQE_XSec_2DTcos_antinu |
| 175 | MiniBooNE_CCQELike_XSec_2DTcos_antinu |
| 176 | MiniBooNE_CC1pip_XSec_1DEnu_nu |
| 177 | MiniBooNE_CC1pip_XSec_1DQ2_nu |
| 178 | MiniBooNE_CC1pip_XSec_1DTpi_nu |
| 179 | MiniBooNE_CC1pip_XSec_1DTu_nu |
| 180 | MiniBooNE_CC1pip_XSec_2DQ2Enu_nu |
| 181 | MiniBooNE_CC1pip_XSec_2DTpiCospi_nu |
| 182 | MiniBooNE_CC1pip_XSec_2DTpiEnu_nu |
| 183 | MiniBooNE_CC1pip_XSec_2DTuCosmu_nu |
| 184 | MiniBooNE_CC1pip_XSec_2DTuEnu_nu |
| 185 | MiniBooNE_CC1pi0_XSec_1DEnu_nu |
| 186 | MiniBooNE_CC1pi0_XSec_1DQ2_nu |
| 187 | MiniBooNE_CC1pi0_XSec_1DTu_nu |
| 188 | MiniBooNE_CC1pi0_XSec_1Dcosmu_nu |
| 189 | MiniBooNE_CC1pi0_XSec_1Dcospi0_nu |
| 190 | MiniBooNE_CC1pi0_XSec_1Dppi0_nu |
| 191 | MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu |
| 192 | MiniBooNE_NC1pi0_XSec_1Dcospi0_rhc |
| 193 | MiniBooNE_NC1pi0_XSec_1Dcospi0_nu |
| 194 | MiniBooNE_NC1pi0_XSec_1Dcospi0_fhc |
| 195 | MiniBooNE_NC1pi0_XSec_1Dppi0_antinu |
| 196 | MiniBooNE_NC1pi0_XSec_1Dppi0_rhc |
| 197 | MiniBooNE_NC1pi0_XSec_1Dppi0_nu |
| 198 | MiniBooNE_NC1pi0_XSec_1Dppi0_fhc |
| 199 | MiniBooNE_NCEL_XSec_Treco_nu |
| 200 | }}} |
| 201 | |
| 202 | We only care about CC1pip data therefore the following samples are of interest |
| 203 | {{{ |
| 204 | [stowell@hepgw1 ~]$ nuissamples MiniBooNE_CC1pip |
| 205 | MiniBooNE_CC1pip_XSec_1DEnu_nu |
| 206 | MiniBooNE_CC1pip_XSec_1DQ2_nu |
| 207 | MiniBooNE_CC1pip_XSec_1DTpi_nu |
| 208 | MiniBooNE_CC1pip_XSec_1DTu_nu |
| 209 | MiniBooNE_CC1pip_XSec_2DQ2Enu_nu |
| 210 | MiniBooNE_CC1pip_XSec_2DTpiCospi_nu |
| 211 | MiniBooNE_CC1pip_XSec_2DTpiEnu_nu |
| 212 | MiniBooNE_CC1pip_XSec_2DTuCosmu_nu |
| 213 | MiniBooNE_CC1pip_XSec_2DTuEnu_nu |
| 214 | }}} |
| 215 | |
| 216 | In this example we will compare to the 1Dtpi and 1DTu distributions, but we could provide any number of the samples seen in the lists. |
| 217 | |
| 218 | We write our card file with these two datasets using the following sample object format: |
| 219 | {{{ |
| 220 | sample NAME_OF_SAMPLE INPUT_TYPE:FILE_INPUT |
| 221 | }}} |
| 222 | |
| 223 | So for our genie files generated in step 2.1, our card file would be : |
| 224 | |
| 225 | **genie_tutorial.card** |
| 226 | {{{ |
| 227 | sample MiniBooNE_CC1pip_XSec_1DTpi_nu GENIE: gntp.2063030.ghep.root |
| 228 | sample MiniBooNE_CC1pip_XSec_1DTu_nu GENIE: gntp.2063030.ghep.root |
| 229 | }}} |
| 230 | |
| 231 | We can now run our cardfile using the standard nuisance application like so: |
| 232 | {{{ |
| 233 | $ nuiscomp -c genie_tutorial.card -o genie_samples.root |
| 234 | }}} |
| 235 | |
| 236 | This will produce a lot of logging output , but eventually, if there are no errors, it should finish with: |
| 237 | {{{ |
| 238 | [LOG Fitter]: Saving current full FCN predictions |
| 239 | [LOG Minmzr]:- Writing each of the data classes... |
| 240 | [LOG Sample]:-- Written Histograms: MiniBooNE_CC1pip_XSec_1DTpi_nu |
| 241 | [LOG Sample]:-- Written Histograms: MiniBooNE_CC1pip_XSec_1DTu_nu |
| 242 | [LOG Fitter]: ------------------------------------ - |
| 243 | [LOG Fitter]: Comparison Complete. |
| 244 | [LOG Fitter]: ------------------------------------ - |
| 245 | }}} |
| 246 | |
| 247 | To check that the comparison definitely finished successfully, lets open the root file and check the file is not empty. |
| 248 | {{{ |
| 249 | $ root genie_allsamples.root |
| 250 | Attaching file genie_allsamples.root as _file0... |
| 251 | root [0] TBrowser b |
| 252 | }}} |
| 253 | |
| 254 | |
| 255 | |
| 256 | If you see something similar to this then the comparisons should have ran successfully. |
| 257 | |