naming_schema.py
Go to the documentation of this file.
1 ###########################
2 # Naming schema
3 # histograms should follow a logical naming convention:
4 # <category>-<observable>-<reconstruction level>-<truth level>
5 # this module contains dictionaries of all know values of these
6 # as a dictionary. The key of the dictionary should match the value
7 # in the histogram naming convention. The value is used to label
8 # these in plots
9 categories = {"reco" : "Reconstructed observables",
10  "true" : "Truth observables",
11  "mc" : "Truth observables",
12  "mixed" : "Miscellanea",
13  "res" : "Resolutions",
14  "SAM" : "SAM",
15  "" : "Unknown"}
16 observables = {"definition_summary" : "",
17  "reco_neutrino_energy" : "Reconstructed neutrino energy",
18  "reco_muon_length" : "Reconstructed muon length",
19  "reco_hadronic_energy" : "Reconstructed hadronic energy",
20  "reco_fit_hadronic_energy" : "Reconstructed fit hadronic energy",
21  "true_neutrino_energy" : "True neutrino energy",
22  "true_muon_energy" : "True muon energy",
23  "true_hadronic_energy" : "True hadronic energy",
24  "true_x" : "True x",
25  "true_y" : "True y",
26  "true_w2" : "True w2",
27  "true_q2" : "True q2",
28  "counters" : "Cut flow counters",
29  "" : "Unknown",
30  "numuE" : "Reconstructed Neutrino Energy [GeV]",
31  "slcNHit" : "Slice N_{Hit}",
32  "calE" : "Slice Calorimetric Energy [GeV]",
33  "hadE" : "Reconstructed Hadronic Energy [GeV]",
34  "numuTrackE" : "Muon Track Energy [GeV]",
35  "hadEPerNHit" : "Average Hadronic Energy Per Hit [GeV]",
36  "trkEPerNHit" : "Average Track Energy Per Hit [GeV]",
37  "hadNHit" : "Hadronic N_{Hit}",
38  "hadcalE" : "Off-track Calorimetric Hadronic Energy [GeV]",
39  "hadTrkE" : "On-track Hadronic Energy [GeV]",
40  "hadVisE" : "Visible On-track Hadronic Energy [GeV]",
41  "maxy" : "Slice Maximum Y [m]",
42  "nkal" : "Number of Tracks in Slice",
43  "nhit" : "Number of Hits in Slice",
44  "trkStartX" : "Track Start X Position [m]",
45  "trkStartY" : "Track Start Y Position [m]",
46  "trkStartZ" : "Track Start Z Position [m]",
47  "trkEndX" : "Track End X Position [m]",
48  "trkEndY" : "Track End Y Position [m]",
49  "trkEndZ" : "Track End Z Position [m]",
50  "sliceDuration" : "Slice Duration [ns]",
51  "trkNhits" : "Number of Hits in Primary Track",
52  "trkLength" : "Muon Track Length [m]",
53  "scatLL" : "ReMId Input: Scattering Log-likelihood",
54  "dedxLL" : "ReMId Input: dE/dx Log-likelihood",
55  "nonHadPlaneFrac" : "ReMId Input: Non-hadronic Plane Fraction",
56  "remid" : "ReMId",
57  "slcUnCalibNHit" : "Number of Uncalibrated Hits in Slice",
58  "slcMeanTime" : "Slice Mean Time [#mus]",
59  "slcStartTime" : "Slice Start Time [#mus]",
60  "slcEndTime" : "Slice End Time [#mus]",
61  "slcMinX" : "Slice Minimum X [m]",
62  "slcMinY" : "Slice Minimum Y [m]",
63  "slcMinZ" : "Slice Minimum Z [m]",
64  "slcMaxX" : "Slice Maximum X [m]",
65  "slcMaxY" : "Slice Maximum Y [m]",
66  "slcMaxZ" : "Slice Maximum Z [m]",
67  "slcExtentX" : "Slice Extent X [m]",
68  "slcExtentY" : "Slice Extent Y [m]",
69  "slcExtentZ" : "Slice Extent Z [m]",
70  "dirX" : "Kalman Track Cos #theta_{X}",
71  "dirY" : "Kalman Track Cos #theta_{Y}",
72  "dirZ" : "Kalman Track Cos #theta_{Z}",
73  "cosNumi" : "Kalman Track Cos #theta_{NuMI}",
74  "trkNPlaneGap" : "Number of Missing Planes in Kalman Track",
75  "slcCalEPerNHit" : "Visible Slice Energy Per Hit [GeV]",
76  "qepid" : "QePId",
77  "nonQeE" : "Non QE Neutrino Energy [GeV]",
78  "nonQeHadE" : "Hadronic Non-QE Energy [GeV]",
79  "QepidOffE" : "QePId Input: Off-track Energy Ratio",
80  "QepidEDiff" : "QePId Input: Fractional Energy Difference",
81  "QepidEDiffZ" : "QePId Input: Fractional Energy Difference Z-test",
82  "QepidDedx" : "QePId Input: dE/dx Ratio",
83  "qeE" : "QE Neutrino Energy [GeV]",
84  "qeHadE" : "Hadronic QE Energy [GeV]",
85  "qeAngleE" : "QE Angle Neutrino Energy [GeV]",
86  "numuTrackE" : "Muon Track Energy [GeV]",
87  "HadVisE" : "Visible Hadronic Energy [GeV]",
88  "TotalPOT" : "Total PoT",
89  "TotalEvents" : "Number of events",
90  "trkccE" : "Reconstructed neutrino energy [GeV]",
91  "pid" : "Reconstructed muon identification",
92  "nhit" : "Number of hits in the slice",
93  "ncontplanes" : "Number of continuous planes in the slice",
94  "ncosmic" : "Number of cosmic tracks in the slice",
95  "nkalman" : "Number of Kalman tracks in the slice",
96  "ncellsfromedge" : "Minimum number of cells to edge of detector",
97  "firstplane" : "First plane in the slice",
98  "lastplane" : "Last plane in the slice",
99  "startZ" : "Z-pos of track start",
100  "stopZ" : "Z-pos of track stop",
101  "kalyposattrans" : "Y-pos of Kalman track at transition ",
102  "hadcalcatE_plus_hadcaltranE": "Hadronic calorometric energy NOT on muon track [GeV]",
103  "kalfwdcell" : "Kalman projected # cells forwards to det edge",
104  "kalbakcell" : "Kalman projected # cells backwards to det edge"
105  }
106 
107 reco_levels = {"" : "",
108  "NumuContainND" : "Containment and slice quality cuts",
109  "NumuND" : "Containment, slice quality, and ReMId cuts",
110  "NumuND1trk" : "Containment, slice quality, ReMId cuts and have 1 track",
111  "NumuND2trk" : "Containment, slice quality, ReMId cuts and have 2 tracks",
112  "NumuContainFD" : "Containment, cosmic rejection and slice quality cuts",
113  "NumuFD" : "Containment, cosmic rejection, slice quality, and ReMId cuts",
114  "NumuFD1trk" : "Containment, cosmic rejection, slice quality, ReMId cuts and have 1 track",
115  "NumuFD2trk" : "Containment, cosmic rejection, slice quality, ReMId cuts and have 2 tracks",
116  "nocut" : "No cuts",
117  "nocut_blinded" : "No cuts (blinded)",
118  "DQ" : "DQ",
119  "DQ_blinded" : "DQ (blinded)",
120  "DQ_containment" : "DQ + containment",
121  "DQ_containment_blinded" : "DQ + containment (blinded)",
122  "DQ_containment_NCRej" : "DQ + containment + NC rej",
123  "DQ_containment_NCRej_blinded" : "DQ + containment + NC rej (blinded)",
124  "all_numu_cuts" : "All cuts",
125  "all_numu_cuts_blinded" : "All cuts (blinded)",
126  "numu_selection" : "NuMu selection",
127  "NoCuts" : "No cuts",
128  "NoMEC" : "No MEC",
129  "NMinus1_trkccE" : "All cuts except trkccE",
130  "NMinus1_pid" : "All cuts except pid",
131  "NMinus1_nhit" : "All cuts except nhit",
132  "NMinus1_ncontplanes" : "All cuts except ncontplanes",
133  "NMinus1_ncosmic" : "All cuts except ncosmic",
134  "NMinus1_nkalman" : "All cuts except nkalman",
135  "NMinus1_ncellsfromedge" : "All cuts except ncellsfromedge",
136  "NMinus1_firstplane" : "All cuts except firstplane",
137  "NMinus1_lastplane" : "All cuts except lastplane",
138  "NMinus1_startZ" : "All cuts except startZ",
139  "NMinus1_stopZ" : "All cuts except stopZ",
140  "NMinus1_kalyposattrans" : "All cuts except kalyposattrans",
141  "NMinus1_hadcalE" : "All cuts except hadcalE",
142  "NMinus1_kalfwdcell" : "All cuts except kalfwdcell",
143  "NMinus1_kalbakcell" : "All cuts except kalbakcell",
144  "NMinus1_NCRej" : "All cuts except NCRej",
145  "numuFD": "Selected events pass the numu FD selection",
146  "numuND": "Selected events pass the numu ND selection"
147 
148  }
149 
150 true_levels = {"QE" : "QE",
151  "Res" : "Res",
152  "DIS" : "DIS",
153  "Coh" : "Coh",
154  "MEC" : "MEC",
155  "" : "All",
156  "truth_components" : "By component"}
157 components = {"caf_analysis" : "CAF Analysis",
158  "caf_numu_nd_validation" : "CAF NuMu ND validation",
159  "caf_numu_validation" : "CAF NuMu validation",
160  "caf_numu_fd_validation" : "CAF NuMu FD validation",
161  "caf_numu_sensitivity" : "CAF NuMu Sensitivity"}
162 validations = {}
163 standard_truth_components = ["", "QE", "Res", "DIS", "Coh", "MEC"]
164 standard_truth_suffixes = []
165 for t in standard_truth_components:
166  if t == "": standard_truth_suffixes.append(t)
167  else: standard_truth_suffixes.append("-%s"%t)
168 ###########################
169 # L.Vinton's nested true selections
170 # bases = ["true_numucc","numuFD","numuND"]
171 bases = {"true_numucc" : "True numu CC ",
172  "numuFD" : "FD numu selection ",
173  "numuND" : "ND numu selection "}
174 ints = {"no_cut" : "",
175  "true_qe" : "True QE events ",
176  "true_non_qe" : "True non-QE events "}
177 contains = {"no_cut" : "",
178  "true_nd_contained" : "True ND contained ",
179  "true_nd_uncontained" : "True ND un-contained "}
180 
181 for b in bases.keys():
182  for i in ints.keys():
183  for c in contains.keys():
184  key = "%s_%s_%s"%(b,i,c)
185  value = "%s %s %s"%(bases[b],ints[i],contains[c])
186  reco_levels[key] = value
187 
188 ###########################
189 # convert the dataset name to a label
190 def datasetToLabel(name):
191  if (" " in name): return name
192  label = ""
193  if "_nd_" in name: label += "ND "
194  else: label += "FD "
195 
196  if "_genie_" in name: label += "genie"
197  if "_cry_" in name: label += "CRY"
198  if "_cosmic_" in name:label += "cosmic data"
199  if "_numi_" in name: label += "NuMI data"
200 
201  return label
202 ###########################
203 # get a validation name
204 def validationName(name):
205  if name in validations.keys():
206  return validations[name]
207  return name.replace("_"," ")
208 ###########################
209 # get a component name
210 def componentName(name):
211  if name in components.keys():
212  return components[name]
213  return name.replace("_"," ").title()
214 ###########################
215 # get a histogram category name
216 def categoryName(name):
217  if name in categories.keys():
218  return categories[name]
219  return name.replace("_"," ").title()
220 ###########################
221 # get a histogram observable name
222 def observableName(name):
223  if name in observables.keys():
224  return observables[name]
225  return name.replace("_"," ").title()
226 ###########################
227 # get a reconstructed level
228 def recoLevelName(name):
229  if name in reco_levels.keys():
230  return reco_levels[name]
231  return name.replace("_"," ")
232 ##########################
233 # get a truth level
234 def trueLevelName(name):
235  if name in true_levels.keys():
236  return true_levels[name]
237  return name.replace("_"," ")
def validationName(name)
get a validation name
def datasetToLabel(name)
convert the dataset name to a label
def categoryName(name)
get a histogram category name
def componentName(name)
get a component name
def trueLevelName(name)
get a truth level
def observableName(name)
get a histogram observable name
def recoLevelName(name)
get a reconstructed level