~maus-maintainers/maus/merge

« back to all changes in this revision

Viewing changes to bin/user/first-observation-paper-scripts/old/old_configs/config_reco_2017_03_straights.py

  • Committer: Paolo Franchini
  • Date: 2019-07-26 10:14:17 UTC
  • mfrom: (736.1.7 MAUS_to_be_3.3.2)
  • Revision ID: p.franchini@warwick.ac.uk-20190726101417-tb49frojbb37nish
MergeĀ fromĀ MAUS-v3.3.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import copy
2
 
 
3
 
def mc_file_names(job_name, datasets):
4
 
    file_list = ["/home/cr67/work/reco/mc/"+job_name+"/"+datasets+"/*_sim.root"]
5
 
    return file_list
6
 
 
7
 
def reco_file_names(run_number_list, maus, do_globals):
8
 
    file_list = []
9
 
    for run in run_number_list:
10
 
        run = str(run).rjust(5, '0')
11
 
        a_file = "/home/cr67/work/reco/"+maus+"/"+run+"/"+run+"_recon"
12
 
        if not do_globals:
13
 
            a_file += ".root"
14
 
        else:
15
 
            a_file += "_global_test.root"
16
 
        file_list.append(a_file)
17
 
    print file_list
18
 
    return file_list
19
 
 
20
 
def get_analysis(run_list, name, tof01_min_max, maus_version, data_dir, amplitude_source, p_bins, tkd_cut, do_globals):
21
 
    plot_dir = data_dir+"plots_"+name+"/"
22
 
    plot_dir = plot_dir.replace(" ", "_")
23
 
    min_p = min([min(a_bin) for a_bin in p_bins])
24
 
    max_p = max([max(a_bin) for a_bin in p_bins])
25
 
    return {
26
 
            "plot_dir":plot_dir, # makedirs and then put plots in this directory. Removes any old plots there!!!
27
 
            "tof12_cut_low":32., # TOF12 cut lower bound
28
 
            "tof12_cut_high":39., # TOF12 cut upper bound
29
 
            "delta_tof01_lower":-2., # Delta TOF01 cut lower bound 
30
 
            "delta_tof01_upper":1.5, # Delta TOF01 cut upper bound 
31
 
            "delta_tof12_lower":-5., # Delta TOF01 cut lower bound 
32
 
            "delta_tof12_upper":5., # Delta TOF01 cut upper bound 
33
 
            "tof01_cut_low":tof01_min_max[0], # TOF01 cut lower bound
34
 
            "tof01_cut_high":tof01_min_max[1], # TOF01 cut upper bound
35
 
            "p_bins":p_bins, # set of momentum bins; for now really it is just a lower and upper bound
36
 
            "p_tot_ds_low":tkd_cut[0], # downstream momentum cut lower bound
37
 
            "p_tot_ds_high":tkd_cut[1], # downstream momentum cut upper bound
38
 
            "reco_files":reco_file_names(run_list, maus_version, do_globals), # list of strings to be handed to glob
39
 
            "name":name, # appears on plots
40
 
            "color":4, # not used
41
 
            "pid":-13, # assume pid of tracks following TOF cut
42
 
            "pvalue_threshold":0.02, # minimum allowed pvalue for pvalue cut
43
 
            "chi2_threshold":10.0, # maximum allowed chi2/dof for chi2 cut
44
 
            "amplitude_source":"output/2016-04_1.2_mc/plots_"+amplitude_source+"/amplitude.json",
45
 
            "field_uncertainty":0.02,
46
 
            "amplitude_chi2":False,
47
 
            "do_magnet_alignment":False,
48
 
            "do_amplitude":False,
49
 
            "do_extrapolation":False,
50
 
            "do_globals":do_globals,
51
 
            "do_mc":False,
52
 
            "do_plots":True,
53
 
            "csv_output_detectors":["tof1", "diffuser_us", "diffuser_mid", "diffuser_ds"], # write data at listed detector locations
54
 
            "csv_output_filename":"test", #"8590_mc_extrapolated_tracks.csv", # write a summary output of data in flat text format to listed filename; set to None to do nothing
55
 
            "extrapolation_source":"tku_tp"
56
 
        }
57
 
 
58
 
 
59
 
class Config(object):
60
 
    geometry = "Test.dat" #"geometry_08681/ParentGeometryFile.dat" #
61
 
    # location to which data and plots will be dumped following analysis
