ATLAS Offline Software
Loading...
Searching...
No Matches
python.JetAnalysisConfig.LargeRJetAnalysisConfig Class Reference
Inheritance diagram for python.JetAnalysisConfig.LargeRJetAnalysisConfig:
Collaboration diagram for python.JetAnalysisConfig.LargeRJetAnalysisConfig:

Public Member Functions

 __init__ (self)
 instanceName (self)
 getUncertaintyToolSettings (self, config)
 createUncertaintyTool (self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False)
 createFFSmearingTool (self, jetFFSmearingAlg, config)
 makeAlgs (self, config)

Public Attributes

 systematicsModelJER
 systematicsModelJMS
 runJERsystematicsOnData
 containerName
str jetCollection = "AnalysisJets") :
 recalibratePhyslite

Detailed Description

the ConfigBlock for the large-r jet sequence

Definition at line 619 of file JetAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.__init__ ( self)

Definition at line 622 of file JetAnalysisConfig.py.

622 def __init__ (self) :
623 super (LargeRJetAnalysisConfig, self).__init__ ()
624 self.addOption ('containerName', '', type=str,
625 noneAction='error',
626 info="the name of the output container after calibration.")
627 self.addOption ('jetCollection', '', type=str,
628 noneAction='error',
629 info="the jet container to run on. It is interpreted to determine "
630 "the correct config blocks to call for small- or large-R jets.")
631 self.addOption ('jetInput', '', type=str,
632 noneAction='error',
633 info="the type of jet input. Supported options are: `UFO`.")
634 self.addOption ('recalibratePhyslite', True, type=bool,
635 info="whether to run the CP::JetCalibrationAlg on PHYSLITE "
636 "derivations. The default is True.")
637 self.addOption ('runUncertainties', True, type=bool,
638 info="whether to configure JetUncertaintiesTool.", expertMode=True )
639 self.addOption ('systematicsModelJER', "Full", type=str)
640 self.addOption ('systematicsModelJMS', "Full", type=str)
641 self.addOption ('systematicsModelJMR', "Full", type=str,
642 info="the NP reduction scheme to use for JMR: Full, Simple. The default is Full.")
643 self.addOption ('runJERsystematicsOnData', False, type=bool,
644 info="whether to run the All/Full JER model variations also on data samples. Expert option!",
645 expertMode=True)
646 # Adding these options to override the jet uncertainty config file when we have new recommendations
647 # Calibration tool options
648 self.addOption ('calibToolConfigFile', None, type=str,
649 info="name of the config file to use for the jet calibration "
650 "tool. Expert option to override JetETmiss recommendations.",
651 expertMode=True)
652 self.addOption ('calibToolCalibArea', None, type=str,
653 info="name of the CVMFS area to use for the jet calibration "
654 "tool. Expert option to override JetETmiss recommendations.",
655 expertMode=True)
656 self.addOption ('calibToolCalibSeq', None, type=str,
657 info="name of the sequence to use for the jet calibration "
658 "tool (e.g. `JetArea_Residual_EtaJES_GSC`). Expert option to override "
659 "JetETmiss recommendations.",
660 expertMode=True)
661 # Uncertainties tool options
662 self.addOption ('uncertToolConfigPath', None, type=str,
663 info="name of the config file to use for the JES, JER, and JMS uncertainty "
664 "tool. Expert option to override JetETmiss recommendations.",
665 expertMode=True)
666 self.addOption ('uncertToolConfigPathJMR', None, type=str,
667 info="name of the config file to use for the JMR uncertainty "
668 "tool. Expert option to override JetETmiss recommendations.",
669 expertMode=True)
670 self.addOption ('uncertToolCalibArea', None, type=str,
671 info="name (str) of the CVMFS area to use for the jet uncertainty "
672 "tool. Expert option to override JetETmiss recommendations. The "
673 "default is None.",
674 expertMode=True)
675 self.addOption ('uncertToolMCType', None, type=str,
676 info="data type (str) to use for the jet uncertainty tool (e.g. "
677 "'AF3' or 'MC16'). Expert option to override JetETmiss "
678 "recommendations. The default is None.",
679 expertMode=True)
680 self.addOption ('minPt', 200.*GeV, type=float,
681 info=r"the minimum $p_\mathrm{T}$ cut (in MeV) to apply to calibrated large-R jets.")
682 self.addOption ('maxPt', 3000.*GeV, type=float,
683 info=r"the maximum $p_\mathrm{T}$ cut (in MeV) to apply to calibrated large-R jets.")
684 self.addOption ('maxEta', 0., type=float,
685 info=r"the maximum $\vert\eta\vert$ cut to apply to calibrated large-R jets.")
686 self.addOption ('maxRapidity', 2., type=float,
687 info="the maximum rapidity cut to apply to calibrated large-R jets.")
688 self.addOption ('minMass', 40.*GeV, type=float,
689 info="the minimum mass cut (in MeV) to apply to calibrated large-R jets.")
690 self.addOption ('maxMass', 600.*GeV, type=float,
691 info="the maximum mass cut (in MeV) to apply to calibrated large-R jets.")
692

