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