62
 
    info_file = "geometry_08681/Maus_Information.gdml"
63
 
    will_require_tof1 = True # require at least one TOF1 Space point to even load the data
64
 
    will_require_tof2 = False # require at least one TOF2 Space point to even load the data
65
 
    tk_station = 1 # load data from a particular tracker station
66
 
    tk_plane = 0
67
 
    # prerequisite for space point cut
68
 
    will_require_triplets = False #True # require triplet space points
69
 
    upstream_cuts = { # Set to true to make data_plotter and amplitude_analysis use these cuts; False to ignore the cut
70
 
          "any_cut":None,
71
 
          "scifi_space_clusters":False,
72
 
          "scifi_space_points":False,
73
 
          "scifi_tracks_us":True,
74
 
          "scifi_nan_us":False,
75
 
          "scifi_track_points_us":False,
76
 
          "aperture_us":False,
77
 
          "pvalue_us":False,
78
 
          "chi2_us":False,
79
 
          "aperture_ds":False,
80
 
          "scifi_tracks_ds":False,
81
 
          "scifi_nan_ds":False,
82
 
          "scifi_track_points_ds":False,
83
 
          "pvalue_ds":False,
84
 
          "chi2_ds":False,
85
 
          "tof01":False,
86
 
          "tof12":False,
87
 
          "delta_tof01":False, #extrapolatedtof01 compared to recon tof01
88
 
          "delta_tof12":False, #extrapolatedtof12 compared to recon tof12
89
 
          "p_tot_us":False,
90
 
          "p_tot_ds":False,
91
 
          "tof_0_sp":True,
92
 
          "tof_1_sp":True,
93
 
          "tof_2_sp":False,
94
 
          "upstream_aperture_cut":False,
95
 
          "downstream_aperture_cut":False,
96
 
    }
97
 
    downstream_cuts = copy.deepcopy(upstream_cuts)
98
 
    downstream_cuts["p_tot_ds"] = True
99
 
    downstream_cuts["tof2_sp"] = True
100
 
    downstream_cuts["pvalue_ds"] = False
101
 
    downstream_cuts["chi2_ds"] = False
102
 
    downstream_cuts["tof12"] = False # if TOF12 is out of range chuck it (but ignore "no TOF2" events)
103
 
    downstream_cuts["scifi_nan_ds"] = True
104
 
    downstream_cuts["scifi_tracks_ds"] = True
105
 
    extrapolation_cuts = upstream_cuts
106
 
 
107
 
    data_dir = "output/2017-03-straights/"
108
 
 
109
 
    analyses = []
110
 
    for run in [10161]:
111
 
        analyses.append(get_analysis([run], "3-140-"+str(run), [27, 32], "MAUS-v3.0.2", data_dir, "3-140_MC", [[135, 145]], [100, 200], False))
112
 
    #for run in [10141]:
113
 
    #    analyses.append(get_analysis([run], "6-140-"+str(run), [27, 31], "MAUS-v3.0.2", data_dir, "10-140_MC", [[135, 145]], [100, 200], False))
114
 
    #for run in [10140]:  
115
 
    #    analyses.append(get_analysis([run], "10-140-"+str(run), [27, 30], "MAUS-v3.0.2", data_dir, "10-140_MC", [[135, 145]], [100, 200], False))
116
 
    amplitude_bin_width = 5
117
 
    amplitude_max = 25
118
 
 
119
 
    required_trackers = [0, 1] # for space points
120
 
    required_number_of_track_points = 12 # doesnt do anything
121
 
    global_min_step_size = 1. # for extrapolation, set the extrapolation step size
122
 
    global_max_step_size = 100. # for extrapolation, set the extrapolation step size
123
 
    will_load_tk_space_points = True # determines whether data loader will attempt to load tracker space points
124
 
    will_load_tk_track_points = True # determines whether data loader will attempt to load tracker track points
125
 
    number_of_spills = None #100 # if set to an integer, limits the number of spills loaded for each sub-analysis
126
 
    preanalysis_number_of_spills = 1000 # number of spills to analyse during "pre-analysis"
127
 
    analysis_number_of_spills = 1000 # number of spills to analyse during each "analysis" step
128
 
    momentum_from_tracker = True # i.e. not from TOFs
129
 
    time_from = "tof1"
130
 
 
131
 
    residuals_plots_nbins = 100 # used for track extrapolation plots