Member Function Documentation

◆ createFFSmearingTool()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.createFFSmearingTool ( self,
jetFFSmearingAlg,
config )

Definition at line 786 of file JetAnalysisConfig.py.

786 def createFFSmearingTool(self, jetFFSmearingAlg, config):
787 # Retrieve appropriate large-R jet mass resolution recommendations for the FFJetSmearingTool.
788
789 # Config file:
790 if self.systematicsModelJMR in ["Simple", "Full"]:
791 config_file = f"R10_{self.systematicsModelJMR}JMR.config"
792 else:
793 raise ValueError(
794 f"Invalid request for systematicsModelJMR settings: {self.systematicsModelJMR}"
795 )
796
797 # Expert override for config path:
798 if self.uncertToolConfigPathJMR is not None:
799 config_file = self.uncertToolConfigPathJMR
800 else:
801 config_file = "rel22/Summer2025_PreRec/" + config_file
802 if config.geometry() is LHCPeriod.Run4:
803 warnings.warn_explicit(
804 "Uncertainties for UFO jets are not for Run 4!",
805 JetUncertaintyWarning, filename='', lineno=0)
806
807 # MC type:
808 if config.geometry() is LHCPeriod.Run2:
809 if config.dataType() is DataType.FastSim:
810 mc_type = "MC20AF3"
811 else:
812 mc_type = "MC20"
813 elif config.geometry() >= LHCPeriod.Run3:
814 if config.dataType() is DataType.FastSim:
815 mc_type = "MC23AF3"
816 else:
817 mc_type = "MC23"
818
819 # Set up the FF smearing tool
820 config.addPrivateTool( 'FFSmearingTool', 'CP::FFJetSmearingTool')
821 jetFFSmearingAlg.FFSmearingTool.MassDef = "UFO"
822 jetFFSmearingAlg.FFSmearingTool.MCType = mc_type
823 jetFFSmearingAlg.FFSmearingTool.ConfigFile = config_file
824

◆ createUncertaintyTool()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.createUncertaintyTool ( self,
jetUncertaintiesAlg,
config,
jetCollectionName,
doPseudoData = False )
Create instance(s) of JetUncertaintiesTool following JetETmiss recommendations.

JER uncertainties under the "Full" scheme must be run on MC samples twice:
1. Normal (MC) mode,
2. Pseudodata (PD) mode, as if the events are Data.

Definition at line 748 of file JetAnalysisConfig.py.

