Created on 28 May 2018
@author: kleinwrt
def alignment.constraints_generator.gen_constraints |
( |
|
constraint_sets, |
|
|
|
timedep_config = None , |
|
|
|
global_tags = None , |
|
|
|
init_event = None |
|
) |
| |
Generate "event files" from timedep config and run over them to collect constraint data
and write it to files.
This is a bit tricky. I did not found a way to run basf2 over just a specified list of events
other than generating the files with metadata for event and then running over the files.
This uses unning basf2 multiple times in one script - seems to work despite the warnings - but only
for the generation of "event files"
Parameters
----------
constraint_sets : list (alignment.Constraints)
List of sets of constraints
timedep_config : list(tuple(list(int), list(tuple(int, int, int))))
Time-depence configuration.
Each list item is 2-tuple with list of parameter numbers (use alignment.parameters to get them) and
the (event, run, exp) numbers at which values of these parameters can change.
global_tags : list (str)
List of global tag names and/or (absolute) file paths to local databases
init_event : tuple( int, int, int)
Event (event, run, exp) at which to initialize time-INdependent constraints
Definition at line 110 of file constraints_generator.py.
110 def gen_constraints(constraint_sets, timedep_config=None, global_tags=None, init_event=None):
112 Generate "event files" from timedep config and run over them to collect constraint data
113 and write it to files.
115 This is a bit tricky. I did not found a way to run basf2 over just a specified list of events
116 other than generating the files with metadata for event and then running over the files.
117 This uses unning basf2 multiple times in one script - seems to work despite the warnings - but only
118 for the generation of "event files"
122 constraint_sets : list (alignment.Constraints)
123 List of sets of constraints
124 timedep_config : list(tuple(list(int), list(tuple(int, int, int))))
125 Time-depence configuration.
126 Each list item is 2-tuple with list of parameter numbers (use alignment.parameters to get them) and
127 the (event, run, exp) numbers at which values of these parameters can change.
128 global_tags : list (str)
129 List of global tag names and/or (absolute) file paths to local databases
130 init_event : tuple( int, int, int)
131 Event (event, run, exp) at which to initialize time-INdependent constraints
134 if timedep_config
is None:
137 if global_tags
is None:
138 global_tags = [tag
for tag
in b2.conditions.default_globaltags]
141 for (labels, events_)
in timedep_config:
142 events += [event
for event
in events_]
144 if not len(timedep_config):
145 if init_event
is None:
146 init_event = (0, 0, 0)
147 events = [init_event]
149 events = [(exp, run, ev)
for (ev, run, exp)
in events]
150 events = sorted(list(set(events)))
151 events = [(ev_, run_, exp_)
for (exp_, run_, ev_)
in events]
153 fileName =
'TimedepConfigEvent_exp{}run{}ev{}.root'
156 print(
'Global tags:')
158 print(
'Global tags reversed (this will be used for b2.conditions.override_globaltags(...)):')
159 print([tag
for tag
in reversed(global_tags)])
161 for tag
in [tag
for tag
in reversed(global_tags)]:
162 if os.path.exists(tag):
163 b2.conditions.append_testing_payloads(os.path.abspath(tag))
165 b2.conditions.append_globaltag(tag)
167 for index, event
in enumerate(events):
171 path = b2.create_path()
172 path.add_module(
"EventInfoSetter",
177 path.add_module(
'Progress')
178 this_filename = fileName.format(exp, run, ev)
179 path.add_module(
'RootOutput', outputFileName=this_filename, ignoreCommandLineOverride=
True)
180 files.append(this_filename)
188 path = b2.create_path()
189 path.add_module(
"RootInput", inputFileNames=files, ignoreCommandLineOverride=
True)
190 path.add_module(
'HistoManager')
191 path.add_module(
'Progress')
192 path.add_module(
'Gearbox')
193 path.add_module(
'Geometry')
195 collector = path.add_module(
'MillepedeCollector',
196 timedepConfig=timedep_config)
198 constraint_files = []
199 for constraint_set
in constraint_sets:
200 constraint_set.configure_collector(collector)
201 constraint_files.append(constraint_set.filename)
202 path.add_module(ConstraintsGenerator(constraint_set))
207 return [os.path.abspath(file)
for file
in constraint_files]
def alignment.constraints_generator.save_config |
( |
|
constraint_sets, |
|
|
|
timedep_config = None , |
|
|
|
global_tags = None , |
|
|
|
init_event = None |
|
) |
| |
Save constraints configuration to a file (using pickle)
Parameters
----------
constraint_sets : list (alignment.Constraints)
List of sets of constraints
timedep_config : list(tuple(list(int), list(tuple(int, int, int))))
Time-depence configuration.
Each list item is 2-tuple with list of parameter numbers (use alignment.parameters to get them) and
the (event, run, exp) numbers at which values of these parameters can change.
global_tags : list (str)
List of global tag names and/or (absolute) file paths to local databases
init_event : tuple( int, int, int)
Event (event, run, exp) at which to initialize time-INdependent constraints
Definition at line 65 of file constraints_generator.py.