132
 
    extrapolation_does_apertures = True # set to True in order to include apertures in track extrapolation
133
 
    maus_verbose_level = 5
134
 
 
135
 
    magnet_alignment = {
136
 
        "n_events":10,
137
 
        "max_iterations":100,
138
 
        "resolution":1.,
139
 
    }
140
 
 
141
 
    # z position of central absorber (used for offsetting
142
 
    z_apertures = 0.
143
 
    # z position of detectors (used for track extrapolation) (z, name)
144
 
    # 13692: diffuser us edge
145
 
    # 13782: diffuser ds edge
146
 
    # 16639: lH2 window mount us (us edge)
147
 
    # 16710: lH2 window mount us (ds edge)
148
 
    # 16953.5: LiH centre
149
 
    # 17166: lH2 window mount ds (us edge)
150
 
    # 17242: lH2 window mount ds (ds edge)
151
 
    # 17585: SSU aperture
152
 
    # 18733: SSU He window
153
 
    tkd_offset = 8.
154
 
    detectors = [
155
 
        (5287.2, None, "tof0"),
156
 
        (12929.6-25., None, "tof1_us"),
157
 
        (12929.6, None, "tof1"),
158
 
        (12929.6+25., None, "tof1_ds"),
159
 
        (13968.0, None, "tku_5"),
160
 
        (14318.0, None, "tku_4"),
161
 
        (14618.0, None, "tku_3"),
162
 
        (14867.0, None, "tku_2"),
163
 
        (15068.0, None, "tku_tp"),
164
 
        (18836.8+tkd_offset, None, "tkd_tp"),
165
 
        (18855.+tkd_offset, None, "tkd_2"),
166
 
        (19205.+tkd_offset, None, "tkd_3"),
167
 
        (19505.+tkd_offset, None, "tkd_4"),
168
 
        (19855.+tkd_offset, None, "tkd_5"),
169
 
        (21114.4, None, "tof2"),
170
 
        (21139.4, None, "tof2"),
171
 
        (21159.4, None, "tof2"),
172
 
        (21208., None, "tof2"),
173
 
        (21214.4, None, "tof2"),
174
 
        (21220.4, None, "tof2"),
175
 
 
176
 
    ]
177
 
 
178
 
    plot_virtual_stations = [47, 62, 63, 72, 73, 75, 81]
179
 
    virtual_detectors = [500.*i for i in range(51)]+[det[0] for det in detectors]
180
 
    virtual_detectors += [12975, 13240., 13278, 13306.5, 13326, 13346.4, 13771.2, 13380, 13582, 13592, 13682, 13728, 13704.4, 13709.5, 13755, 13782, 13805, 13850, 13867, 16639, 16710, 16953, 16974, 17166, 17242, 17585,
181
 
                          18733, 19937.9, 16803.7, 16919.6, 16941, 16985.4, 17101.3, 18460, 18540., 18600., 19308, 19328,
182
 
                          19036.8, 19078, 19286.7, 19586.7, 20720]
183
 
    virtual_detectors = [(z, None, "virtual_"+str(i)) for i, z in enumerate(sorted(virtual_detectors))]
184
 
    for z, dummy, plane in virtual_detectors:
185
 
        print z, plane
186
 
    mc_plots = {
187
 
        "mc_stations" : {
188
 
            "tku":53,
189
 
            "tkd":63,
190
 
        }
191
 
    }
192
 
 
193
 
    z_afc = 16955.74
194
 
    # z position of apertures (z, maximum radius, name)
195
 
    # Notes from Jason: 209.6 to fixed flange
196
 
    # 282.5 to movable flange
197
 
    # what about tracker butterfly us and ds?
198
 
    apertures = sorted(
199
 
      [(-3325.74+z_afc, 100., "diffuser_us"),
200
 
       (-3276.74+z_afc, 100., "diffuser_mid"),
201
 
       (-3227.74+z_afc, 100., "diffuser_ds"),]+\
202
 
      [(float(z)+z_afc, 150., "tku_"+str(z)) for z in range(-2918, -1817, 100)]+\
203
 
      [(float(z)+z_afc, 150., "tkd_"+str(z)) for z in range(1818, 2919, 100)]+\
204
 
      [(float(z)+z_afc, 200., "pipe_"+str(z)) for z in range(-1800, 1801, 100)]+\
205
 
      [(+209.6+z_afc, 160., "afc_209.6")],
206
 
    )
207
 
 
208