748 def createUncertaintyTool(self, jetUncertaintiesAlg, config, jetCollectionName, doPseudoData=False):
749 '''
750 Create instance(s) of JetUncertaintiesTool following JetETmiss recommendations.
751
752 JER uncertainties under the "Full" scheme must be run on MC samples twice:
753 1. Normal (MC) mode,
754 2. Pseudodata (PD) mode, as if the events are Data.
755 '''
756
757 # Retrieve the common configuration settings
758 configFile, calibArea, mcType = self.getUncertaintyToolSettings(config)
759
760 # The main tool for all JER combinations
761 config.addPrivateTool( 'uncertaintiesTool', 'JetUncertaintiesTool' )
762 jetUncertaintiesAlg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
763 jetUncertaintiesAlg.uncertaintiesTool.ConfigFile = configFile
764 if calibArea is not None:
765 jetUncertaintiesAlg.uncertaintiesTool.CalibArea = calibArea
766 jetUncertaintiesAlg.uncertaintiesTool.MCType = mcType
767 jetUncertaintiesAlg.uncertaintiesTool.IsData = (config.dataType() is DataType.Data)
768 jetUncertaintiesAlg.uncertaintiesTool.PseudoDataJERsmearingMode = False
769
770 # JER smearing on data
771 if config.dataType() is DataType.Data and not (config.isPhyslite() and doPseudoData and self.runJERsystematicsOnData):
772 # we don't want any systematics on data if we're not using the right JER model!
773 jetUncertaintiesAlg.affectingSystematicsFilter = '.*'
774
775 if config.dataType() is not (DataType.Data and config.isPhyslite()) and doPseudoData and not self.runJERsystematicsOnData:
776 # The secondary tool for pseudo-data JER smearing
777 config.addPrivateTool( 'uncertaintiesToolPD', 'JetUncertaintiesTool' )
778 jetUncertaintiesAlg.uncertaintiesToolPD.JetDefinition = jetCollectionName[:-4]
779 jetUncertaintiesAlg.uncertaintiesToolPD.ConfigFile = configFile
780 if calibArea is not None:
781 jetUncertaintiesAlg.uncertaintiesToolPD.CalibArea = calibArea
782 jetUncertaintiesAlg.uncertaintiesToolPD.MCType = mcType
783 jetUncertaintiesAlg.uncertaintiesToolPD.IsData = True
784 jetUncertaintiesAlg.uncertaintiesToolPD.PseudoDataJERsmearingMode = True
785

◆ getUncertaintyToolSettings()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.getUncertaintyToolSettings ( self,
config )

Definition at line 697 of file JetAnalysisConfig.py.

697 def getUncertaintyToolSettings(self, config):
698 # Retrieve appropriate JES/JER recommendations for the JetUncertaintiesTool.
699 # We do this separately from the tool declaration, as we may need to set uo
700 # two such tools, but they have to be private.
701
702
703 # Config file:
704 config_file = None
705 if self.systematicsModelJER in ["Simple", "Full"] and self.systematicsModelJMS in ["Simple", "Full"]:
706 config_file = "R10_CategoryJES_{0}JER_{1}JMS.config".format(self.systematicsModelJER, self.systematicsModelJMS)
707 else:
708 raise ValueError(
709 "Invalid request for systematicsModelJER/JMS settings: "
710 "systematicsModelJER = '{0}', "
711 "systematicsModelJMS = '{1}'".format(self.systematicsModelJER, self.systematicsModelJMS) )
712 if self.uncertToolConfigPath is not None:
713 # Expert override
714 config_file = self.uncertToolConfigPath
715 else:
716 if config.geometry() in [LHCPeriod.Run2, LHCPeriod.Run3]:
717 config_file = "rel22/Summer2025_PreRec/" + config_file
718 else:
719 warnings.warn_explicit(
720 "Uncertainties for UFO jets are not for Run 4!"
721 " are deprecated - please use a"
722 " JVTWorkingPoint block instead.",
723 JetUncertaintyWarning, filename='', lineno=0)
724
725
726 # Calibration area:
727 calib_area = None
728 if self.uncertToolCalibArea is not None:
729 calib_area = self.uncertToolCalibArea
730
731 # MC type:
732 if self.uncertToolMCType is not None:
733 mc_type = self.uncertToolMCType
734 else:
735 if config.dataType() is DataType.FastSim:
736 if config.geometry() is LHCPeriod.Run2:
737 mc_type = "MC20AF3"
738 else:
739 mc_type = "MC23AF3"
740 else:
741 if config.geometry() is LHCPeriod.Run2:
742 mc_type = "MC20"
743 else:
744 mc_type = "MC23"
745
746 return config_file, calib_area, mc_type
747

◆ instanceName()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.instanceName ( self)
Return the instance name for this block

Definition at line 693 of file JetAnalysisConfig.py.

693 def instanceName (self) :
694 """Return the instance name for this block"""
695 return self.containerName
696

