ATLAS Offline Software
Classes | Functions
python.RunDependentMCTaskIterator Namespace Reference

Classes

class  taskIterator
 

Functions

def getRunLumiInfoFragment (jobnumber, task, maxEvents, totalEvents, skipEvents, sequentialEventNumbers=False)
 
def getRandomlySampledRunLumiInfoFragment (jobnumber, task, maxEvents, totalEvents, skipEvents, sequentialEventNumbers=False)
 
def getFragment (jobnumber, task, maxEvents)
 
def findPlaceInTask (jobnumber, task, maxEvents)
 
def taskLookupTable (task)
 
def defineSequentialEventNumbers (jobnumber, fragment, totalEvents, skipEvents)
 

Function Documentation

◆ defineSequentialEventNumbers()

def python.RunDependentMCTaskIterator.defineSequentialEventNumbers (   jobnumber,
  fragment,
  totalEvents,
  skipEvents 
)
Calculate sequential event numbers for the defined getFragment.

Definition at line 164 of file RunDependentMCTaskIterator.py.

164 def defineSequentialEventNumbers(jobnumber,fragment,totalEvents,skipEvents):
165  """ Calculate sequential event numbers for the defined getFragment.
166  """
167  new_frag = []
168  evt_nbr = jobnumber * totalEvents + skipEvents
169  for t in fragment:
170  for i in range(t['evts']):
171  evt_nbr += 1
172  new_frag.append({
173  'run': t['run'],
174  'lb': t['lb'],
175  'starttstamp': t['starttstamp'],
176  'evts': 1,
177  'evt_nbr': evt_nbr,
178  'mu': t['mu'],
179  })
180  return new_frag

◆ findPlaceInTask()

def python.RunDependentMCTaskIterator.findPlaceInTask (   jobnumber,
  task,
  maxEvents 
)
Get the 'i'th job in the task, where each job tries to do maxEvents events.
The 'force_new' flag in the LB list ends the task before that LB, ignoring maxEvents.
Returns a taskIterator. Can raise StopIteration, so you should nest in try.

Definition at line 91 of file RunDependentMCTaskIterator.py.

91 def findPlaceInTask(jobnumber,task,maxEvents):
92  """ Get the 'i'th job in the task, where each job tries to do maxEvents events.
93  The 'force_new' flag in the LB list ends the task before that LB, ignoring maxEvents.
94  Returns a taskIterator. Can raise StopIteration, so you should nest in try.
95  """
96  jobnumber = max(int(jobnumber),0)
97  i, jobs = (0,taskIterator(task,maxEvents))
98  while True:
99  if (i == jobnumber): return jobs
100  i += 1
101  next(jobs)
102  #exit by exception
103 #

◆ getFragment()

def python.RunDependentMCTaskIterator.getFragment (   jobnumber,
  task,
  maxEvents 
)
Calculate the specific configuration of the current job in the digi task.

Definition at line 80 of file RunDependentMCTaskIterator.py.

80 def getFragment(jobnumber,task,maxEvents):
81  """ Calculate the specific configuration of the current job in the digi task.
82  """
83  try: tIter = findPlaceInTask(jobnumber,task,maxEvents)
84  except StopIteration:
85  raise IndexError('There are only %i jobs in this task (not %i).' % (len([1 for i in taskIterator(task,maxEvents)]) + 1,jobnumber + 1))
86  try: tIter.__next__()
87  except StopIteration:
88  pass
89  return tIter.donejob
90 #

◆ getRandomlySampledRunLumiInfoFragment()

def python.RunDependentMCTaskIterator.getRandomlySampledRunLumiInfoFragment (   jobnumber,
  task,
  maxEvents,
  totalEvents,
  skipEvents,
  sequentialEventNumbers = False 
)
Calculate the specific configuration of the current job in the digi
task. Sample the mu values randomly.

Definition at line 42 of file RunDependentMCTaskIterator.py.

42 def getRandomlySampledRunLumiInfoFragment(jobnumber,task,maxEvents,totalEvents,skipEvents,sequentialEventNumbers=False):
43  """Calculate the specific configuration of the current job in the digi
44  task. Sample the mu values randomly.
45  """
46  # init random generator
47  random.seed(jobnumber)
48 
49  # generate task inverse
50  lookup_table=taskLookupTable(task)
51  max_index = len(lookup_table) - 1
52 
53  # sample mu profile
54  new_frag = []
55  evt_nbr = jobnumber * totalEvents + skipEvents
56  for i in range(maxEvents):
57  evt_nbr += 1
58 
59  index = lookup_table[random.randint(0, max_index)]
60  t = task[index]
61 
62  item = {
63  'run': t['run'],
64  'lb': t['lb'],
65  'starttstamp': t['starttstamp'],
66  'evts': 1,
67  'mu': t['mu'],
68  }
69 
70  if 'force_new' in t:
71  item['force_new'] = t['force_new']
72 
73  if sequentialEventNumbers:
74  item['evt_nbr'] = evt_nbr
75 
76  new_frag.append(item)
77 
78  return sorted(new_frag, key=itemgetter('run', 'starttstamp'))
79 

