CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Member Functions | Public Attributes
dataLoader.DataLoader Class Reference
Inheritance diagram for dataLoader.DataLoader:

Public Member Functions

def __init__
 
def print_data
 

Public Attributes

 abseta_test_points
 
 DISCR_MAX
 
 DISCR_MIN
 
 discr_test_points
 
 discrs
 
 entries
 
 ETA_MAX
 
 ETA_MIN
 
 eta_test_points
 
 etas
 
 flav
 
 flavs
 
 meas_type
 
 op
 
 ops
 
 PT_MAX
 
 PT_MIN
 
 pt_test_points
 
 pts
 
 syss
 

Detailed Description

Definition at line 20 of file dataLoader.py.

Constructor & Destructor Documentation

def dataLoader.DataLoader.__init__ (   self,
  csv_data,
  measurement_type,
  operating_point,
  flavour 
)

Definition at line 21 of file dataLoader.py.

21 
22  def __init__(self, csv_data, measurement_type, operating_point, flavour):
23  self.meas_type = measurement_type
24  self.op = operating_point
25  self.flav = flavour
26 
27  # list of entries
28  ens = []
29  for l in csv_data:
30  if not l.strip():
31  continue # skip empty lines
32  try:
33  e = ROOT.BTagEntry(l)
34  if (e.params.measurementType == measurement_type
35  and ((not separate_by_op)
36  or e.params.operatingPoint == operating_point)
37  and ((not separate_by_flav)
38  or e.params.jetFlavor == flavour)
39  ):
40  ens.append(e)
41  except TypeError:
42  raise RuntimeError("Error: can not interpret line: " + l)
43  self.entries = ens
44 
45  if not ens:
46  return
47 
48  # fixed data
49  self.ops = set(e.params.operatingPoint for e in ens)
50  self.flavs = set(e.params.jetFlavor for e in ens)
51  self.syss = set(e.params.sysType for e in ens)
52  self.etas = set((e.params.etaMin, e.params.etaMax) for e in ens)
53  self.pts = set((e.params.ptMin, e.params.ptMax) for e in ens)
54  self.discrs = set((e.params.discrMin, e.params.discrMax)
55  for e in ens
56  if e.params.operatingPoint == 3)
57 
58  self.ETA_MIN = -2.4
59  self.ETA_MAX = 2.4
60  self.PT_MIN = min(e.params.ptMin for e in ens)
61  self.PT_MAX = max(e.params.ptMax for e in ens)
62  if any(e.params.operatingPoint == 3 for e in ens):
63  self.DISCR_MIN = min(
64  e.params.discrMin
65  for e in ens
66  if e.params.operatingPoint == 3
67  )
68  self.DISCR_MAX = max(
69  e.params.discrMax
70  for e in ens
71  if e.params.operatingPoint == 3
72  )
73  else:
74  self.DISCR_MIN = 0.
75  self.DISCR_MAX = 1.
76 
77  # test points for variable data (using bound +- epsilon)
78  eps = 1e-4
79  eta_test_points = list(itertools.ifilter(
80  lambda x: self.ETA_MIN < x < self.ETA_MAX,
81  itertools.chain(
82  (a + eps for a, _ in self.etas),
83  (a - eps for a, _ in self.etas),
84  (b + eps for _, b in self.etas),
85  (b - eps for _, b in self.etas),
86  (self.ETA_MIN + eps, self.ETA_MAX - eps),
87  )
88  ))
89  abseta_test_points = list(itertools.ifilter(
90  lambda x: 0. < x < self.ETA_MAX,
91  itertools.chain(
92  (a + eps for a, _ in self.etas),
93  (a - eps for a, _ in self.etas),
94  (b + eps for _, b in self.etas),
95  (b - eps for _, b in self.etas),
96  (eps, self.ETA_MAX - eps),
97  )
98  ))
99  pt_test_points = list(itertools.ifilter(
100  lambda x: self.PT_MIN < x < self.PT_MAX,
101  itertools.chain(
102  (a + eps for a, _ in self.pts),
103  (a - eps for a, _ in self.pts),
104  (b + eps for _, b in self.pts),
105  (b - eps for _, b in self.pts),
106  (self.PT_MIN + eps, self.PT_MAX - eps),
107  )
108  ))
109  discr_test_points = list(itertools.ifilter(
110  lambda x: self.DISCR_MIN < x < self.DISCR_MAX,
111  itertools.chain(
112  (a + eps for a, _ in self.discrs),
113  (a - eps for a, _ in self.discrs),
114  (b + eps for _, b in self.discrs),
115  (b - eps for _, b in self.discrs),
116  (self.DISCR_MIN + eps, self.DISCR_MAX - eps),
117  )
118  ))
119  # use sets
120  self.eta_test_points = set(round(f, 5) for f in eta_test_points)
121  self.abseta_test_points = set(round(f, 5) for f in abseta_test_points)
122  self.pt_test_points = set(round(f, 5) for f in pt_test_points)
123  self.discr_test_points = set(round(f, 5) for f in discr_test_points)
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
T min(T a, T b)
Definition: MathUtil.h:58

