@@ -38,7 +38,7 @@ rule build_per_energy_calibration:
38
38
timestamp = "{timestamp}" ,
39
39
datatype = "cal" ,
40
40
channel = "{channel}" ,
41
- tier = "pht" ,
41
+ tier = "pht" ,
42
42
output :
43
43
ecal_file = temp (get_pattern_pars_tmp_channel (setup , "pht" , "energy_cal" )),
44
44
results_file = temp (
@@ -351,6 +351,7 @@ for key, dataset in part.datasets.items():
351
351
partition ,
352
352
key ,
353
353
tier = "pht" ,
354
+ name = "aoecal" ,
354
355
)
355
356
],
356
357
aoe_results = [
@@ -360,7 +361,7 @@ for key, dataset in part.datasets.items():
360
361
partition ,
361
362
key ,
362
363
tier = "pht" ,
363
- name = "objects " ,
364
+ name = "aoecal_objects " ,
364
365
extension = "pkl" ,
365
366
)
366
367
],
@@ -371,6 +372,7 @@ for key, dataset in part.datasets.items():
371
372
partition ,
372
373
key ,
373
374
tier = "pht" ,
375
+ name = "aoecal" ,
374
376
)
375
377
],
376
378
log :
@@ -379,7 +381,7 @@ for key, dataset in part.datasets.items():
379
381
partition ,
380
382
key ,
381
383
"pht" ,
382
- name = "par_pht " ,
384
+ name = "par_pht_aoe " ,
383
385
),
384
386
group :
385
387
"par-pht"
@@ -413,7 +415,7 @@ for key, dataset in part.datasets.items():
413
415
414
416
# Merged energy and a/e supercalibrations to reduce number of rules as they have same inputs/outputs
415
417
# This rule builds the a/e calibration using the calibration dsp files for the whole partition
416
- rule build_pht_super_calibrations :
418
+ rule build_pht_aoe_calibrations :
417
419
input :
418
420
files = os .path .join (
419
421
filelist_path (setup ), "all-{experiment}-{period}-{run}-cal-dsp.filelist"
@@ -431,11 +433,13 @@ rule build_pht_super_calibrations:
431
433
channel = "{channel}" ,
432
434
timestamp = "{timestamp}" ,
433
435
output :
434
- hit_pars = temp (get_pattern_pars_tmp_channel (setup , "pht" )),
436
+ hit_pars = temp (get_pattern_pars_tmp_channel (setup , "pht" , "aoecal" )),
435
437
aoe_results = temp (
436
- get_pattern_pars_tmp_channel (setup , "pht" , "objects" , extension = "pkl" )
438
+ get_pattern_pars_tmp_channel (
439
+ setup , "pht" , "objeaoecal_objectscts" , extension = "pkl"
440
+ )
437
441
),
438
- plot_file = temp (get_pattern_plts_tmp_channel (setup , "pht" )),
442
+ plot_file = temp (get_pattern_plts_tmp_channel (setup , "pht" , "aoecal" )),
439
443
log :
440
444
get_pattern_log_channel (setup , "pars_pht_aoe_cal" ),
441
445
group :
@@ -470,3 +474,166 @@ for key, items in ordered.items():
470
474
rule_order_list += [item .name for item in items ]
471
475
rule_order_list .append (fallback_pht_rule .name )
472
476
workflow ._ruleorder .add (* rule_order_list ) # [::-1]
477
+
478
+ part_pht_rules = {}
479
+ for key , dataset in part .datasets .items ():
480
+ for partition in dataset .keys ():
481
+
482
+ rule :
483
+ input :
484
+ files = part .get_filelists (partition , key , "dsp" ),
485
+ tcm_files = part .get_filelists (partition , key , "tcm" ),
486
+ ecal_file = part .get_par_files (
487
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
488
+ partition ,
489
+ key ,
490
+ tier = "pht" ,
491
+ name = "aoecal" ,
492
+ ),
493
+ eres_file = part .get_par_files (
494
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
495
+ partition ,
496
+ key ,
497
+ tier = "pht" ,
498
+ name = "aoecal_objects" ,
499
+ extension = "pkl" ,
500
+ ),
501
+ inplots = part .get_plt_files (
502
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
503
+ partition ,
504
+ key ,
505
+ tier = "pht" ,
506
+ name = "aoecal" ,
507
+ ),
508
+ params :
509
+ datatype = "cal" ,
510
+ channel = "{channel}" ,
511
+ timestamp = part .get_timestamp (
512
+ f"{ par_pht_path (setup )} /validity.jsonl" , partition , key , tier = "pht"
513
+ ),
514
+ output :
515
+ hit_pars = [
516
+ temp (file )
517
+ for file in part .get_par_files (
518
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
519
+ partition ,
520
+ key ,
521
+ tier = "pht" ,
522
+ )
523
+ ],
524
+ lq_results = [
525
+ temp (file )
526
+ for file in part .get_par_files (
527
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
528
+ partition ,
529
+ key ,
530
+ tier = "pht" ,
531
+ name = "objects" ,
532
+ extension = "pkl" ,
533
+ )
534
+ ],
535
+ plot_file = [
536
+ temp (file )
537
+ for file in part .get_plt_files (
538
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
539
+ partition ,
540
+ key ,
541
+ tier = "pht" ,
542
+ )
543
+ ],
544
+ log :
545
+ part .get_log_file (
546
+ f"{ par_pht_path (setup )} /validity.jsonl" ,
547
+ partition ,
548
+ key ,
549
+ "pht" ,
550
+ name = "par_pht_lq" ,
551
+ ),
552
+ group :
553
+ "par-pht"
554
+ resources :
555
+ mem_swap = 75 ,
556
+ runtime = 300 ,
557
+ shell :
558
+ "{swenv} python3 -B "
559
+ f"{ basedir } /../scripts/pars_pht_lqcal.py "
560
+ "--log {log} "
561
+ "--configs {configs} "
562
+ "--datatype {params.datatype} "
563
+ "--timestamp {params.timestamp} "
564
+ "--inplots {input.inplots} "
565
+ "--channel {params.channel} "
566
+ "--lq_results {output.lq_results} "
567
+ "--eres_file {input.eres_file} "
568
+ "--hit_pars {output.hit_pars} "
569
+ "--plot_file {output.plot_file} "
570
+ "--ecal_file {input.ecal_file} "
571
+ "--tcm_filelist {input.tcm_files} "
572
+ "--input_files {input.files}"
573
+
574
+ # fix_name(f"{key}-{partition}")
575
+
576
+ if key in part_pht_rules :
577
+ part_pht_rules [key ].append (list (workflow .rules )[- 1 ])
578
+ else :
579
+ part_pht_rules [key ] = [list (workflow .rules )[- 1 ]]
580
+
581
+
582
+ # This rule builds the lq calibration using the calibration dsp files for the whole partition
583
+ rule build_pht_lq_calibration :
584
+ input :
585
+ files = os .path .join (
586
+ filelist_path (setup ), "all-{experiment}-{period}-{run}-cal-dsp.filelist"
587
+ ),
588
+ tcm_filelist = os .path .join (
589
+ filelist_path (setup ), "all-{experiment}-{period}-{run}-cal-tcm.filelist"
590
+ ),
591
+ ecal_file = get_pattern_pars_tmp_channel (setup , "pht" , "aoecal" ),
592
+ eres_file = get_pattern_pars_tmp_channel (
593
+ setup , "pht" , "aoecal_objects" , extension = "pkl"
594
+ ),
595
+ inplots = get_pattern_plts_tmp_channel (setup , "pht" , "aoecal" ),
596
+ params :
597
+ datatype = "cal" ,
598
+ channel = "{channel}" ,
599
+ timestamp = "{timestamp}" ,
600
+ output :
601
+ hit_pars = temp (get_pattern_pars_tmp_channel (setup , "pht" )),
602
+ lq_results = temp (
603
+ get_pattern_pars_tmp_channel (setup , "pht" , "objects" , extension = "pkl" )
604
+ ),
605
+ plot_file = temp (get_pattern_plts_tmp_channel (setup , "pht" )),
606
+ log :
607
+ get_pattern_log_channel (setup , "pars_pht_lq_cal" ),
608
+ group :
609
+ "par-pht"
610
+ resources :
611
+ mem_swap = 60 ,
612
+ runtime = 300 ,
613
+ shell :
614
+ "{swenv} python3 -B "
615
+ f"{ basedir } /./scripts/pars_pht_lqcal.py "
616
+ "--log {log} "
617
+ "--configs {configs} "
618
+ "--datatype {params.datatype} "
619
+ "--timestamp {params.timestamp} "
620
+ "--inplots {input.inplots} "
621
+ "--channel {params.channel} "
622
+ "--lq_results {output.lq_results} "
623
+ "--eres_file {input.eres_file} "
624
+ "--hit_pars {output.hit_pars} "
625
+ "--plot_file {output.plot_file} "
626
+ "--ecal_file {input.ecal_file} "
627
+ "--tcm_filelist {input.tcm_filelist} "
628
+ "--input_files {input.files}"
629
+
630
+
631
+ fallback_pht_rule = list (workflow .rules )[- 1 ]
632
+
633
+ rule_order_list = []
634
+ ordered = OrderedDict (part_pht_rules )
635
+ ordered .move_to_end ("default" )
636
+ for key , items in ordered .items ():
637
+ rule_order_list += [item .name for item in items ]
638
+ rule_order_list .append (fallback_pht_rule .name )
639
+ workflow ._ruleorder .add (* rule_order_list ) # [::-1]
0 commit comments