◆ getRunLumiInfoFragment()

def python.RunDependentMCTaskIterator.getRunLumiInfoFragment (   jobnumber,
  task,
  maxEvents,
  totalEvents,
  skipEvents,
  sequentialEventNumbers = False 
)
Calculate the specific configuration of the current job in the digi
task. Try to make each fragment utilize the same amount of CPU and
Cache resources.  Exploits the fact that the task when sorted by
mu value will have long finishing pieces near the beginning and
short pieces near the end.  A more even solution is obtained by
pairing chunks of maxEvents/2 from the beginning and end of the
sorted task.

Definition at line 14 of file RunDependentMCTaskIterator.py.

14 def getRunLumiInfoFragment(jobnumber,task,maxEvents,totalEvents,skipEvents,sequentialEventNumbers=False):
15  """Calculate the specific configuration of the current job in the digi
16  task. Try to make each fragment utilize the same amount of CPU and
17  Cache resources. Exploits the fact that the task when sorted by
18  mu value will have long finishing pieces near the beginning and
19  short pieces near the end. A more even solution is obtained by
20  pairing chunks of maxEvents/2 from the beginning and end of the
21  sorted task.
22  """
23  hiMaxEvents,loMaxEvents=0,0
24  if(maxEvents%2==0):
25  hiMaxEvents=loMaxEvents=int(maxEvents/2)
26  else:
27  hiMaxEvents=int((maxEvents-1)/2)
28  loMaxEvents=int((maxEvents+1)/2)
29  hi_mu_frag=[]
30  lo_mu_frag=[]
31  if hiMaxEvents > 0:
32  hi_mu_frag=getFragment(jobnumber,sorted(task,key=lambda job: job['mu'],reverse=True),hiMaxEvents)
33  if loMaxEvents > 0:
34  lo_mu_frag=getFragment(jobnumber,sorted(task,key=lambda job: job['mu']),loMaxEvents)
35 
36  fragment=sorted(sum([hi_mu_frag,lo_mu_frag],[]),key=lambda job: job['run'])
37  if sequentialEventNumbers:
38  return defineSequentialEventNumbers(jobnumber,fragment,totalEvents,skipEvents)
39  else:
40  return fragment
41 

◆ taskLookupTable()

def python.RunDependentMCTaskIterator.taskLookupTable (   task)
Generate task lookup table

Definition at line 155 of file RunDependentMCTaskIterator.py.

155 def taskLookupTable(task):
156  """ Generate task lookup table
157  """
158  table = []
159  for i, item in enumerate(task):
160  for k in range(item['evts']):
161  table.append(i)
162  return table
163 
python.RunDependentMCTaskIterator.findPlaceInTask
def findPlaceInTask(jobnumber, task, maxEvents)
Definition: RunDependentMCTaskIterator.py:91
python.RunDependentMCTaskIterator.taskLookupTable
def taskLookupTable(task)
Definition: RunDependentMCTaskIterator.py:155
max
#define max(a, b)
Definition: cfImp.cxx:41
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.RunDependentMCTaskIterator.getFragment
def getFragment(jobnumber, task, maxEvents)
Definition: RunDependentMCTaskIterator.py:80
convertTimingResiduals.sum
sum
Definition: convertTimingResiduals.py:55
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
python.RunDependentMCTaskIterator.defineSequentialEventNumbers
def defineSequentialEventNumbers(jobnumber, fragment, totalEvents, skipEvents)
Definition: RunDependentMCTaskIterator.py:164
python.RunDependentMCTaskIterator.getRandomlySampledRunLumiInfoFragment
def getRandomlySampledRunLumiInfoFragment(jobnumber, task, maxEvents, totalEvents, skipEvents, sequentialEventNumbers=False)
Definition: RunDependentMCTaskIterator.py:42
if
if(febId1==febId2)
Definition: LArRodBlockPhysicsV0.cxx:569
python.RunDependentMCTaskIterator.getRunLumiInfoFragment
def getRunLumiInfoFragment(jobnumber, task, maxEvents, totalEvents, skipEvents, sequentialEventNumbers=False)
Definition: RunDependentMCTaskIterator.py:14