547 PlotterTool = None, addAsPrimary = True, ReallyUseGPUTools = True):
548
549 doLCCalib = flags.CaloRecGPU.ActiveConfig.doTopoClusterLocalCalib
550
551 if clustersname is None:
552 clustersname = "CaloCalTopoClusters" if doLCCalib else "CaloTopoClusters"
553
554 if clustersname == "CaloTopoClusters" and doLCCalib:
555 raise RuntimeError("Inconsistent arguments: clustersname must not be 'CaloTopoClusters' if doTopoClusterLocalCalib is True")
556
557 clustersname_final = clustersname
558 if flags.CaloRecGPU.ActiveConfig.applyClusterTimingCut:
559 clustersname = f"{clustersname}BeforeTimingCut"
560
561 result = ComponentAccumulator()
562
563 if not instantiateForTrigger:
564
565 from LArGeoAlgsNV.LArGMConfig import LArGMCfg
566 from TileGeoModel.TileGMConfig import TileGMCfg
567 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
568
569 result.merge(CaloNoiseCondAlgCfg(flags,"totalNoise"))
570 result.merge(CaloNoiseCondAlgCfg(flags,"electronicNoise"))
571
572 result.merge(LArGMCfg(flags))
573 result.merge(TileGMCfg(flags))
574
575
576 HybridClusterProcessor = CompFactory.CaloGPUHybridClusterProcessor(name)
577 HybridClusterProcessor.ClustersOutputName = clustersname
578
579 HybridClusterProcessor.WriteTriggerSpecificInfo = instantiateForTrigger
580
581 HybridClusterProcessor.MeasureTimes = flags.CaloRecGPU.ActiveConfig.MeasureTimes
582
583 HybridClusterProcessor.TimeFileOutput = "GlobalTimes.txt"
584
585 HybridClusterProcessor.DeferConstantDataPreparationToFirstEvent = True
586 HybridClusterProcessor.DoPlots = PlotterTool is not None
587 HybridClusterProcessor.PlotterTool = PlotterTool
588
589 HybridClusterProcessor.NumPreAllocatedDataHolders = flags.CaloRecGPU.ActiveConfig.NumPreAllocatedDataHolders
590
591 if ReallyUseGPUTools:
592
593 HybridClusterProcessor.ConstantDataToGPUTool = result.popToolsAndMerge( BasicConstantDataExporterToolCfg(flags) )
594 HybridClusterProcessor.EventDataToGPUTool = result.popToolsAndMerge( BasicEventDataExporterToolCfg(flags, cellsname) )
595 HybridClusterProcessor.GPUToEventDataTool = result.popToolsAndMerge( AthenaClusterAndMomentsImporterToolCfg(flags, cellsname, instantiateForTrigger) )
596
597
598 HybridClusterProcessor.BeforeGPUTools = []
599
600 HybridClusterProcessor.GPUTools = []
601
602 HybridClusterProcessor.GPUTools += [result.popToolsAndMerge( TopoAutomatonClusteringToolCfg(flags,"GPUGrowing"))]
603
604 HybridClusterProcessor.GPUTools += [result.popToolsAndMerge( ClusterInfoCalcToolCfg(flags,"PostGPUGrowingClusterPropertiesCalculator", True))]
605
606 HybridClusterProcessor.GPUTools += [result.popToolsAndMerge( TopoAutomatonSplitterToolCfg(flags,"GPUSplitting") )]
607
608 HybridClusterProcessor.GPUTools += [result.popToolsAndMerge( ClusterSorterToolCfg(flags, "GPUClusterSorting", False) )]
609
610 HybridClusterProcessor.GPUTools += [result.popToolsAndMerge( GPUClusterMomentsCalculatorToolCfg(flags,"GPUTopoMoments") )]
611
612 else:
613
614 HybridClusterProcessor.ConstantDataToGPUTool = None
615 HybridClusterProcessor.EventDataToGPUTool = None
616 HybridClusterProcessor.GPUToEventDataTool = None
617 HybridClusterProcessor.SkipConversions = True
618
619 HybridClusterProcessor.GPUTools = []
620
621 HybridClusterProcessor.BeforeGPUTools = []
622
623 HybridClusterProcessor.BeforeGPUTools += [result.popToolsAndMerge( DefaultTopologicalClusteringToolCfg(flags, cellsname,"CPUGrowing"))]
624
625 HybridClusterProcessor.BeforeGPUTools += [result.popToolsAndMerge( DefaultClusterSplittingToolCfg(flags,"CPUSplitting") )]
626
627 HybridClusterProcessor.BeforeGPUTools += [result.popToolsAndMerge( DefaultClusterMomentsCalculatorToolCfg(flags, instantiateForTrigger, "CPUTopoMoments") )]
628
629 HybridClusterProcessor.BeforeGPUTools += [ CompFactory.CaloClusterStoreRawProperties("RawPropertiesStorer") ]
630
631
632
633 HybridClusterProcessor.AfterGPUTools = []
634
635 if not instantiateForTrigger:
636 from CaloBadChannelTool.CaloBadChanToolConfig import CaloBadChanToolCfg
637 caloBadChanTool = result.popToolsAndMerge( CaloBadChanToolCfg(flags) )
638 HybridClusterProcessor.AfterGPUTools += [CompFactory.CaloClusterBadChannelList(badChannelTool = caloBadChanTool)]
639
640 if not instantiateForTrigger and flags.CaloRecGPU.ActiveConfig.doCalibHitMoments:
641
642 calibHitsMomentsMaker = result.popToolsAndMerge(DefaultCalibMomentsToolCfg(flags))
643 HybridClusterProcessor.AfterGPUTools += [calibHitsMomentsMaker]
644
645 if doLCCalib:
646 if not instantiateForTrigger:
647 HybridClusterProcessor.AfterGPUTools += [CompFactory.CaloClusterSnapshot(OutputName=clustersnapname,
648 SetCrossLinks=True,
649 FinalClusterContainerName=clustersname)]
650 else:
651 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
652 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
653 result.merge(CaloNoiseCondAlgCfg(flags, noisetype="electronicNoise"))
654 result.merge(caloTopoCoolFolderCfg(flags))
655
656 calibTools = result.popToolsAndMerge(DefaultTopoClusterLocalCalibToolsCfg(flags, instantiateForTrigger, 'Trig' if instantiateForTrigger else ''))
657
658 HybridClusterProcessor.AfterGPUTools += calibTools
659
660
661 if not instantiateForTrigger:
662 from CaloRec.CaloTopoClusterConfig import caloTopoCoolFolderCfg
663 result.merge(caloTopoCoolFolderCfg(flags))
664
665 if instantiateForTrigger:
666 from CaloTools.CaloNoiseCondAlgConfig import CaloNoiseCondAlgCfg
667 result.merge(CaloNoiseCondAlgCfg(flags))
668
669 result.addEventAlgo(HybridClusterProcessor, primary=addAsPrimary)
670
671 if flags.CaloRecGPU.ActiveConfig.applyClusterTimingCut:
672 from CaloRec.CaloTopoClusterConfig import CaloClusterTimingFilterCfg
673 result.merge(CaloClusterTimingFilterCfg(flags, name = f"{clustersname}Filter", InputClusters = clustersname, OutputClusters = clustersname_final))
674
675 if instantiateForTrigger or clustersname_final in flags.CaloRecGPU.ActiveConfig.skipWriteList:
676
677 return result
678
679
680 AODMoments=[ "SECOND_R"
681 ,"SECOND_LAMBDA"
682 ,"CENTER_MAG"
683 ,"CENTER_LAMBDA"
684 ,"FIRST_ENG_DENS"
685 ,"ENG_FRAC_MAX"
686 ,"ISOLATION"
687 ,"ENG_BAD_CELLS"
688 ,"N_BAD_CELLS"
689 ,"BADLARQ_FRAC"
690 ,"ENG_POS"
691 ,"SIGNIFICANCE"
692 ,"AVG_LAR_Q"
693 ,"AVG_TILE_Q"
694 ,"EM_PROBABILITY"
695 ,"BadChannelList"
696 ,"SECOND_TIME"
697 ,"NCELL_SAMPLING"]
698
699 if flags.CaloRecGPU.ActiveConfig.writeExtendedClusterMoments:
700 AODMoments += ["LATERAL"
701 ,"LONGITUDINAL"
702 ,"CELL_SIGNIFICANCE"
703 ,"PTD"
704 ,"MASS"]
705
706 if flags.Reco.EnableHI:
707 AODMoments += ["CELL_SIG_SAMPLING"]
708
709 if flags.CaloRecGPU.ActiveConfig.writeCalibHitClusterMoments:
710 AODMoments += ["ENG_CALIB_TOT"
711 ,"ENG_CALIB_OUT_L"
712 ,"ENG_CALIB_OUT_T"
713 ,"ENG_CALIB_EMB0"
714 ,"ENG_CALIB_EME0"
715 ,"ENG_CALIB_TILEG3"
716 ,"ENG_CALIB_DEAD_TOT"
717 ,"ENG_CALIB_DEAD_EMB0"
718 ,"ENG_CALIB_DEAD_TILE0"
719 ,"ENG_CALIB_DEAD_TILEG3"
720 ,"ENG_CALIB_DEAD_EME0"
721 ,"ENG_CALIB_DEAD_HEC0"
722 ,"ENG_CALIB_DEAD_FCAL"
723 ,"ENG_CALIB_DEAD_LEAKAGE"
724 ,"ENG_CALIB_DEAD_UNCLASS"
725 ,"ENG_CALIB_FRAC_EM"
726 ,"ENG_CALIB_FRAC_HAD"
727 ,"ENG_CALIB_FRAC_REST"]
728
729
730 from OutputStreamAthenaPool.OutputStreamConfig import addToAOD, addToESD
731 toESD = [f"xAOD::CaloClusterContainer#{clustersname_final}",
732 f"xAOD::CaloClusterAuxContainer#{clustersname_final}Aux.",
733 f"CaloClusterCellLinkContainer#{clustersname_final}_links"]
734 toAOD = [f"xAOD::CaloClusterContainer#{clustersname_final}",
735 f"CaloClusterCellLinkContainer#{clustersname_final}_links"]
736
737 AODMoments.append("CellLink")
738 if flags.CaloRecGPU.ActiveConfig.addCalibrationHitDecoration:
739 AODMoments.append(flags.CaloRecGPU.ActiveConfig.CalibrationHitDecorationName)
740
741 if flags.CaloRecGPU.ActiveConfig.addCPData:
742 AODMoments += ["ClusterWidthEta","ClusterWidthPhi"]
743
744 auxItems = f"xAOD::CaloClusterAuxContainer#{clustersname_final}Aux."
745 auxItems+= ".".join(AODMoments)
746
747 toAOD.append(auxItems)
748
749 result.merge(addToESD(flags, toESD))
750 result.merge(addToAOD(flags, toAOD))
751
752
753 return result