CMS 3D CMS Logo

List of all members | Public Member Functions | Public Attributes
dataLoader.DataLoader Class Reference
Inheritance diagram for dataLoader.DataLoader:

Public Member Functions

def __init__ (self, csv_data, measurement_type, operating_point, flavour)
 
def print_data (self)
 

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

◆ __init__()

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

Definition at line 21 of file dataLoader.py.

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

Member Function Documentation

◆ print_data()

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.

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

Member Data Documentation

◆ abseta_test_points

dataLoader.DataLoader.abseta_test_points

Definition at line 120 of file dataLoader.py.

◆ DISCR_MAX

dataLoader.DataLoader.DISCR_MAX

Definition at line 67 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ DISCR_MIN

dataLoader.DataLoader.DISCR_MIN

Definition at line 62 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ discr_test_points

dataLoader.DataLoader.discr_test_points

Definition at line 122 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ discrs

dataLoader.DataLoader.discrs

Definition at line 53 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ entries

dataLoader.DataLoader.entries

◆ ETA_MAX

dataLoader.DataLoader.ETA_MAX

Definition at line 58 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ ETA_MIN

dataLoader.DataLoader.ETA_MIN

Definition at line 57 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ eta_test_points

dataLoader.DataLoader.eta_test_points

Definition at line 119 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ etas

dataLoader.DataLoader.etas

Definition at line 51 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ flav

dataLoader.DataLoader.flav

Definition at line 24 of file dataLoader.py.

◆ flavs

dataLoader.DataLoader.flavs

Definition at line 49 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ meas_type

dataLoader.DataLoader.meas_type

Definition at line 22 of file dataLoader.py.

◆ op

dataLoader.DataLoader.op

Definition at line 23 of file dataLoader.py.

◆ ops

dataLoader.DataLoader.ops

Definition at line 48 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ PT_MAX

dataLoader.DataLoader.PT_MAX

Definition at line 60 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ PT_MIN

dataLoader.DataLoader.PT_MIN

Definition at line 59 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ pt_test_points

dataLoader.DataLoader.pt_test_points

Definition at line 121 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ pts

dataLoader.DataLoader.pts

Definition at line 52 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().

◆ syss

dataLoader.DataLoader.syss

Definition at line 50 of file dataLoader.py.

Referenced by dataLoader.DataLoader.print_data().