#!/usr/bin/env python # Copyright (c) 2020, Anthony Latorre # # This program 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. # # This program 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 # this program. If not, see . """ Script to do convert GENIE reweight ROOT files into HDF5 files. To run it just run: $ ./convert-genie-rw [filename] -o [output filename] """ from __future__ import print_function, division import ROOT if __name__ == '__main__': import argparse import sys import h5py import numpy as np parser = argparse.ArgumentParser("convert GENIE reweight files from ROOT -> HDF5") parser.add_argument("filename", help="input filename") parser.add_argument("-o", "--output", required=True, help="output filename") args = parser.parse_args() f = ROOT.TFile(args.filename) weights = f.Get("weights") weights.GetEntry(0) nuniverses = len(weights.weights) data = np.empty(weights.GetEntries()*nuniverses,dtype=[('run',np.int32),('evn',np.int32),('universe',np.int32),('weight',np.float32)]) for i, event in enumerate(weights): for j in range(nuniverses): data[i*nuniverses+j] = event.runnum, event.eventnum, j, event.weights[j] f.Close() with h5py.File(args.output,"w") as fout: fout.create_dataset('weights',data=data) alue='169f148f885ddcd3697656129fd01968853a21de'/>
blob: dd88992f354b5cf04b3019e5b43ff76905ea3757 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
$processor_list 'MCO UCL PRU PCK OUT END'

* set up output file
$output_format $full_ds
$zdab_option $zdab_max_mc
$default_output_file '@output'

$prune_mc               $keep
$prune_mcpm             $keep
$prune_mcvx_source      $keep
$prune_mcvx_boundary    $drop
$prune_mcvx_interaction $drop
$prune_mcvx_sink        $drop
$prune_mcvx_pre_source  $drop

$mcrun 10000

* simulate run conditions for run 10000
$mc_gen_run_cond $on

$num_events @num_events

* number of vertices
$mc_num_seed_vx 1

$mc_interaction_type   $start$$@particle_id
$mc_position           $pos_region 2. $D2O$0000. 1. $ACRC_IVL$0000. 1.
$mc_direction          $dir_isotropic
$mc_energy             $en_mono @mc_energy
$mc_time               $tim_fixed 100.
$mc_misc_find_region   $unknown
$mc_event_rate         1. $per_sec

* Enable MPCA
$set_mpca_threshold 1.5

* Enable PCA which is required for MPCA
set bank TCAL 1 word 4 to 54

* Enable combined charge mode which is required for MPCA
$combined_q_mode 1

* titles files for run 10000
titles DQXX_0000010000.dat
titles /nfs/disk1/sno/mcprod/anxx/titles/pca/anxx_pca_0000010623_p2.dat
titles /nfs/disk1/sno/output/anxx/titles/neutrino/10000-10999/anxx_nu_0000010000_p12.dat

* set the average number of noise hits per event
* this comes from the autosno generated MC_Atm_Nu_No_Osc_Snoman_Genie10000_X_1_run_mc_atm_nu_genie.cmd file
set bank TRSP 1 word 2 to 2.051309

@activate_atmospherics
@load_d2o_settings.cmd
@run_snodb