◆ makeAlgs()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.makeAlgs ( self,
config )

Definition at line 825 of file JetAnalysisConfig.py.

825 def makeAlgs (self, config) :
826
827 # Self-select: only run for large-R (radius 10) jets
828 if config.getContainerMeta(self.containerName, 'jetRadius', failOnMiss=True) != 10:
829 return
830
831 configFile = None
832 calibSeq = None
833 calibArea = None
834
835 jetCollectionName=self.jetCollection
836 if(self.jetCollection=="AnalysisJets") :
837 jetCollectionName="AntiKt4EMPFlowJets"
838 if(self.jetCollection=="AnalysisLargeRJets") :
839 jetCollectionName="AntiKt10UFOCSSKSoftDropBeta100Zcut10Jets"
840
841 jetInput = config.getContainerMeta(self.containerName, 'jetInput', failOnMiss=True)
842 trim = config.getContainerMeta(self.containerName, 'jetTrim', failOnMiss=True)
843
844 if jetInput not in ["UFO"]:
845 raise ValueError("Invalid input type '{0}' for large-R jets!".format(jetInput) )
846
847 if not trim:
848 raise ValueError("Untrimmed large-R jets are not supported!")
849
850 configFile = "JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_26Nov2024.config"
851 calibArea = "00-04-83"
852 if self.calibToolConfigFile is not None:
853 configFile = self.calibToolConfigFile
854
855 if config.dataType() is not DataType.Data:
856 calibSeq = "EtaJES_JMS"
857 elif config.dataType() is DataType.Data:
858 calibSeq = "EtaJES_JMS_Insitu"
859 if self.calibToolCalibSeq is not None:
860 calibSeq = self.calibToolCalibSeq
861
862 if self.calibToolCalibArea is not None:
863 calibArea = self.calibToolCalibArea
864
865 if not config.isPhyslite() or self.recalibratePhyslite:
866 # Create calibration tool before algorithm (EventLoop ordering)
867 calibToolName = 'JetCalibTool_' + jetCollectionName[:-4]
868 calibTool = config.createPublicTool( 'JetCalibrationTool', calibToolName )
869
870 calibTool.JetCollection = jetCollectionName[:-4]
871
872 if configFile is None:
873 raise ValueError(f'Unsupported: {jetInput=}, {config.dataType()=}')
874 calibTool.ConfigFile = configFile
875
876 if calibSeq is None:
877 raise ValueError(f'Unsupported: {jetInput=}, {config.dataType()=}')
878 calibTool.CalibSequence = calibSeq
879
880 if calibArea is not None:
881 calibTool.CalibArea = calibArea
882
883 calibTool.IsData = (config.dataType() is DataType.Data)
884 # Prepare the jet calibration algorithm
885 alg = config.createAlgorithm( 'CP::JetCalibrationAlg', 'JetCalibrationAlg' )
886 alg.calibrationTool = f'{calibTool.getType()}/{calibTool.getName()}'
887 alg.jets = config.readName(self.containerName)
888 alg.jetsOut = config.copyName(self.containerName)
889
890 # Jet uncertainties
891 if jetInput == "UFO" and config.dataType() in [DataType.FullSim, DataType.FastSim] and self.runUncertainties:
892 alg = config.createAlgorithm( 'CP::JetUncertaintiesAlg', 'JetUncertaintiesAlg' )
893 self.createUncertaintyTool(alg, config, jetCollectionName, doPseudoData=( self.systematicsModelJER in ["Full","All"] ))
894
895 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
896
897 # R=1.0 jets have a validity range
898 alg.outOfValidity = 2 # SILENT
899 alg.outOfValidityDeco = 'outOfValidity'
900
901 alg.jets = config.readName (self.containerName)
902 alg.jetsOut = config.copyName (self.containerName)
903 alg.preselection = config.getPreselection (self.containerName, '')
904
905 if jetInput != "UFO" and self.runUncertainties:
906 alg = config.createAlgorithm( 'CP::JetUncertaintiesAlg', 'JetUncertaintiesAlg' )
907
908 # R=1.0 jets have a validity range
909 alg.outOfValidity = 2 # SILENT
910 alg.outOfValidityDeco = 'outOfValidity'
911 config.addPrivateTool( 'uncertaintiesTool', 'JetUncertaintiesTool' )
912
913 alg.uncertaintiesTool.JetDefinition = jetCollectionName[:-4]
914 alg.uncertaintiesTool.ConfigFile = \
915 "rel21/Moriond2018/R10_{0}Mass_all.config".format(self.largeRMass)
916 alg.uncertaintiesTool.MCType = "MC16a"
917 alg.uncertaintiesTool.IsData = (config.dataType() is DataType.Data)
918
919 alg.jets = config.readName (self.containerName)
920 alg.jetsOut = config.copyName (self.containerName)
921 alg.preselection = config.getPreselection (self.containerName, '')
922 config.addSelection (self.containerName, '', 'outOfValidity')
923
924 if jetInput == "UFO" and config.dataType() is not DataType.Data:
925 # set up the FF smearing algorithm
926 alg = config.createAlgorithm( 'CP::JetFFSmearingAlg', 'JetFFSmearingAlg' )
927 self.createFFSmearingTool(alg, config)
928 alg.outOfValidity = 2 # SILENT
929 alg.outOfValidityDeco = 'outOfValidityJMR'
930 alg.jets = config.readName (self.containerName)
931 alg.jetsOut = config.copyName (self.containerName)
932 alg.preselection = config.getPreselection (self.containerName, '')
933
934 if self.minPt > 0 or self.maxPt > 0 or self.maxEta > 0 or self.maxRapidity > 0:
935 # Set up the the pt-eta selection
936 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'JetPtEtaCutAlg' )
937 alg.selectionDecoration = 'selectPtEta,as_bits'
938 config.addPrivateTool( 'selectionTool', 'CP::AsgPtEtaSelectionTool' )
939 alg.selectionTool.minPt = self.minPt
940 alg.selectionTool.maxPt = self.maxPt
941 alg.selectionTool.maxEta = self.maxEta
942 alg.selectionTool.maxRapidity = self.maxRapidity
943 alg.particles = config.readName (self.containerName)
944 alg.preselection = config.getPreselection (self.containerName, '')
945 config.addSelection (self.containerName, '', alg.selectionDecoration,
946 preselection=True)
947
948 if self.minMass > 0 or self.maxMass > 0:
949 # Set up the the mass selection
950 alg = config.createAlgorithm( 'CP::AsgSelectionAlg', 'JetMassCutAlg' )
951 alg.selectionDecoration = 'selectMass,as_bits'
952 config.addPrivateTool( 'selectionTool', 'CP::AsgMassSelectionTool' )
953 alg.selectionTool.minM = self.minMass
954 alg.selectionTool.maxM = self.maxMass
955 alg.particles = config.readName (self.containerName)
956 alg.preselection = config.getPreselection (self.containerName, '')
957 config.addSelection (self.containerName, '', alg.selectionDecoration,
958 preselection=True)
959
960 config.addOutputVar (self.containerName, 'm', 'm')
961
if(pathvar)

Member Data Documentation

◆ containerName

python.JetAnalysisConfig.LargeRJetAnalysisConfig.containerName

Definition at line 828 of file JetAnalysisConfig.py.

◆ jetCollection

str python.JetAnalysisConfig.LargeRJetAnalysisConfig.jetCollection = "AnalysisJets") :

Definition at line 836 of file JetAnalysisConfig.py.

◆ recalibratePhyslite

python.JetAnalysisConfig.LargeRJetAnalysisConfig.recalibratePhyslite

Definition at line 865 of file JetAnalysisConfig.py.

◆ runJERsystematicsOnData

python.JetAnalysisConfig.LargeRJetAnalysisConfig.runJERsystematicsOnData

Definition at line 771 of file JetAnalysisConfig.py.

◆ systematicsModelJER

python.JetAnalysisConfig.LargeRJetAnalysisConfig.systematicsModelJER

Definition at line 711 of file JetAnalysisConfig.py.

◆ systematicsModelJMS

python.JetAnalysisConfig.LargeRJetAnalysisConfig.systematicsModelJMS

Definition at line 711 of file JetAnalysisConfig.py.


The documentation for this class was generated from the following file: