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 612 of file JetAnalysisConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.JetAnalysisConfig.LargeRJetAnalysisConfig.__init__ ( self)

Definition at line 615 of file JetAnalysisConfig.py.

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

Member Function Documentation

◆ createFFSmearingTool()

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

Definition at line 779 of file JetAnalysisConfig.py.

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

◆ 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 741 of file JetAnalysisConfig.py.

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

◆ getUncertaintyToolSettings()

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

Definition at line 690 of file JetAnalysisConfig.py.

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

◆ instanceName()

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

Definition at line 686 of file JetAnalysisConfig.py.

686 def instanceName (self) :
687 """Return the instance name for this block"""
688 return self.containerName
689

◆ makeAlgs()

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

Definition at line 818 of file JetAnalysisConfig.py.

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

Member Data Documentation

◆ containerName

python.JetAnalysisConfig.LargeRJetAnalysisConfig.containerName

Definition at line 821 of file JetAnalysisConfig.py.

◆ jetCollection

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

Definition at line 829 of file JetAnalysisConfig.py.

◆ recalibratePhyslite

python.JetAnalysisConfig.LargeRJetAnalysisConfig.recalibratePhyslite

Definition at line 858 of file JetAnalysisConfig.py.

◆ runJERsystematicsOnData

python.JetAnalysisConfig.LargeRJetAnalysisConfig.runJERsystematicsOnData

Definition at line 764 of file JetAnalysisConfig.py.

◆ systematicsModelJER

python.JetAnalysisConfig.LargeRJetAnalysisConfig.systematicsModelJER

Definition at line 704 of file JetAnalysisConfig.py.

◆ systematicsModelJMS

python.JetAnalysisConfig.LargeRJetAnalysisConfig.systematicsModelJMS

Definition at line 704 of file JetAnalysisConfig.py.


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