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