nuisance is hosted by Hepforge, IPPP Durham
close Warning: Can't synchronize with repository "(default)" ("(default)" is not readable or not a Git repository.). Look in the Trac log for more information.

Changes between Version 1 and Version 2 of HowToUseNUISMIN-GENIE


Ignore:
Timestamp:
Jun 13, 2017, 3:05:34 PM (7 years ago)
Author:
Patrick Stowell
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • HowToUseNUISMIN-GENIE

    v1 v2  
    1111[[PageOutline(1-3,Wiki content,inline,numbered)]]
    1212
    13 == Running NUISMIN ==
     13= Running NUISMIN =
    1414
    1515{{{
     
    2828- [wiki:HowToUseNUISMIN-GENIE I want to use GENIE]
    2929
    30 == Running a GENIE Minimization ==
    31 
    32 === Preparing Event Samples ===
    33 
    34 === Choosing our samples ===
     30= Running a GENIE Minimization =
     31
     32In 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 ==
     35If 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
     37If 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
     41The standard gevgen application options can be ran using
     42{{{
     43 $ gevgen -h
     44Syntax:
     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
     65We need to provide a flux and target list to GENIE when running gevgen.
     66
     67We 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}}}
     77For more information on how to generate events in GENIE please see: https://arxiv.org/abs/1510.05494
     78
     79Once 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
     84root [0]
     85Attaching file gntp.2063030.ghep.root as _file0...
     86Warning in <TClass::TClass>: no dictionary for class genie::NtpMCEventRecord is available
     87Warning in <TClass::TClass>: no dictionary for class genie::NtpMCRecordI is available
     88Warning in <TClass::TClass>: no dictionary for class genie::NtpMCRecHeader is available
     89Warning in <TClass::TClass>: no dictionary for class genie::EventRecord is available
     90Warning in <TClass::TClass>: no dictionary for class genie::GHepRecord is available
     91Warning in <TClass::TClass>: no dictionary for class genie::Interaction is available
     92Warning in <TClass::TClass>: no dictionary for class genie::InitialState is available
     93Warning in <TClass::TClass>: no dictionary for class genie::Target is available
     94Warning in <TClass::TClass>: no dictionary for class genie::ProcessInfo is available
     95Warning in <TClass::TClass>: no dictionary for class genie::Kinematics is available
     96Warning in <TClass::TClass>: no dictionary for class genie::XclsTag is available
     97Warning in <TClass::TClass>: no dictionary for class genie::KPhaseSpace is available
     98Warning in <TClass::TClass>: no dictionary for class genie::GHepParticle is available
     99Warning in <TClass::TClass>: no dictionary for class pair<genie::EKineVar,double> is available
     100root [1] _file0->ls();
     101TFile**         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
     111root [0]
     112Attaching file input-flux.root as _file0...
     113root [1] _file0->ls();
     114TFile**         input-flux.root
     115 TFile*         input-flux.root
     116  KEY: TH1D     spectrum;1      neutrino_flux
     117}}}
     118
     119Now that the event samples have been generated correctly, we need to prepare them for use in NUISANCE.
     120
     121=== Running PrepareGENIE ===
     122
     123The 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
     125The 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
     129PrepareGENIEEvents NUISANCE app.
     130Takes GHep Outputs and prepares events for NUISANCE.
     131
     132PrepareGENIEEvents  [-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
     137Prepare Mode [Default] : Takes a single GHep file, reconstructs the original GENIE splines,  and creates a duplicate file that
     138also contains the flux, event rate, and xsec predictions that NUISANCE needs.
     139Following 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
     142simple 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
     144target=1000060120,1000010010,1000010010
     145}}}
     146
     147The 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
     149These 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
     151We 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
     157Now 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
     174Now 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
     178To 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
     180We want to produce comparisons to MiniBooNE CCQE data, so first we should search the NUISANCE sample list.
     181
     182The ‘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
     184We can list the MIniBooNE samples using
     185{{{
     186[stowell@hepgw1 ~]$ nuissamples MiniBooNE
     187MiniBooNE_CCQE_XSec_1DQ2_nu
     188MiniBooNE_CCQELike_XSec_1DQ2_nu
     189MiniBooNE_CCQE_XSec_1DQ2_antinu
     190MiniBooNE_CCQELike_XSec_1DQ2_antinu
     191MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu
     192MiniBooNE_CCQE_XSec_2DTcos_nu
     193MiniBooNE_CCQELike_XSec_2DTcos_nu
     194MiniBooNE_CCQE_XSec_2DTcos_antinu
     195MiniBooNE_CCQELike_XSec_2DTcos_antinu
     196MiniBooNE_CC1pip_XSec_1DEnu_nu
     197MiniBooNE_CC1pip_XSec_1DQ2_nu
     198MiniBooNE_CC1pip_XSec_1DTpi_nu
     199MiniBooNE_CC1pip_XSec_1DTu_nu
     200MiniBooNE_CC1pip_XSec_2DQ2Enu_nu
     201MiniBooNE_CC1pip_XSec_2DTpiCospi_nu
     202MiniBooNE_CC1pip_XSec_2DTpiEnu_nu
     203MiniBooNE_CC1pip_XSec_2DTuCosmu_nu
     204MiniBooNE_CC1pip_XSec_2DTuEnu_nu
     205MiniBooNE_CC1pi0_XSec_1DEnu_nu
     206MiniBooNE_CC1pi0_XSec_1DQ2_nu
     207MiniBooNE_CC1pi0_XSec_1DTu_nu
     208MiniBooNE_CC1pi0_XSec_1Dcosmu_nu
     209MiniBooNE_CC1pi0_XSec_1Dcospi0_nu
     210MiniBooNE_CC1pi0_XSec_1Dppi0_nu
     211MiniBooNE_NC1pi0_XSec_1Dcospi0_antinu
     212MiniBooNE_NC1pi0_XSec_1Dcospi0_rhc
     213MiniBooNE_NC1pi0_XSec_1Dcospi0_nu
     214MiniBooNE_NC1pi0_XSec_1Dcospi0_fhc
     215MiniBooNE_NC1pi0_XSec_1Dppi0_antinu
     216MiniBooNE_NC1pi0_XSec_1Dppi0_rhc
     217MiniBooNE_NC1pi0_XSec_1Dppi0_nu
     218MiniBooNE_NC1pi0_XSec_1Dppi0_fhc
     219MiniBooNE_NCEL_XSec_Treco_nu
     220}}}
     221
     222We only care about CC1pip data therefore the following samples are of interest
     223{{{
     224[stowell@hepgw1 ~]$ nuissamples MiniBooNE_CCQE_
     225MiniBooNE_CCQE_XSec_1DQ2_nu
     226MiniBooNE_CCQE_XSec_1DQ2_antinu
     227MiniBooNE_CCQE_CTarg_XSec_1DQ2_antinu
     228MiniBooNE_CCQE_XSec_2DTcos_nu
     229MiniBooNE_CCQE_XSec_2DTcos_antinu
     230
     231}}}
     232
     233In 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
     235We write our card file with these two datasets using the following sample object format:
     236{{{
     237sample NAME_OF_SAMPLE  INPUT_TYPE:FILE_INPUT   
     238}}}
     239
     240So if our GENIE file is called 'MiniBooNE_FHC_numu_2.5M.root', our card file will be :
     241
     242**genie_tutorial.card**
     243{{{
     244sample MiniBooNE_CCQE_XSec_1DQ2_nu GENIE:MiniBooNE_FHC_numu_2.5M.root
     245sample MiniBooNE_CCQE_XSec_1DQ2_antinu GENIE:MiniBooNE_FHC_numu_2.5M.root
     246}}}
     247
     248If 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.
    35249
    36250=== Setting up our reweight dials ===