Member Function Documentation

def dataLoader.DataLoader.print_data (   self)

Definition at line 124 of file dataLoader.py.

References dataLoader.DataLoader.DISCR_MAX, dataLoader.DataLoader.DISCR_MIN, dataLoader.DataLoader.discr_test_points, dataLoader.DataLoader.discrs, dataLoader.DataLoader.ETA_MAX, dataLoader.DataLoader.ETA_MIN, dataLoader.DataLoader.eta_test_points, dataLoader.DataLoader.etas, dataLoader.DataLoader.flavs, dataLoader.DataLoader.ops, print(), dataLoader.DataLoader.PT_MAX, dataLoader.DataLoader.PT_MIN, dataLoader.DataLoader.pt_test_points, dataLoader.DataLoader.pts, and dataLoader.DataLoader.syss.

125  def print_data(self):
126  print("\nFound operating points:")
127  print(self.ops)
128 
129  print("\nFound jet flavors:")
130  print(self.flavs)
131 
132  print("\nFound sys types (need at least 'central', 'up', 'down'; " \
133  "also 'up_SYS'/'down_SYS' compatibility is checked):")
134  print(self.syss)
135 
136  print("\nFound eta ranges: (need everything covered from %g or 0. " \
137  "up to %g):" % (self.ETA_MIN, self.ETA_MAX))
138  print(self.etas)
139 
140  print("\nFound pt ranges: (need everything covered from %g " \
141  "to %g):" % (self.PT_MIN, self.PT_MAX))
142  print(self.pts)
143 
144  print("\nFound discr ranges: (only needed for operatingPoint==3, " \
145  "covered from %g to %g):" % (self.DISCR_MIN, self.DISCR_MAX))
146  print(self.discrs)
147 
148  print("\nTest points for eta (bounds +- epsilon):")
149  print(self.eta_test_points)
150 
151  print("\nTest points for pt (bounds +- epsilon):")
152  print(self.pt_test_points)
153 
154  print("\nTest points for discr (bounds +- epsilon):")
156  print("")
157 
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47

Member Data Documentation

dataLoader.DataLoader.abseta_test_points

Definition at line 120 of file dataLoader.py.

dataLoader.DataLoader.DISCR_MAX

Definition at line 67 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.DISCR_MIN

Definition at line 62 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.discr_test_points

Definition at line 122 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.discrs

Definition at line 53 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.entries

Definition at line 42 of file dataLoader.py.

Referenced by python.rootplot.utilities.Hist.__init_TGraph(), and python.rootplot.utilities.Hist.TH1F().

dataLoader.DataLoader.ETA_MAX

Definition at line 58 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.ETA_MIN

Definition at line 57 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.eta_test_points

Definition at line 119 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.etas

Definition at line 51 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.flav

Definition at line 24 of file dataLoader.py.

dataLoader.DataLoader.flavs

Definition at line 49 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.meas_type

Definition at line 22 of file dataLoader.py.

dataLoader.DataLoader.op

Definition at line 23 of file dataLoader.py.

dataLoader.DataLoader.ops

Definition at line 48 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.PT_MAX

Definition at line 60 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.PT_MIN

Definition at line 59 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.pt_test_points

Definition at line 121 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.pts

Definition at line 52 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

dataLoader.DataLoader.syss

Definition at line 50 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().