HPS-MC
 
All Classes Namespaces Files Functions Variables Pages
Loading...
Searching...
No Matches
tools.py
Go to the documentation of this file.
1"""! Tools that can be used in HPSMC jobs."""
2
3import os
4import gzip
5import shutil
6import subprocess
7import tarfile
8
9from subprocess import PIPE
10
11from hpsmc.component import Component
12import hpsmc.func as func
13
14
16 """!
17 Run the SLIC Geant4 simulation.
18
19 Optional parameters are: **nevents**, **macros**, **run_number**, **disable_particle_table** \n
20 Required parameters are: **detector** \n
21 Required configurations are: **slic_dir**, **detector_dir**
22 """
23
24 def __init__(self, **kwargs):
25
26 self.macros = []
27
28 self.run_number = None
29
30 self.detector_dir = None
31
35
36 Component.__init__(self,
37 name='slic',
38 command='slic',
39 output_ext='.slcio',
40 **kwargs)
41
42 def cmd_args(self):
43 """!
44 Setup command arguments.
45 @return list of arguments
46 """
47 if not len(self.input_files()):
48 raise Exception("No inputs given for SLIC.")
49
50 args = ["-g", self.__detector_file(),
51 # "-i", self.input_files()[0],
52 "-o", self.output_files()[0],
53 "-d%s" % str(self.seedseed)]
54
55 if self.neventsnevents is not None:
56 args.extend(["-r", str(self.neventsnevents)])
57
58 if self.run_number is not None:
59 args.extend(["-m", "run_number.mac"])
60
61 if not self.disable_particle_table:
62 tbl = self.__particle_tbl()
63 if os.path.exists(tbl):
64 args.extend(["-P", tbl])
65 else:
66 raise Exception('SLIC particle.tbl does not exist: %s' % tbl)
67
68 if len(self.macros):
69 # args = []
70 for macro in self.macros:
71 if macro == "run_number.mac":
72 raise Exception("Macro name '%s' is not allowed." % macro)
73 if not os.path.isabs(macro):
74 raise Exception("Macro '%s' is not an absolute path." % macro)
75 args.extend(["-m", macro])
76 else:
77 args.extend(["-i", self.input_files()[0]])
78
79 return args
80
81 def __detector_file(self):
82 """! Return path to detector file."""
83 return os.path.join(self.detector_dir, self.detector, self.detector + ".lcdd")
84
85 def __particle_tbl(self):
86 """! Return path to particle table."""
87 return os.path.join(self.slic_dir, "share", "particle.tbl")
88
89 def config(self, parser):
90 """! Configure SLIC component."""
91 super().config(parser)
92
93 if self.detector_dir is None:
94 self.detector_dir = "{}/share/detectors".format(self.hpsmc_dir)
95 if not os.path.isdir(self.detector_dir):
96 raise Exception('Failed to find valid detector_dir')
97 self.logger.debug("Using detector_dir from install: {}".format(self.detector_dir))
98
99 def setup(self):
100 """! Setup SLIC component."""
101 if not os.path.exists(self.slic_dir):
102 raise Exception("slic_dir does not exist: %s" % self.slic_dir)
103
104 self.env_script = self.slic_dir + os.sep + "bin" + os.sep + "slic-env.sh"
105 if not os.path.exists(self.env_script):
106 raise Exception('SLIC setup script does not exist: %s' % self.namename)
107
108 if self.run_number is not None:
109 run_number_cmd = "/lcio/runNumber %d" % self.run_number
110 run_number_mac = open("run_number.mac", 'w')
111 run_number_mac.write(run_number_cmd)
112 run_number_mac.close()
113
115 """!
116 Return list of optional parameters.
117
118 Optional parameters are: **nevents**, **macros**, **run_number**
119 @return list of optional parameters
120 """
121 return ['nevents', 'macros', 'run_number', 'disable_particle_table']
122
124 """!
125 Return list of required parameters.
126
127 Required parameters are: **detector**
128 @return list of required parameters
129 """
130 return ['detector']
131
133 """!
134 Return list of required configurations.
135
136 Required configurations are: **slic_dir**, **detector_dir**
137 @return list of required configurations
138 """
139 return ['slic_dir', 'detector_dir']
140
141 def execute(self, log_out, log_err):
142 """!
143 Execute SLIC component.
144
145 Component is executed by creating command line input
146 from command and command arguments.
147 @return return code of process
148 """
149 # SLIC needs to be run inside bash as the Geant4 setup script is a piece of #@$@#$.
150 cl = 'bash -c ". %s && %s %s"' % (self.env_script, self.command, ' '.join(self.cmd_argscmd_args()))
151
152 # self.logger.info("Executing '%s' with command: %s" % (self.name, cl))
153 proc = subprocess.Popen(cl, shell=True, stdout=log_out, stderr=log_err)
154 proc.communicate()
155 proc.wait()
156
157 return proc.returncode
158
159
160
162 """!
163 Copy the SQLite database file to the desired location.
164 """
165
166 def __init__(self, **kwargs):
167 """!
168 Initialize SQLiteProc to copy the SQLite file.
169 """
170 self.source_file = kwargs.get('source_file')
171 self.destination_file = kwargs.get('destination_file')
172
173 # Set the Local SQLite Snapshot Location
174 if self.source_file is not None:
175 self.logger.debug("Setting SQLite local copy source file from config: %s" + self.source_file)
176 args.append(self.source_file)
177 if self.destination_file is not None:
178 self.logger.debug('Setting Job Destination file from config: %s' % self.destination_file)
179 args.append('-Dorg.hps.conditions.url=%s' % self.destination_file)
180
181 # Ensure to call the parent constructor properly
182 Component.__init__(self, name='sqlite_file_copy', **kwargs)
183
184
185 def cmd_args(self):
186 """!
187 Return dummy command arguments to satisfy the parent class.
188 """
189 cmd_args = ["(no-command-needed)"]
190
191 if not all(isinstance(arg, str) for arg in cmd_args):
192 raise ValueError("All arguments must be strings.")
193 # return ["(no-command-needed)"]
194 return ['--source', self.source_file, '--destination', self.destination_file]
195
196 def execute(self, log_out, log_err):
197 """!
198 Execute the file copy operation.
199 """
200
201 try:
202 # Copy the file
203
204 self.logger.info(f"Copying file from {self.source_file} to {self.destination_file}")
205 shutil.copy(self.source_file, self.destination_file)
206
207 # Log success
208 self.logger.info(f"Successfully copied file to {self.destination_file}")
209
210 return 0 # Success code
211
212 except Exception as e:
213 self.logger.error(f"Error during file copy: {e}")
214 return 1 # Error code
215
216
218 """!
219 Run the hps-java JobManager class.
220
221 Input files have slcio format.
222
223 Required parameters are: **steering_files** \n
224 Optional parameters are: **detector**, **run_number**, **defs**
225 """
226
227 def __init__(self, steering=None, **kwargs):
228
230 self.run_number = None
231
232 self.neventsnevents = None
233
234 self.detector = None
235
237
238 self.defs = None
239
240 self.java_args = None
241
243
244 self.lcsim_cache_dir = None
245
246 self.conditions_user = None
247
249
250 self.conditions_url = None
251
252 self.steering = steering
253
255
256 if 'overlay_file' in kwargs:
257 self.overlay_file = kwargs['overlay_file']
258 else:
259 self.overlay_file = None
260
261 Component.__init__(self,
262 name='job_manager',
263 command='java',
264 description='HPS Java Job Manager',
265 output_ext='.slcio',
266 **kwargs)
267
268 # Automatically append steering file key to output file name
269 if self.append_tokappend_tok is None:
271 self.logger.debug("Append token for '%s' automatically set to '%s' from steering key." % (self.namename, self.append_tokappend_tok))
272
273 def config(self, parser):
274 """! Configure JobManager component."""
275 super().config(parser)
276 # if installed these are set in the environment script...
277 if self.hps_java_bin_jar is None:
278 if os.getenv('HPS_JAVA_BIN_JAR', None) is not None:
279 self.hps_java_bin_jar = os.getenv('HPS_JAVA_BIN_JAR', None)
280 self.logger.debug('Set HPS_JAVA_BIN_JAR from environment: {}'.format(self.hps_java_bin_jar))
281 else:
282 raise Exception('hps_java_bin_jar not set in environment or config file!')
283 if self.conditions_url is None:
284 if os.getenv("CONDITIONS_URL", None) is not None:
285 self.conditions_url = os.getenv("CONDITIONS_URL", None)
286 self.logger.debug('Set CONDITIONS_URL from environment: {}'.format(self.hps_java_bin_jar))
287
289 """!
290 Return list of required configurations.
291
292 Required configurations are: **hps_java_bin_jar**
293 @retun list of required configurations.
294 """
295 return ['hps_java_bin_jar']
296
297 def setup(self):
298 """! Setup JobManager component."""
299 if not len(self.input_files()):
300 raise Exception("No inputs provided to hps-java.")
301
302 if self.steering not in self.steering_files:
303 raise Exception("Steering '%s' not found in: %s" % (self.steering, self.steering_files))
305
306 def cmd_args(self):
307 """!
308 Setup command arguments.
309 @return list of arguments
310 """
311 args = []
312
313 if self.java_args is not None:
314 self.logger.debug('Setting java_args from config: %s' % self.java_args)
315 args.append(self.java_args)
316
317 if self.logging_config_file is not None:
318 self.logger.debug('Setting logging_config_file from config: %s' % self.logging_config_file)
319 args.append('-Djava.util.logging.config.file=%s' % self.logging_config_file)
320
321 if self.lcsim_cache_dir is not None:
322 self.logger.debug('Setting lcsim_cache_dir from config: %s' % self.lcsim_cache_dir)
323 args.append('-Dorg.lcsim.cacheDir=%s' % self.lcsim_cache_dir)
324
325 if self.conditions_user is not None:
326 self.logger.debug('Setting conditions_user from config: %s' % self.conditions_user)
327 args.append('-Dorg.hps.conditions.user=%s' % self.conditions_user)
328 if self.conditions_password is not None:
329 self.logger.debug('Setting conditions_password from config (not shown)')
330 args.append('-Dorg.hps.conditions.password=%s' % self.conditions_password)
331 if self.conditions_url is not None:
332 self.logger.debug('Setting conditions_url from config: %s' % self.conditions_url)
333 args.append('-Dorg.hps.conditions.url=%s' % self.conditions_url)
334
335 args.append("-jar")
336 args.append(self.hps_java_bin_jar)
337
338
339 if self.event_print_interval is not None:
340 args.append("-e")
341 args.append(str(self.event_print_interval))
342
343 if self.run_number is not None:
344 args.append("-R")
345 args.append(str(self.run_number))
346
347 if self.detector is not None:
348 args.append("-d")
349 args.append(self.detector)
350
351 if len(self.output_files()):
352 args.append("-D")
353 args.append("outputFile=" + os.path.splitext(self.output_files()[0])[0])
354
355 if self.defs:
356 for k, v in self.defs.items():
357 args.append("-D")
358 args.append(k + "=" + str(v))
359
360 if not os.path.isfile(self.steering_file):
361 args.append("-r")
362 self.logger.debug("Steering does not exist at '%s' so assuming it is a resource." % self.steering_file)
363 else:
364 if not os.path.isabs(self.steering_file):
365 raise Exception('Steering looks like a file but is not an abs path: %s' % self.steering_file)
366 args.append(self.steering_file)
367
368 if self.neventsnevents is not None:
369 args.append("-n")
370 args.append(str(self.neventsnevents))
371
372 for input_file in self.input_files():
373 args.append("-i")
374 args.append(input_file)
375
376 if self.overlay_file is not None:
377 args.append("-D")
378 args.append("overlayFile=" + os.path.splitext(self.overlay_file)[0])
379
380 return args
381
383 """!
384 Return list of required parameters.
385
386 Required parameters are: **steering_files**
387 @return list of required parameters
388 """
389 return ['steering_files']
390
392 """!
393 Return list of optional parameters.
394
395 Optional parameters are: **detector**, **run_number**, **defs**
396 @return list of optional parameters
397 """
398 return ['detector', 'run_number', 'defs', 'nevents']
399
400
402 """!
403 Run the hpstr analysis tool.
404
405 Required parameters are: **config_files** \n
406 Optional parameters are: **year**, **is_data**, **nevents** \n
407 Required configs are: **hpstr_install_dir**, **hpstr_base**
408 """
409
410 def __init__(self, cfg=None, is_data=0, year=None, tracking=None, **kwargs):
411
412 self.cfg = cfg
413
414 self.is_data = is_data
415
416 self.year = year
417
418 self.tracking = tracking
419
421 self.hpstr_base = None
422
423 Component.__init__(self,
424 name='hpstr',
425 command='hpstr',
426 **kwargs)
427
428 def setup(self):
429 """! Setup HPSTR component."""
430 if not os.path.exists(self.hpstr_install_dir):
431 raise Exception('hpstr_install_dir does not exist: %s' % self.hpstr_install_dir)
432 self.env_script = self.hpstr_install_dir + os.sep + "bin" + os.sep + "hpstr-env.sh"
433
434 # The config file to use is read from a dict in the JSON parameters.
435 if self.cfg not in self.config_files:
436 raise Exception("Config '%s' was not found in: %s" % (self.cfg, self.config_files))
437 config_file = self.config_files[self.cfg]
438 if len(os.path.dirname(config_file)):
439 # If there is a directory name then we expect an absolute path not in the hpstr dir.
440 if os.path.isabs(config_file):
441 self.cfg_path = config_file
442 else:
443 # The config must be an abs path.
444 raise Exception('The config has a directory but is not an abs path: %s' % self.cfg)
445 else:
446 # Assume the cfg file is within the hpstr base dir.
447 self.cfg_path = os.path.join(self.hpstr_base, "processors", "config", config_file)
448 self.logger.debug('Set config path: %s' % self.cfg_path)
449
450 # For ROOT output, automatically append the cfg key from the job params.
451 if os.path.splitext(self.input_files()[0])[1] == '.root':
453 self.logger.debug('Automatically appending token to output file: %s' % self.append_tokappend_tok)
454
456 """!
457 Return list of required parameters.
458
459 Required parameters are: **config_files**
460 @return list of required parameters
461 """
462 return ['config_files']
463
465 """!
466 Return list of optional parameters.
467
468 Optional parameters are: **year**, **is_data**, **nevents**
469 @return list of optional parameters
470 """
471 return ['year', 'is_data', 'nevents', 'tracking']
472
474 """!
475 Return list of required configs.
476
477 Required configs are: **hpstr_install_dir**, **hpstr_base**
478 @return list of required configs
479 """
480 return ['hpstr_install_dir', 'hpstr_base']
481
482 def cmd_args(self):
483 """!
484 Setup command arguments.
485 @return list of arguments
486 """
487 args = [self.cfg_path,
488 "-t", str(self.is_data),
489 "-i", self.input_files()[0],
490 "-o", self.output_filesoutput_files()[0]]
491 if self.neventsnevents is not None:
492 args.extend(["-n", str(self.neventsnevents)])
493 if self.year is not None:
494 args.extend(["-y", str(self.year)])
495 if self.tracking is not None:
496 args.extend(["-w", str(self.tracking)])
497 return args
498
499 def output_files(self):
500 """! Adjust names of output files."""
501 f, ext = os.path.splitext(self.input_files()[0])
502 if '.slcio' in ext:
503 return ['%s.root' % f]
504 else:
505 if not self.append_tokappend_tok:
506 self.append_tokappend_tok = self.cfg
507 return ['%s_%s.root' % (f, self.append_tokappend_tok)]
508
509 def execute(self, log_out, log_err):
510 """! Execute HPSTR component."""
511 args = self.cmd_argscmd_args()
512 cl = 'bash -c ". %s && %s %s"' % (self.env_script, self.command,
513 ' '.join(self.cmd_argscmd_args()))
514
515 self.logger.debug("Executing '%s' with command: %s" % (self.namename, cl))
516 proc = subprocess.Popen(cl, shell=True, stdout=log_out, stderr=log_err)
517 proc.communicate()
518 proc.wait()
519
520 return proc.returncode
521
522
523
524
526 """!
527 Generic class for StdHep tools.
528 """
529
530
531 seed_names = ['beam_coords',
532 'beam_coords_old',
533 'lhe_tridents',
534 'lhe_tridents_displacetime',
535 'lhe_tridents_displaceuni',
536 'merge_poisson',
537 'mix_signal',
538 'random_sample']
539
540 def __init__(self, name=None, **kwargs):
541
542 Component.__init__(self,
543 name=name,
544 command="stdhep_" + name,
545 **kwargs)
546
547 def cmd_args(self):
548 """!
549 Setup command arguments.
550 @return list of arguments
551 """
552 args = []
553
554 if self.name in StdHepTool.seed_names:
555 args.extend(["-s", str(self.seedseed)])
556
557 if len(self.output_files()) == 1:
558 args.insert(0, self.output_files()[0])
559 elif len(self.output_files()) > 1:
560 raise Exception("Too many outputs specified for StdHepTool.")
561 else:
562 raise Exception("No outputs specified for StdHepTool.")
563
564 if len(self.input_files()):
565 for i in self.inputs[::-1]:
566 args.insert(0, i)
567 else:
568 raise Exception("No inputs specified for StdHepTool.")
569
570 return args
571
572
574 """!
575 Transform StdHep events into beam coordinates.
576
577 Optional parameters are: **beam_sigma_x**, **beam_sigma_y**, **beam_rot_x**,
578 **beam_rot_y**, **beam_rot_z**, **target_x**, **target_y**, **target_z**
579 """
580
581 def __init__(self, **kwargs):
582
584 self.beam_sigma_x = None
585
586 self.beam_sigma_y = None
587
588 self.target_x = None
589
590 self.target_y = None
591
592 self.target_z = None
593
594 self.beam_rot_x = None
595
596 self.beam_rot_y = None
597
598 self.beam_rot_z = None
599
600 StdHepTool.__init__(self,
601 name='beam_coords',
602 append_tok='rot',
603 **kwargs)
604
605 def cmd_args(self):
606 """!
607 Setup command arguments.
608 @return list of arguments
609 """
610 args = StdHepTool.cmd_args(self)
611
612 if self.beam_sigma_x is not None:
613 args.extend(['-x', str(self.beam_sigma_x)])
614 if self.beam_sigma_y is not None:
615 args.extend(['-y', str(self.beam_sigma_y)])
616
617 if self.beam_rot_x is not None:
618 args.extend(['-u', str(self.beam_rot_x)])
619 if self.beam_rot_y is not None:
620 args.extend(['-v', str(self.beam_rot_y)])
621 if self.beam_rot_z is not None:
622 args.extend(['-w', str(self.beam_rot_z)])
623
624 if self.target_x is not None:
625 args.extend(['-X', str(self.target_x)])
626 if self.target_y is not None:
627 args.extend(['-Y', str(self.target_y)])
628 if self.target_z is not None:
629 args.extend(['-Z', str(self.target_z)])
630
631 return args
632
634 """!
635 Return list of optional parameters.
636
637 Optional parameters are: **beam_sigma_x**, **beam_sigma_y**, **beam_rot_x**,
638 **beam_rot_y**, **beam_rot_z**, **target_x**, **target_y**, **target_z**
639 @return list of optional parameters
640 """
641 return ['beam_sigma_x', 'beam_sigma_y', 'beam_rot_x',
642 'beam_rot_y', 'beam_rot_z',
643 'target_x', 'target_y', 'target_z']
644
645
647 """!
648 Randomly sample StdHep events into a new file.
649
650 Optional parameters are: **nevents**, **mu**
651 """
652
653 def __init__(self, **kwargs):
654 StdHepTool.__init__(self,
655 name='random_sample',
656 append_tok='sampled',
657 **kwargs)
658
659 self.mu = None
660
661 def cmd_args(self):
662 """!
663 Setup command arguments.
664 @return list of arguments
665 """
666 args = []
667
668 if self.name in StdHepTool.seed_names:
669 args.extend(["-s", str(self.seedseedseed)])
670
671 args.extend(["-N", str(1)])
672
673 if self.neventsnevents is not None:
674 args.extend(["-n", str(self.neventsnevents)])
675
676 if self.mu is not None:
677 args.extend(["-m", str(self.mu)])
678
679 if len(self.output_files()) == 1:
680 # only use file name, not extension because extension is added by tool
681 args.insert(0, os.path.splitext(self.output_files()[0])[0])
682 elif len(self.output_files()) > 1:
683 raise Exception("Too many outputs specified for RandomSample.")
684 else:
685 raise Exception("No outputs specified for RandomSample.")
686
687 if len(self.input_files()):
688 for i in self.inputs[::-1]:
689 args.insert(0, i)
690 else:
691 raise Exception("No inputs were provided.")
692
693 return args
694
696 """!
697 Return list of optional parameters.
698
699 Optional parameters are: **nevents**, **mu**
700 @return list of optional parameters
701 """
702 return ['nevents', 'mu']
703
704 def execute(self, log_out, log_err):
705 """! Execute RandomSample component"""
706 returncode = Component.execute(self, log_out, log_err)
707
708 # Move file to proper output file location.
709 src = '%s_1.stdhep' % os.path.splitext(self.output_files()[0])[0]
710 dest = '%s.stdhep' % os.path.splitext(self.output_files()[0])[0]
711 self.logger.debug("Moving '%s' to '%s'" % (src, dest))
712 shutil.move(src, dest)
713
714 return returncode
715
716
718 """!
719 Convert LHE files to StdHep, displacing the time by given ctau.
720
721 Optional parameters are: **ctau**
722 """
723
724 def __init__(self, **kwargs):
725
726 self.ctau = None
727 StdHepTool.__init__(self,
728 name='lhe_tridents_displacetime',
729 output_ext='.stdhep',
730 **kwargs)
731
732 def cmd_args(self):
733 """!
734 Setup command arguments.
735 @return list of arguments
736 """
737 args = StdHepTool.cmd_args(self)
738 if self.ctau is not None:
739 args.extend(["-l", str(self.ctau)])
740 return args
741
743 """!
744 Return list of optional parameters.
745
746 Optional parameters are: **ctau**
747 @return list of optional parameters
748 """
749 return ['ctau']
750
751
753 """!
754 Convert LHE files to StdHep, displacing the time by given ctau.
755
756 Optional parameters are: **ctau**
757 """
758
759 def __init__(self, **kwargs):
760
761 self.ctau = None
762 StdHepTool.__init__(self,
763 name='lhe_tridents_displaceuni',
764 output_ext='.stdhep',
765 **kwargs)
766
767 def cmd_args(self):
768 """!
769 Setup command arguments.
770 @return list of arguments
771 """
772 args = StdHepTool.cmd_args(self)
773 if self.ctau is not None:
774 args.extend(["-l", str(self.ctau)])
775 return args
776
778 """!
779 Return list of optional parameters.
780
781 Optional parameters are: **ctau**
782 @return list of optional parameters
783 """
784 return ['ctau']
785
786
788 """!
789 Add mother particles for physics samples.
790 """
791
792 def __init__(self, **kwargs):
793 StdHepTool.__init__(self,
794 name='add_mother',
795 append_tok='mom',
796 **kwargs)
797
798
800 """! Add full truth mother particles for physics samples"""
801
802 def __init__(self, **kwargs):
803 StdHepTool.__init__(self,
804 'add_mother_full_truth',
805 append_tok='mom_full_truth',
806 **kwargs)
807 if len(self.inputsinputs) != 2:
808 raise Exception("Must have 2 input files: a stdhep file and a lhe file in order")
810 base, ext = os.path.splitext(self.input_file_1)
811 if ext != '.stdhep':
812 raise Exception("The first input file must be a stdhep file")
814 base, ext = os.path.splitext(self.input_file_2)
815 if ext != '.lhe':
816 raise Exception("The second input file must be a lhe file")
817
818 def cmd_args(self):
819 """!
820 Setup command arguments.
821 @return list of arguments
822 """
823 return super().cmd_args()
824
825
827 """!
828 Merge StdHep files, applying poisson sampling.
829
830 Required parameters are: **target_thickness**, **num_electrons**
831 """
832
833 def __init__(self, xsec=0, **kwargs):
834
835 self.xsec = xsec
836
838
839 self.num_electrons = None
840
841 StdHepTool.__init__(self,
842 name='merge_poisson',
843 append_tok='sampled',
844 **kwargs)
845
846 def setup(self):
847 """! Setup MergePoisson component."""
848 if self.xsec > 0:
849 self.mu = func.lint(self.target_thickness, self.num_electrons) * self.xsec
850 else:
851 raise Exception("Cross section is missing.")
852 self.logger.info("mu is %f", self.mu)
853
855 """!
856 Return list of required parameters.
857
858 Required parameters are: **target_thickness**, **num_electrons**
859 @return list of required parameters
860 """
861 return ['target_thickness', 'num_electrons']
862
863 def cmd_args(self):
864 """!
865 Setup command arguments.
866 @return list of arguments
867 """
868 args = []
869 if self.name in StdHepTool.seed_names:
870 args.extend(["-s", str(self.seedseedseed)])
871
872 args.extend(["-m", str(self.mu), "-N", str(1), "-n", str(self.neventsnevents)])
873
874 if len(self.output_files()) == 1:
875 # only use file name, not extension because extension is added by tool
876 args.insert(0, os.path.splitext(self.output_files()[0])[0])
877 elif len(self.output_files()) > 1:
878 raise Exception("Too many outputs specified for MergePoisson.")
879 else:
880 raise Exception("No outputs specified for MergePoisson.")
881
882 if len(self.input_files()):
883 for i in self.inputs[::-1]:
884 args.insert(0, i)
885 else:
886 raise Exception("No inputs were provided.")
887
888 return args
889
890 def execute(self, log_out, log_err):
891 """! Execute MergePoisson component."""
892 returncode = Component.execute(self, log_out, log_err)
893
894 # Move file from tool to proper output file location.
895 src = '%s_1.stdhep' % os.path.splitext(self.output_files()[0])[0]
896 dest = '%s.stdhep' % os.path.splitext(self.output_files()[0])[0]
897 self.logger.debug("Moving '%s' to '%s'" % (src, dest))
898 shutil.move(src, dest)
899
900 return returncode
901
902
904 """!
905 Merge StdHep files.
906
907 Optional parameters are: none \n
908 Required parameters are: none
909 """
910
911 def __init__(self, **kwargs):
912 StdHepTool.__init__(self,
913 name='merge_files',
914 **kwargs)
915
917 """!
918 Return list of optional parameters.
919
920 Optional parameters are: none
921 @return list of optional parameters
922 """
923 return []
924
926 """!
927 Return list of required parameters.
928
929 Required parameters are: none
930 @return list of required parameters
931 """
932 return []
933
934
936 """!
937 Count number of events in a StdHep file.
938 """
939
940 def __init__(self, **kwargs):
941 Component.__init__(self,
942 name='stdhep_count',
943 command='stdhep_count.sh',
944 **kwargs)
945
946 def cmd_args(self):
947 """!
948 Setup command arguments.
949 @return list of arguments
950 """
951
952 return [self.input_files()[0]]
953
954 def execute(self, log_out, log_err):
955 """! Execute StdHepCount component."""
956 cl = [self.command]
957 cl.extend(self.cmd_argscmd_args())
958 proc = subprocess.Popen(cl, stdout=PIPE)
959 (output, err) = proc.communicate()
960
961 nevents = int(output.split()[1])
962 print("StdHep file '%s' has %d events." % (self.input_files()[0], nevents))
963
964 return proc.returncode
965
966
968 """!
969 Generic base class for Java based tools.
970 """
971
972 def __init__(self, name, java_class, **kwargs):
973
974 self.java_class = java_class
975
976 self.java_args = None
977
978 self.conditions_url = None
979 Component.__init__(self,
980 name,
981 "java",
982 **kwargs)
983
985 """!
986 Return list of required config.
987
988 Required config are: **hps_java_bin_jar**
989 @return list of required config
990 """
991 return ['hps_java_bin_jar']
992
993 def cmd_args(self):
994 """!
995 Setup command arguments.
996 @return list of arguments
997 """
998 args = []
999 if self.java_args is not None:
1000 self.logger.debug("Setting java_args from config: %s" + self.java_args)
1001 args.append(self.java_args)
1002 if self.conditions_url is not None:
1003 self.logger.debug('Setting conditions_url from config: %s' % self.conditions_url)
1004 args.append('-Dorg.hps.conditions.url=%s' % self.conditions_url)
1005 args.append("-cp")
1006 args.append(self.hps_java_bin_jar)
1007 args.append(self.java_class)
1008 return args
1009
1010 def config(self, parser):
1011 super().config(parser)
1012
1013
1015 """!
1016 Convert EVIO events to LCIO using the hps-java EvioToLcio command line tool.
1017
1018 Input files have evio format (format used by DAQ system).
1019
1020 Required parameters are: **detector**, **steering_files** \n
1021 Optional parameters are: **run_number**, **skip_events**, **nevents**, **event_print_interval**
1022 """
1023
1024 def __init__(self, steering=None, **kwargs):
1025
1026 self.detector = None
1027
1028 self.run_number = None
1029
1030 self.skip_events = None
1031
1033
1034 self.steering = steering
1035
1036 JavaTool.__init__(self,
1037 name='evio_to_lcio',
1038 java_class='org.hps.evio.EvioToLcio',
1039 output_ext='.slcio',
1040 **kwargs)
1041
1043 """!
1044 Return list of required parameters.
1045
1046 Required parameters are: **detector**, **steering_files**
1047 @return list of required parameters
1048 """
1049 return ['detector', 'steering_files']
1050
1052 """!
1053 Return list of optional parameters.
1054
1055 Optional parameters are: **run_number**, **skip_events**, **nevents**, **event_print_interval**
1056 @return list of optional parameters
1057 """
1058 return ['run_number', 'skip_events', 'nevents', 'event_print_interval']
1059
1060 def setup(self):
1061 """! Setup EvioToLcio component."""
1062 super().setup()
1063 if self.steering not in self.steering_files:
1064 raise Exception("Steering '%s' not found in: %s" % (self.steering, self.steering_files))
1066
1067 def cmd_args(self):
1068 """!
1069 Setup command arguments.
1070 @return list of arguments
1071 """
1072 args = JavaTool.cmd_args(self)
1073 if not len(self.output_files()):
1074 raise Exception('No output files were provided.')
1075 output_file = self.output_files()[0]
1076 args.append('-DoutputFile=%s' % os.path.splitext(output_file)[0])
1077 args.extend(['-d', self.detector])
1078 if self.run_number is not None:
1079 args.extend(['-R', str(self.run_number)])
1080 if self.skip_events is not None:
1081 args.extend(['-s', str(self.skip_events)])
1082
1083 if not os.path.isfile(self.steering_file):
1084 args.append('-r')
1085 self.logger.debug("Steering does not exist at '%s' so assuming it is a resource." % self.steering_file)
1086 else:
1087 if not os.path.isabs(self.steering_file):
1088 raise Exception("Steering looks like a file but is not an abs path: %s" % self.steering_file)
1089 args.extend(['-x', self.steering_file])
1090
1091 if self.neventsnevents is not None:
1092 args.extend(['-n', str(self.neventsnevents)])
1093
1094 args.append('-b')
1095
1096 for inputfile in self.input_files():
1097 args.append(inputfile)
1098
1099 if self.event_print_interval is not None:
1100 args.extend(['-e', str(self.event_print_interval)])
1101
1102 return args
1103
1104
1106 """!
1107 Space MC events and apply energy filters to process before readout.
1108
1109 Optional parameters are: **filter_ecal_hit_ecut**, **filter_event_interval**,
1110 **filter_nevents_read**, **filter_nevents_write**, **filter_no_cuts** \n
1111 Required config are: **hps_java_bin_jar**
1112 """
1113
1114 def __init__(self, **kwargs):
1115 if 'filter_no_cuts' in kwargs:
1116 self.filter_no_cuts = kwargs['filter_no_cuts']
1117 else:
1118
1119 self.filter_no_cuts = False
1120
1121 if 'filter_ecal_pairs' in kwargs:
1122 self.filter_ecal_pairs = kwargs['filter_ecal_pairs']
1123 else:
1124 self.filter_ecal_pairs = False
1125
1126 if 'filter_ecal_hit_ecut' in kwargs:
1127 self.filter_ecal_hit_ecut = kwargs['filter_ecal_hit_ecut']
1128 else:
1129
1130 self.filter_ecal_hit_ecut = -1.0
1131 # self.filter_ecal_hit_ecut = 0.05
1132
1133 if 'filter_event_interval' in kwargs:
1134 self.filter_event_interval = kwargs['filter_event_interval']
1135 else:
1136
1137 self.filter_event_interval = 250
1138
1139 if 'filter_nevents_read' in kwargs:
1140 self.filter_nevents_read = kwargs['filter_nevents_read']
1141 else:
1142
1143 self.filter_nevents_read = -1
1144
1145 if 'filter_nevents_write' in kwargs:
1146 self.filter_nevents_write = kwargs['filter_nevents_write']
1147 else:
1148
1149 self.filter_nevents_write = -1
1150
1152
1153 JavaTool.__init__(self,
1154 name='filter_bunches',
1155 java_class='org.hps.util.FilterMCBunches',
1156 append_tok='filt',
1157 **kwargs)
1158
1159 def config(self, parser):
1160 """! Configure FilterBunches component."""
1161 super().config(parser)
1162 if self.hps_java_bin_jarhps_java_bin_jar is None:
1163 if os.getenv('HPS_JAVA_BIN_JAR', None) is not None:
1164 self.hps_java_bin_jarhps_java_bin_jar = os.getenv('HPS_JAVA_BIN_JAR', None)
1165 self.logger.debug('Set HPS_JAVA_BIN_JAR from environment: {}'.format(self.hps_java_bin_jarhps_java_bin_jar))
1166
1167 def cmd_args(self):
1168 """!
1169 Setup command arguments.
1170 @return list of arguments
1171 """
1172 args = JavaTool.cmd_args(self)
1173 args.append("-e")
1174 args.append(str(self.filter_event_interval))
1175 for i in self.input_files():
1176 args.append(i)
1177 args.append(self.output_files()[0])
1178 if self.filter_ecal_pairs:
1179 args.append("-d")
1180 if self.filter_ecal_hit_ecut > 0:
1181 args.append("-E")
1182 args.append(str(self.filter_ecal_hit_ecut))
1183 if self.filter_nevents_read > 0:
1184 args.append('-n')
1185 args.append(str(self.filter_nevents_read))
1186 if self.filter_nevents_write > 0:
1187 args.append('-w')
1188 args.append(str(self.filter_nevents_write))
1189 if self.filter_no_cuts:
1190 args.append('-a')
1191 return args
1192
1194 """!
1195 Return list of optional parameters.
1196
1197 Optional parameters are: **filter_ecal_hit_ecut**, **filter_event_interval**,
1198 **filter_nevents_read**, **filter_nevents_write**, **filter_no_cuts** \n
1199 @return list of optional parameters
1200 """
1201 return ['filter_ecal_hit_ecut',
1202 'filter_event_interval',
1203 'filter_nevents_read',
1204 'filter_nevents_write',
1205 'filter_no_cuts']
1206
1208 """!
1209 Return list of required config.
1210
1211 Required config are: **hps_java_bin_jar**
1212 @return list of required config
1213 """
1214 return ['hps_java_bin_jar']
1215
1216
1218 """!
1219 Apply hodo-hit filter and space MC events to process before readout.
1220
1221 The nevents parameter is not settable from JSON in this class. It should
1222 be supplied as an init argument in the job script if it needs to be
1223 customized (the default nevents and event_interval used to apply spacing
1224 should usually not need to be changed by the user). \n
1225
1226 Optional parameters are: **num_hodo_hits**, **event_interval**
1227 """
1228
1229 def __init__(self, **kwargs):
1230 if "num_hodo_hits" in kwargs:
1231 self.num_hodo_hits = kwargs['num_hodo_hits']
1232 else:
1233 self.num_hodo_hits = 0
1234
1235 if "event_interval" in kwargs:
1236 self.event_interval = kwargs['event_interval']
1237 else:
1238 self.event_interval = 250
1239
1240 JavaTool.__init__(self,
1241 name='filter_events',
1242 java_class='org.hps.util.ExtractEventsWithHitAtHodoEcal',
1243 append_tok='filt',
1244 **kwargs)
1245
1246 def cmd_args(self):
1247 """!
1248 Setup command arguments.
1249 @return list of arguments
1250 """
1251 args = JavaTool.cmd_args(self)
1252 args.append("-e")
1253 args.append(str(self.event_interval))
1254 for i in self.input_files():
1255 args.append(i)
1256 args.append(self.output_files()[0])
1257 if self.num_hodo_hits > 0:
1258 args.append("-M")
1259 args.append(str(self.num_hodo_hits))
1260 if self.neventsnevents:
1261 args.append("-w")
1262 args.append(str(self.neventsnevents))
1263 return args
1264
1266 """!
1267 Return list of optional parameters.
1268
1269 Optional parameters are: **num_hodo_hits**, **event_interval**
1270 @return list of optional parameters
1271 """
1272 return ['num_hodo_hits', 'event_interval']
1273
1274
1276 """!
1277 Unzip the input files to outputs.
1278 """
1279
1280 def __init__(self, **kwargs):
1281 Component.__init__(self,
1282 name='unzip',
1283 command='gunzip',
1284 **kwargs)
1285
1286 def output_files(self):
1287 """! Return list of output files."""
1288 if self.outputs:
1289 return self.outputs
1290 return [os.path.splitext(i)[0] for i in self.input_files()]
1291
1292 def execute(self, log_out, log_err):
1293 """! Execute Unzip component."""
1294 for i in range(0, len(self.input_files())):
1295 inputfile = self.input_files()[i]
1296 outputfile = self.output_filesoutput_files()[i]
1297 with gzip.open(inputfile, 'rb') as in_file, open(outputfile, 'wb') as out_file:
1298 shutil.copyfileobj(in_file, out_file)
1299 self.logger.debug("Unzipped '%s' to '%s'" % (inputfile, outputfile))
1300 return 0
1301
1302
1304 """!
1305 Dump LCIO event information.
1306
1307 Required parameters are: none \n
1308 Required config are: **lcio_dir**
1309 """
1310
1311 def __init__(self, **kwargs):
1312
1313 self.lcio_dir = None
1314 Component.__init__(self,
1315 name='lcio_dump_event',
1316 command='dumpevent',
1317 **kwargs)
1318
1319 if "event_num" in kwargs:
1320 self.event_num = kwargs["event_num"]
1321 else:
1322 self.event_num = 1
1323
1324 def config(self, parser):
1325 """! Configure LCIODumpEvent component."""
1326 super().config(parser)
1327 if self.lcio_dir is None:
1328 self.lcio_dir = self.hpsmc_dir
1329
1330 def setup(self):
1331 """! Setup LCIODumpEvent component."""
1332 self.commandcommand = self.lcio_dir + "/bin/dumpevent"
1333
1334 def cmd_args(self):
1335 """!
1336 Setup command arguments.
1337 @return list of arguments
1338 """
1339 if not len(self.input_files()):
1340 raise Exception("Missing required inputs for LCIODumpEvent.")
1341 args = []
1342 args.append(self.input_files()[0])
1343 args.append(str(self.event_num))
1344 return args
1345
1347 """!
1348 Return list of required config.
1349
1350 Required config are: **lcio_dir**
1351 @return list of required config
1352 """
1353 return ['lcio_dir']
1354
1356 """!
1357 Return list of required parameters.
1358
1359 Required parameters are: none
1360 @return list of required parameters
1361 """
1362 return []
1363
1364
1366 """!
1367 Count events in an LHE file.
1368 """
1369
1370 def __init__(self, minevents=0, fail_on_underflow=False, **kwargs):
1371 self.minevents = minevents
1372 Component.__init__(self,
1373 name="lhe_count",
1374 **kwargs)
1375
1376 def setup(self):
1377 """! Setup LHECount component."""
1378 if not len(self.input_files()):
1379 raise Exception("Missing at least one input file.")
1380
1381 def cmd_exists(self):
1382 """!
1383 Check if command exists.
1384 @return True if command exists
1385 """
1386 return True
1387
1388 def execute(self, log_out, log_err):
1389 """! Execute LHECount component."""
1390 for i in self.inputs:
1391 with gzip.open(i, 'rb') as in_file:
1392 lines = in_file.readlines()
1393
1394 nevents = 0
1395 for line in lines:
1396 if "<event>" in line:
1397 nevents += 1
1398
1399 print("LHE file '%s' has %d events." % (i, nevents))
1400
1401 if nevents < self.minevents:
1402 msg = "LHE file '%s' does not contain the minimum %d events." % (i, nevents)
1403 if self.fail_on_underflow:
1404 raise Exception(msg)
1405 else:
1406 self.logger.warning(msg)
1407 return 0
1408
1409
1411 """!
1412 Tar files into an archive.
1413 """
1414
1415 def __init__(self, **kwargs):
1416 Component.__init__(self,
1417 name='tar_files',
1418 **kwargs)
1419
1420 def cmd_exists(self):
1421 """!
1422 Check if command exists.
1423 @return True if command exists
1424 """
1425 return True
1426
1427 def execute(self, log_out, log_err):
1428 """! Execute TarFiles component."""
1429 self.logger.debug("Opening '%s' for writing ..." % self.outputs[0])
1430 tar = tarfile.open(self.outputs[0], "w")
1431 for i in self.inputs:
1432 self.logger.debug("Adding '%s' to archive" % i)
1433 tar.add(i)
1434 tar.close()
1435 self.logger.info("Wrote archive '%s'" % self.outputs[0])
1436 return 0
1437
1438
1440 """!
1441 Move input files to new locations.
1442 """
1443
1444 def __init__(self, **kwargs):
1445 Component.__init__(self,
1446 name='move_files',
1447 **kwargs)
1448
1449 def cmd_exists(self):
1450 """!
1451 Check if command exists.
1452 @return True if command exists
1453 """
1454 return True
1455
1456 def execute(self, log_out, log_err):
1457 """! Execute TarFiles component."""
1458 if len(self.inputsinputs) != len(self.outputsoutputs):
1459 raise Exception("Input and output lists are not the same length!")
1460 for io in zip(self.inputsinputs, self.outputsoutputs):
1461 src = io[0]
1462 dest = io[1]
1463 self.logger.info("Moving %s -> %s" % (src, dest))
1464 shutil.move(src, dest)
1465 return 0
1466
1467
1469 """!
1470 Generic component for LCIO tools.
1471
1472 Required parameters are: none \n
1473 Required config are: **lcio_bin_jar**
1474 """
1475
1476 def __init__(self, name=None, **kwargs):
1477
1478 self.lcio_bin_jar = None
1479 Component.__init__(self,
1480 name,
1481 command='java',
1482 **kwargs)
1483
1484 def config(self, parser):
1485 """! Configure LCIOTool component."""
1486 super().config(parser)
1487 if self.lcio_bin_jar is None:
1488 self.config_from_environ()
1489
1490 def cmd_args(self):
1491 """!
1492 Setup command arguments.
1493 @return list of arguments
1494 """
1495 if not self.name:
1496 raise Exception("Name required to write cmd args for LCIOTool.")
1497 return ['-jar', self.lcio_bin_jar, self.name]
1498
1500 """!
1501 Return list of required config.
1502
1503 Required config are: **lcio_bin_jar**
1504 @return list of required config
1505 """
1506 return ['lcio_bin_jar']
1507
1509 """!
1510 Return list of required parameters.
1511
1512 Required parameters are: none
1513 @return list of required parameters
1514 """
1515 return []
1516
1517
1519 """!
1520 Concatenate LCIO files together.
1521 """
1522
1523 def __init__(self, **kwargs):
1524 LCIOTool.__init__(self,
1525 name='concat',
1526 **kwargs)
1527
1528 def cmd_args(self):
1529 """!
1530 Setup command arguments.
1531 @return list of arguments
1532 """
1533 args = LCIOTool.cmd_args(self)
1534 if not len(self.input_files()):
1535 raise Exception("Missing at least one input file.")
1536 if not len(self.output_files()):
1537 raise Exception("Missing an output file.")
1538 for i in self.input_files():
1539 args.extend(["-f", i])
1540 args.extend(["-o", self.outputs[0]])
1541 return args
1542
1543
1545 """!
1546 Count events in LCIO files.
1547
1548 Required parameters are: none \n
1549 Optional parameters are: none
1550 """
1551
1552 def __init__(self, **kwargs):
1553 LCIOTool.__init__(self,
1554 name='count',
1555 **kwargs)
1556
1557 def cmd_args(self):
1558 """!
1559 Setup command arguments.
1560 @return list of arguments
1561 """
1562 args = LCIOTool.cmd_args(self)
1563 if not len(self.inputsinputs):
1564 raise Exception("Missing an input file.")
1565 args.extend(["-f", self.inputsinputs[0]])
1566 return args
1567
1569 """!
1570 Return list of required parameters.
1571
1572 Required parameters are: none
1573 @return list of required parameters
1574 """
1575 return []
1576
1578 """!
1579 Return list of optional parameters.
1580
1581 Optional parameters are: none
1582 @return list of optional parameters
1583 """
1584 return []
1585
1586
1588 """!
1589 Merge LCIO files.
1590 """
1591
1592 def __init__(self, **kwargs):
1593 LCIOTool.__init__(self,
1594 name='merge',
1595 **kwargs)
1596
1597 def cmd_args(self):
1598 """!
1599 Setup command arguments.
1600 @return list of arguments
1601 """
1602 args = LCIOTool.cmd_args(self)
1603 if not len(self.input_files()):
1604 raise Exception("Missing at least one input file.")
1605 if not len(self.output_files()):
1606 raise Exception("Missing an output file.")
1607 for i in self.input_files():
1608 args.extend(["-f", i])
1609 args.extend(["-o", self.outputs[0]])
1610 if self.neventsnevents is not None:
1611 args.extend(['-n', str(self.neventsnevents)])
1612 return args
Base class for components in a job.
Definition component.py:15
output_files(self)
Return a list of output files created by this component.
Definition component.py:208
config_from_environ(self)
Configure component from environment variables which are just upper case versions of the required con...
Definition component.py:233
cmd_args(self)
Return the command arguments of this component.
Definition component.py:95
input_files(self)
Get a list of input files for this component.
Definition component.py:204
Add full truth mother particles for physics samples.
Definition tools.py:799
__init__(self, **kwargs)
Definition tools.py:802
cmd_args(self)
Setup command arguments.
Definition tools.py:818
Add mother particles for physics samples.
Definition tools.py:787
__init__(self, **kwargs)
Definition tools.py:792
Transform StdHep events into beam coordinates.
Definition tools.py:573
beam_rot_x
beam rotation in x?
Definition tools.py:594
__init__(self, **kwargs)
Definition tools.py:581
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:633
beam_sigma_y
beam sigma in y
Definition tools.py:586
target_x
target x position
Definition tools.py:588
target_y
target y position
Definition tools.py:590
beam_rot_z
beam rotation in z?
Definition tools.py:598
beam_rot_y
beam rotation in y?
Definition tools.py:596
cmd_args(self)
Setup command arguments.
Definition tools.py:605
target_z
target z position
Definition tools.py:592
Convert LHE files to StdHep, displacing the time by given ctau.
Definition tools.py:717
__init__(self, **kwargs)
Definition tools.py:724
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:742
cmd_args(self)
Setup command arguments.
Definition tools.py:732
Convert LHE files to StdHep, displacing the time by given ctau.
Definition tools.py:752
__init__(self, **kwargs)
Definition tools.py:759
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:777
cmd_args(self)
Setup command arguments.
Definition tools.py:767
Convert EVIO events to LCIO using the hps-java EvioToLcio command line tool.
Definition tools.py:1014
run_number
run number
Definition tools.py:1028
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:1051
detector
detector name
Definition tools.py:1026
required_parameters(self)
Return list of required parameters.
Definition tools.py:1042
setup(self)
Setup EvioToLcio component.
Definition tools.py:1060
__init__(self, steering=None, **kwargs)
Definition tools.py:1024
steering
steering file
Definition tools.py:1034
skip_events
number of events that are skipped
Definition tools.py:1030
event_print_interval
event print interval
Definition tools.py:1032
cmd_args(self)
Setup command arguments.
Definition tools.py:1067
Apply hodo-hit filter and space MC events to process before readout.
Definition tools.py:1217
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:1265
cmd_args(self)
Setup command arguments.
Definition tools.py:1246
Space MC events and apply energy filters to process before readout.
Definition tools.py:1105
filter_event_interval
Default event filtering interval.
Definition tools.py:1134
__init__(self, **kwargs)
Definition tools.py:1114
filter_ecal_hit_ecut
No default ecal hit cut energy (negative val to be ignored)
Definition tools.py:1127
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:1193
filter_nevents_read
Default is no maximum nevents to read.
Definition tools.py:1140
filter_no_cuts
By default cuts are on.
Definition tools.py:1116
config(self, parser)
Configure FilterBunches component.
Definition tools.py:1159
required_config(self)
Return list of required config.
Definition tools.py:1207
filter_nevents_write
Default is no maximum nevents to write.
Definition tools.py:1146
cmd_args(self)
Setup command arguments.
Definition tools.py:1167
Run the hpstr analysis tool.
Definition tools.py:401
execute(self, log_out, log_err)
Execute HPSTR component.
Definition tools.py:509
output_files(self)
Adjust names of output files.
Definition tools.py:499
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:464
required_parameters(self)
Return list of required parameters.
Definition tools.py:455
setup(self)
Setup HPSTR component.
Definition tools.py:428
__init__(self, cfg=None, is_data=0, year=None, tracking=None, **kwargs)
Definition tools.py:410
cfg
configuration
Definition tools.py:412
required_config(self)
Return list of required configs.
Definition tools.py:473
tracking
tracking option (KF, GBL, BOTH)
Definition tools.py:418
is_data
run mode
Definition tools.py:414
cmd_args(self)
Setup command arguments.
Definition tools.py:482
Generic base class for Java based tools.
Definition tools.py:967
java_class
java class
Definition tools.py:974
config(self, parser)
Automatic configuration.
Definition tools.py:1010
required_config(self)
Return list of required config.
Definition tools.py:984
cmd_args(self)
Setup command arguments.
Definition tools.py:993
java_args
java arguments
Definition tools.py:976
__init__(self, name, java_class, **kwargs)
Definition tools.py:972
Run the hps-java JobManager class.
Definition tools.py:217
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:391
detector
detector name
Definition tools.py:234
required_parameters(self)
Return list of required parameters.
Definition tools.py:382
setup(self)
Setup JobManager component.
Definition tools.py:297
__init__(self, steering=None, **kwargs)
Definition tools.py:227
lcsim_cache_dir
lcsim cache directory
Definition tools.py:244
steering
steering file
Definition tools.py:252
config(self, parser)
Configure JobManager component.
Definition tools.py:273
hps_java_bin_jar
location of hps-java installation?
Definition tools.py:254
logging_config_file
file for config logging
Definition tools.py:242
required_config(self)
Return list of required configurations.
Definition tools.py:288
event_print_interval
event print interval
Definition tools.py:236
cmd_args(self)
Setup command arguments.
Definition tools.py:306
java_args
java arguments
Definition tools.py:240
conditions_password
no idea
Definition tools.py:248
Concatenate LCIO files together.
Definition tools.py:1518
__init__(self, **kwargs)
Definition tools.py:1523
cmd_args(self)
Setup command arguments.
Definition tools.py:1528
Count events in LCIO files.
Definition tools.py:1544
__init__(self, **kwargs)
Definition tools.py:1552
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:1577
required_parameters(self)
Return list of required parameters.
Definition tools.py:1568
cmd_args(self)
Setup command arguments.
Definition tools.py:1557
Dump LCIO event information.
Definition tools.py:1303
__init__(self, **kwargs)
Definition tools.py:1311
lcio_dir
lcio directory
Definition tools.py:1313
required_parameters(self)
Return list of required parameters.
Definition tools.py:1355
setup(self)
Setup LCIODumpEvent component.
Definition tools.py:1330
config(self, parser)
Configure LCIODumpEvent component.
Definition tools.py:1324
required_config(self)
Return list of required config.
Definition tools.py:1346
cmd_args(self)
Setup command arguments.
Definition tools.py:1334
Merge LCIO files.
Definition tools.py:1587
__init__(self, **kwargs)
Definition tools.py:1592
cmd_args(self)
Setup command arguments.
Definition tools.py:1597
Generic component for LCIO tools.
Definition tools.py:1468
lcio_bin_jar
lcio bin jar (whatever this is)
Definition tools.py:1478
required_parameters(self)
Return list of required parameters.
Definition tools.py:1508
config(self, parser)
Configure LCIOTool component.
Definition tools.py:1484
required_config(self)
Return list of required config.
Definition tools.py:1499
cmd_args(self)
Setup command arguments.
Definition tools.py:1490
__init__(self, name=None, **kwargs)
Definition tools.py:1476
Count events in an LHE file.
Definition tools.py:1365
execute(self, log_out, log_err)
Execute LHECount component.
Definition tools.py:1388
__init__(self, minevents=0, fail_on_underflow=False, **kwargs)
Definition tools.py:1370
setup(self)
Setup LHECount component.
Definition tools.py:1376
cmd_exists(self)
Check if command exists.
Definition tools.py:1381
Merge StdHep files.
Definition tools.py:903
__init__(self, **kwargs)
Definition tools.py:911
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:916
required_parameters(self)
Return list of required parameters.
Definition tools.py:925
Merge StdHep files, applying poisson sampling.
Definition tools.py:826
execute(self, log_out, log_err)
Execute MergePoisson component.
Definition tools.py:890
target_thickness
target thickness in cm
Definition tools.py:837
__init__(self, xsec=0, **kwargs)
Definition tools.py:833
required_parameters(self)
Return list of required parameters.
Definition tools.py:854
setup(self)
Setup MergePoisson component.
Definition tools.py:846
xsec
cross section in pb
Definition tools.py:835
num_electrons
number of electrons per bunch
Definition tools.py:839
cmd_args(self)
Setup command arguments.
Definition tools.py:863
Move input files to new locations.
Definition tools.py:1439
execute(self, log_out, log_err)
Execute TarFiles component.
Definition tools.py:1456
__init__(self, **kwargs)
Definition tools.py:1444
cmd_exists(self)
Check if command exists.
Definition tools.py:1449
Randomly sample StdHep events into a new file.
Definition tools.py:646
execute(self, log_out, log_err)
Execute RandomSample component.
Definition tools.py:704
__init__(self, **kwargs)
Definition tools.py:653
mu
median of distribution?
Definition tools.py:659
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:695
cmd_args(self)
Setup command arguments.
Definition tools.py:661
Run the SLIC Geant4 simulation.
Definition tools.py:15
execute(self, log_out, log_err)
Execute SLIC component.
Definition tools.py:141
__init__(self, **kwargs)
Definition tools.py:24
run_number
Run number to set on output file (optional)
Definition tools.py:28
optional_parameters(self)
Return list of optional parameters.
Definition tools.py:114
required_parameters(self)
Return list of required parameters.
Definition tools.py:123
__particle_tbl(self)
Return path to particle table.
Definition tools.py:85
setup(self)
Setup SLIC component.
Definition tools.py:99
disable_particle_table
Optionally disable loading of the particle table shipped with slic Note: This should not be used with...
Definition tools.py:34
__detector_file(self)
Return path to detector file.
Definition tools.py:81
macros
List of macros to run (optional)
Definition tools.py:26
config(self, parser)
Configure SLIC component.
Definition tools.py:89
required_config(self)
Return list of required configurations.
Definition tools.py:132
detector_dir
To be set from config or install dir.
Definition tools.py:30
cmd_args(self)
Setup command arguments.
Definition tools.py:42
Copy the SQLite database file to the desired location.
Definition tools.py:161
execute(self, log_out, log_err)
Execute the file copy operation.
Definition tools.py:196
__init__(self, **kwargs)
Initialize SQLiteProc to copy the SQLite file.
Definition tools.py:166
cmd_args(self)
Return dummy command arguments to satisfy the parent class.
Definition tools.py:185
Count number of events in a StdHep file.
Definition tools.py:935
execute(self, log_out, log_err)
Execute StdHepCount component.
Definition tools.py:954
__init__(self, **kwargs)
Definition tools.py:940
cmd_args(self)
Setup command arguments.
Definition tools.py:946
Generic class for StdHep tools.
Definition tools.py:525
cmd_args(self)
Setup command arguments.
Definition tools.py:547
__init__(self, name=None, **kwargs)
Definition tools.py:540
Tar files into an archive.
Definition tools.py:1410
execute(self, log_out, log_err)
Execute TarFiles component.
Definition tools.py:1427
__init__(self, **kwargs)
Definition tools.py:1415
cmd_exists(self)
Check if command exists.
Definition tools.py:1420
Unzip the input files to outputs.
Definition tools.py:1275
execute(self, log_out, log_err)
Execute Unzip component.
Definition tools.py:1292
output_files(self)
Return list of output files.
Definition tools.py:1286
__init__(self, **kwargs)
Definition tools.py:1280
Miscellaneous math functions.
Definition func.py:1