CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
generateFlavCfromFlavB Namespace Reference

Functions

def generate_flav_c
 
def main
 

Function Documentation

def generateFlavCfromFlavB.generate_flav_c (   loaded_data)

Definition at line 10 of file generateFlavCfromFlavB.py.

References cmsPerfStripChart.dict, alcazmumu_cfi.filter, and list().

Referenced by main().

10 
11 def generate_flav_c(loaded_data):
12  flav_b_data = filter(
13  lambda e: e.params.jetFlavor == 0,
14  loaded_data.entries
15  )
16  flav_b_data = sorted(flav_b_data, key=lambda e: e.params.operatingPoint)
17  flav_b_data = sorted(flav_b_data, key=lambda e: e.params.measurementType)
18  flav_b_data = sorted(flav_b_data, key=lambda e: e.params.etaMin)
19  flav_b_data = sorted(flav_b_data, key=lambda e: e.params.ptMin)
20  flav_b_data = sorted(flav_b_data, key=lambda e: e.params.discrMin)
21  sys_groups = itertools.groupby(
22  flav_b_data,
23  key=lambda e: '%d, %s, %.02f, %.02f, %.02f' % (
24  e.params.operatingPoint,
25  e.params.measurementType,
26  e.params.etaMin,
27  e.params.ptMin,
28  e.params.discrMin
29  )
30  )
31 
32  def gen_entry_dict(groups):
33  for _, grp in groups:
34  grp = list(grp)
35  entries_by_sys = dict((e.params.sysType, e) for e in grp)
36  assert len(grp) == len(entries_by_sys) # every sysType is unique
37  yield entries_by_sys
38  sys_dicts = gen_entry_dict(sys_groups)
39 
40  def gen_flavb_csv_line(dicts):
41  for d in dicts:
42  central = d.pop('central')
43  central.params.jetFlavor = 1
44  yield central.makeCSVLine()
45  for e in d.itervalues():
46  e.params.jetFlavor = 1
47  e.formula = '2*(%s)-(%s)' % (e.formula, central.formula)
48  yield e.makeCSVLine()
49  csv_lines = gen_flavb_csv_line(sys_dicts)
50 
51  return list(l for l in csv_lines)
52 
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
def generateFlavCfromFlavB.main ( )

Definition at line 53 of file generateFlavCfromFlavB.py.

References any(), cmsRelvalreport.exit, generate_flav_c(), dataLoader.get_data(), and list().

53 
54 def main():
55  if len(sys.argv) < 3:
56  print 'Need input/output filenames as first/second arguments. Exit.'
57  exit(-1)
58  if os.path.exists(sys.argv[2]):
59  print 'Output file exists. Exit.'
60  exit(-1)
61 
62  print '\nChecking input file consistency...'
63  loaders = dataLoader.get_data(sys.argv[1])
64  checks = checker.run_check_data(loaders, True, True, False)
65  for data in loaders:
66  typ = data.meas_type
67  if 1 in data.flavs:
68  print 'FLAV_C already present in input file for %s. Exit.' % typ
69  exit(-1)
70  if not any(0 in data.flavs for data in loaders):
71  print 'FLAV_B not found in input file. Exit.'
72  exit(-1)
73 
74 
75  print '\nGenerating new csv content...'
76  new_csv_data = list(itertools.chain.from_iterable(
77  l
78  for d in loaders
79  for l in generate_flav_c(d)
80  ))
81 
82  with open(sys.argv[1]) as f:
83  old_csv_data = f.readlines()
84 
85  with open(sys.argv[2], 'w') as f:
86  f.writelines(old_csv_data)
87  f.write('\n')
88  f.writelines(new_csv_data)
89 
90  print 'Done.'
91 
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34
def get_data
Definition: dataLoader.py:190
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run