40 m_jetJVT_ConfigFile(
"JVTlikelihood_20140805.root"),
43 m_jetAntiKt4_Data_ConfigFile(
"JES_MC16Recommendation_Consolidated_EMTopo_Apr2019_Rel21.config"),
44 m_jetAntiKt4_Data_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Insitu"),
46 m_jetAntiKt4_MCFS_ConfigFile(
"JES_MC16Recommendation_Consolidated_EMTopo_Apr2019_Rel21.config"),
47 m_jetAntiKt4_MCFS_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Smear"),
49 m_jetAntiKt4_Data_JMS_ConfigFile(
"JES_JMS_MC16Recommendation_Consolidated_data_only_EMTopo_Sep2019_Rel21.config"),
50 m_jetAntiKt4_Data_JMS_CalibSequence(
"JetArea_Residual_EtaJES_GSC_JMS_Insitu"),
52 m_jetAntiKt4_MCFS_JMS_ConfigFile(
"JES_JMS_MC16Recommendation_Consolidated_MC_only_EMTopo_July2019_Rel21.config"),
53 m_jetAntiKt4_MCFS_JMS_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Smear_JMS"),
55 m_jetAntiKt4_MCAFII_ConfigFile(
"JES_MC16Recommendation_AFII_EMTopo_Apr2019_Rel21.config"),
56 m_jetAntiKt4_MCAFII_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Smear"),
60 m_jetAntiKt4_MCAFII_PFlow_ConfigFile(
"JES_MC16Recommendation_AFII_PFlow_Apr2019_Rel21.config"),
61 m_jetAntiKt4_MCAFII_PFlow_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Smear"),
64 m_jetAntiKt4_Data_PFlow_ConfigFile(
"PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.config"),
65 m_jetAntiKt4_Data_PFlow_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Insitu"),
67 m_jetAntiKt4_PFlow_MCFS_ConfigFile(
"PreRec_R22_PFlow_ResPU_EtaJES_GSC_February23_230215.config"),
68 m_jetAntiKt4_PFlow_MCFS_CalibSequence(
"JetArea_Residual_EtaJES_GSC"),
71 m_jetAntiKt4_Data_PFlow_JMS_ConfigFile(
"JES_JMS_MC16Recommendation_Consolidated_data_only_PFlow_July2019_Rel21.config"),
72 m_jetAntiKt4_Data_PFlow_JMS_CalibSequence(
"JetArea_Residual_EtaJES_GSC_JMS_Insitu"),
74 m_jetAntiKt4_PFlow_MCFS_JMS_ConfigFile(
"JES_JMS_MC16Recommendation_Consolidated_MC_only_PFlow_July2019_Rel21.config"),
75 m_jetAntiKt4_PFlow_MCFS_JMS_CalibSequence(
"JetArea_Residual_EtaJES_GSC_Smear_JMS") {
116 ATH_MSG_INFO(
"top::JetMETCPTools: no need to initialise anything on truth DxAOD");
117 return StatusCode::SUCCESS;
134 return StatusCode::SUCCESS;
147 const std::string caloJets_type =
m_config->sgKeyJets();
148 std::string jetCalibrationName;
149 if (caloJets_type ==
"AntiKt4EMTopoNoElJets") {
150 jetCalibrationName =
"AntiKt4EMTopoJets";
152 jetCalibrationName = caloJets_type;
154 jetCalibrationName.erase(jetCalibrationName.length() - 4);
157 if (asg::ToolStore::contains<IJetCalibrationTool>(
"JetCalibrationTool")) {
160 std::string calibConfig, calibSequence;
163 if (
m_config->jetCalibSequence() ==
"JMS") {
164 if (
m_config->allowSmallRJMSforAFII()) {
165 ATH_MSG_WARNING(
"You enabled support for JMS calibration on AFII samples for small-R jets! NOTE that if you want to use this in an analysis, you must get back to JetEtMiss to demonstrate that AFII use is justifiable in your analysis.");
167 ATH_MSG_ERROR(
"The JMS calibration for small-R jets is not supported for AFII samples! If you want to use this in an analysis, you must get back to JetEtMiss to demonstrate that AFII use is justifiable in your analysis. Set config option AllowJMSforAFII to True if you insist on running JMS on AFII.");
168 return StatusCode::FAILURE;
171 if (
m_config->useParticleFlowJets()) {
179 if (
m_config->jetCalibSequence() ==
"JMS") {
180 if (
m_config->useParticleFlowJets()) {
188 if (
m_config->useParticleFlowJets()) {
198 if (
m_config->jetCalibSequence() ==
"JMS") {
199 if (
m_config->useParticleFlowJets()) {
207 if (
m_config->useParticleFlowJets()) {
219 ATH_MSG_INFO(
"JES Calibration Configuration : " << calibConfig);
220 ATH_MSG_INFO(
"JES Calibration Sequence : " << calibSequence);
223 top::check(asg::setProperty(jetCalibrationTool,
"JetCollection", jetCalibrationName),
224 "Failed to set JetCollection " + jetCalibrationName);
225 top::check(asg::setProperty(jetCalibrationTool,
"ConfigFile", calibConfig),
226 "Failed to set ConfigFile " + calibConfig);
227 top::check(asg::setProperty(jetCalibrationTool,
"CalibSequence", calibSequence),
228 "Failed to set CalibSequence " + calibSequence);
233 "Failed to initialize JetCalibrationTool");
242 ATH_MSG_ERROR(
"fJVT and fJVT in MET does not yet work in R22!");
243 return StatusCode::FAILURE;
245 const std::string fjvt_tool_name =
"JetSelectfJvtTool";
246 if (asg::ToolStore::contains<IJetModifier>(fjvt_tool_name)) {
250 top::check(asg::setProperty(JetSelectfJvtTool,
"JvtMomentName",
"NNJvt"),
251 "Failed to set JvtMomentName for JetForwardJvtTool");
255 if (
m_config->getfJVTWP() !=
"Medium"){
256 top::check(asg::setProperty(JetSelectfJvtTool,
"UseTightOP",
true),
257 "Failed to set UseTightOP for JetForwardJvtTool");
259 top::check(asg::setProperty(JetSelectfJvtTool,
"JetContainer",
m_config->sgKeyJets()),
260 "Failed to set JetContainer for JetForwardJvtTool");
261 top::check(asg::setProperty(JetSelectfJvtTool,
"OutputDec",
"AnalysisTop_fJVTdecision"),
262 "Failed to set OutputDec for JetForwardJvtTool");
264 top::check(JetSelectfJvtTool->initialize(),
"Failed to initialize " + fjvt_tool_name);
278 std::string MC_type =
"";
287 ATH_MSG_ERROR(
"No recommendations for fastsim in Run 3 yet!");
288 return StatusCode::FAILURE;
296 std::string conference =
"Summer2023_PreRec";
299 std::string calib_area =
"None";
302 const bool JERisPseudoData = (
m_config->jetJERSmearingModel() ==
"Full_PseudoData") || (
m_config->jetJERSmearingModel() ==
"All_PseudoData");
303 std::string JERSmearModel =
m_config->jetJERSmearingModel();
304 std::string JMSOption =
m_config->jetJMSOption();
305 bool jmsR21Override =
false;
308 if (JMSOption !=
"None") {
310 ATH_MSG_WARNING(
"JMS not yet available for R22 pre-recs - Moving to Spring2021 R21 recommendations!");
311 jmsR21Override =
true;
312 conference =
"Spring2021";
314 if (JMSOption ==
"JMS_frozen") JMSOption =
"_JMS_frozen";
315 else if (JMSOption ==
"JMS_scaled") JMSOption =
"_JMS_scaled";
317 ATH_MSG_ERROR(
"Incorrect JMS option: None, JMS_frozen, JMS_scaled");
318 return StatusCode::FAILURE;
323 if (JERSmearModel ==
"Full_PseudoData") {
324 JERSmearModel =
"Full";
325 ATH_MSG_INFO(
"JER PseudoData option provided - Treating MC as if it is data for JER uncertainty");
327 if (JERSmearModel ==
"All_PseudoData") {
328 JERSmearModel =
"All";
329 ATH_MSG_INFO(
"JER PseudoData option provided - Treating MC as if it is data for JER uncertainty");
333 if (
m_config->jetUncertainties_NPModel() ==
"SR_Scenario1"
334 && JERSmearModel ==
"Simple"
335 && !jmsR21Override) {
337 "\n **********************************************************************************"
338 "\n * NP-Model 'SR_Scenario1' is ONLY supposed to be used for FTAG calibration work! *"
339 "\n * Please choose another model if you are conducting an analysis! *"
340 "\n **********************************************************************************"
344 else if ((!(
m_config->jetUncertainties_NPModel() ==
"CategoryReduction") || !(JERSmearModel ==
"Full"))
345 && !jmsR21Override) {
347 "Incorrect JES/JER config: In R22 phase-1, only NP-Model \"CategoryReduction\" with some type of \"Full\""
348 " JER-smearing is supported for analyses! Your choices might lead to a crash unless you have installed custom"
354 if (JERSmearModel ==
"All") JERSmearModel =
"_AllJERNP";
355 else if (JERSmearModel ==
"Full") JERSmearModel =
"_FullJER";
356 else if (JERSmearModel ==
"Simple") JERSmearModel =
"_SimpleJER";
358 ATH_MSG_ERROR(
"Incorrect JER option: All, All_PseudoData, Full, Full_PseudoData, Simple");
359 return StatusCode::FAILURE;
368 "rel22/" + conference
369 +
"/R4_" +
m_config->jetUncertainties_NPModel()
374 m_config->jetUncertainties_QGFracFile(),
378 if (JERisPseudoData) {
383 "rel22/" + conference
384 +
"/R4_" +
m_config->jetUncertainties_NPModel()
389 m_config->jetUncertainties_QGFracFile(),
405 +
"/R4_SR_Scenario1_SimpleJER"
409 m_config->jetUncertainties_QGFracFile(),
418 +
"/R4_SR_Scenario2_SimpleJER"
422 m_config->jetUncertainties_QGFracFile(),
431 +
"/R4_SR_Scenario3_SimpleJER"
435 m_config->jetUncertainties_QGFracFile(),
444 +
"/R4_SR_Scenario4_SimpleJER"
448 m_config->jetUncertainties_QGFracFile(),
452 return StatusCode::SUCCESS;
456 std::string jetCalibrationNameLargeR =
m_config->sgKeyLargeRJets();
457 jetCalibrationNameLargeR.erase(jetCalibrationNameLargeR.length() - 4);
461 std::string calibConfigLargeR =
"";
462 std::string calibSequenceLargeR =
"EtaJES_JMS";
463 const std::string calibAreaLargeR =
"00-04-82";
464 const std::string calibChoice =
m_config->largeRJESJMSConfig();
466 if (asg::ToolStore::contains<IJetCalibrationTool>(
"JetCalibrationToolLargeR")) {
471 if (calibChoice !=
"UFOSDMass") {
473 "Unknown largeRJESJMSConfig (Available options: UFOSDMass)) : " + calibChoice);
474 return StatusCode::FAILURE;
478 if (calibChoice ==
"UFOSDMass") {
479 calibConfigLargeR =
"JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_10Mar2023.config";
482 if (calibChoice ==
"UFOSDMass") {
483 calibConfigLargeR =
"JES_MC20PreRecommendation_R10_UFO_CSSK_SoftDrop_JMS_R21Insitu_10Mar2023.config";
488 if (calibChoice ==
"UFOSDMass") {
489 calibSequenceLargeR =
"EtaJES_JMS_Insitu";
495 top::check(asg::setProperty(jetCalibrationToolLargeR,
"JetCollection", jetCalibrationNameLargeR),
496 "Failed to set JetCollection " + jetCalibrationNameLargeR);
497 top::check(asg::setProperty(jetCalibrationToolLargeR,
"ConfigFile", calibConfigLargeR),
498 "Failed to set ConfigFile " + calibConfigLargeR);
499 top::check(asg::setProperty(jetCalibrationToolLargeR,
"CalibSequence", calibSequenceLargeR),
500 "Failed to set CalibSequence " + calibSequenceLargeR);
501 top::check(asg::setProperty(jetCalibrationToolLargeR,
"CalibArea", calibAreaLargeR),
502 "Failed to set CalibArea " + calibAreaLargeR);
506 "Failed to initialize JetCalibrationToolLargeR");
510 std::string configDir(
"");
511 std::string largeRJESJERJMS_unc_config =
m_config->largeRJetUncertainties_NPModel();
512 std::string largeRJMR_unc_config =
m_config->largeRJetUncertainties_JMR_NPModel();
513 std::string calibArea =
"None";
514 std::string MC_type =
"MC20";
517 if (
m_config->isRun3()) MC_type =
"MC21";
519 configDir =
m_config->largeRJetUncertaintiesConfigDir();
522 ATH_MSG_WARNING(
"No large-R jet uncertainty prescriptions are available yet!");
550 return StatusCode::SUCCESS;
557 const std::string ff_tool_name =
"FFJetSmearingTool";
559 const std::string mass_def_name = mass_def.substr(0, mass_def.size()-4);
563 if (asg::ToolStore::contains<ICPJetCorrectionTool>(ff_tool_name)) {
564 tool = asg::ToolStore::get<ICPJetCorrectionTool>(ff_tool_name);
567 top::check(asg::setProperty(
tool,
"MassDef", mass_def_name ),
"Failed to set proper MassDef for FFJetSmearingTool" );
568 top::check(asg::setProperty(
tool,
"ConfigFile",
config ),
"Failed to set proper config file for FFJetSmearingTool" );
569 top::check(
tool->initialize(),
"Failed to initialize " + ff_tool_name );
582 const std::string jvt_tool_name =
"JetJvtEfficiencyTool";
586 std::string JVT_SFFile =
"DummySFs.root";
587 const std::string JVT_WP =
m_config->getJVTWP();
589 if (asg::ToolStore::contains<CP::IJetJvtEfficiency>(jvt_tool_name)) {
590 m_jetJvtTool = asg::ToolStore::get<CP::IJetJvtEfficiency>(jvt_tool_name);
593 top::check(jetJvtTool->setProperty(
"TaggingAlg", JVT_Algo),
594 "Failed to set JVT Algorithm");
595 top::check(jetJvtTool->setProperty(
"WorkingPoint", JVT_WP),
596 "Failed to set JVT WP");
597 top::check(jetJvtTool->setProperty(
"SFFile", JVT_SFFile),
598 "Failed to set JVT SFFile name");
599 top::check(jetJvtTool->setProperty(
"JetJvtMomentName",
"NNJvt"),
600 "Failed to set NNJvt decoration name");
601 top::check(jetJvtTool->setProperty(
"TruthLabel",
"AnalysisTop_isHS"),
602 "Failed to set JVT TruthLabel decoration name");
604 "Failed to set JVT TruthJetContainerName decoration name");
615 if (
m_config->getfJVTWP() !=
"None") {
616 const std::string fjvt_tool_name =
"JetForwardJvtEfficiencyTool";
617 const std::string fJVT_SFFile =
619 "JetJvtEfficiency/May2020/fJvtSFFile.EMPFlow.root" :
620 "JetJvtEfficiency/May2020/fJvtSFFile.EMtopo.root";
621 std::string fJVT_WP =
m_config->getfJVTWP();
622 if (fJVT_WP ==
"Medium") {
628 if (asg::ToolStore::contains<CP::IJetJvtEfficiency>(fjvt_tool_name)) {
629 m_jetfJvtTool = asg::ToolStore::get<CP::IJetJvtEfficiency>(fjvt_tool_name);
632 top::check(jetfJvtTool->setProperty(
"TaggingAlg", fJVT_Algo),
633 "Failed to set fJVT Algorithm");
634 top::check(jetfJvtTool->setProperty(
"WorkingPoint", fJVT_WP),
635 "Failed to set fJVT WP");
636 top::check(jetfJvtTool->setProperty(
"SFFile", fJVT_SFFile),
637 "Failed to set fJVT SFFile name");
638 top::check(jetfJvtTool->setProperty(
"UseMuSFFormat",
true),
639 "Failed to set fJVT SFFile to updated mu binning");
640 top::check(jetfJvtTool->setProperty(
"ScaleFactorDecorationName",
"fJVTSF"),
641 "Failed to set fJVT SF decoration name");
642 top::check(jetfJvtTool->setProperty(
"JetJvtMomentName",
"DFCommonJets_fJvt"),
643 "Failed to set fJVT pass/fail decoration name");
644 top::check(jetfJvtTool->setProperty(
"TruthLabel",
"AnalysisTop_isHS"),
645 "Failed to set fJVT TruthLabel decoration name");
647 "Failed to set fJVT TruthJetContainerName decoration name");
652 return StatusCode::SUCCESS;
659 if (asg::ToolStore::contains<IMETMaker>(
"met::METMaker")) {
660 m_met_maker = asg::ToolStore::get<IMETMaker>(
"met::METMaker");
664 "Failed to set METMaker Jvt WP");
666 if (
m_config->useParticleFlowJets()) {
667 top::check(metMaker->setProperty(
"DoPFlow",
true),
"Failed to set METMaker DoPFlow to true");
670 if (
m_config->doForwardJVTinMET()) {
671 if (
m_config->getfJVTWP() ==
"Medium") {
672 top::check(metMaker->setProperty(
"JetSelection",
"Tenacious"),
673 "Failed to set METMaker JetSelection to Tenacious");
675 top::check(metMaker->setProperty(
"JetRejectionDec",
"DFCommonJets_fJvt"),
676 "Failed to set METMaker JetRejectionDec to DFCommonJets_fJvt");
679 metMaker->
msg().setLevel(MSG::INFO);
684 if (asg::ToolStore::contains<IMETSystematicsTool>(
"met::METSystematicsTool")) {
685 m_met_systematics = asg::ToolStore::get<IMETSystematicsTool>(
"met::METSystematicsTool");
689 std::string METconfigDir =
m_config->METUncertaintiesConfigDir();
690 if (METconfigDir ==
"Latest") METconfigDir =
"METUtilities/R22_PreRecs";
691 top::check(metSyst->setProperty(
"ConfigPrefix", METconfigDir),
"Failed to set METsyst calibration area");
693 if (
m_config->useParticleFlowJets()) {
694 top::check(metSyst->setProperty(
"ConfigSoftTrkFile",
"TrackSoftTerms-pflow.config"),
"Failed to set property");
696 if (
m_config->isAFII() && METconfigDir ==
"METUtilities/data17_13TeV/prerec_Jan16/") {
697 top::check(metSyst->setProperty(
"ConfigSoftTrkFile",
"TrackSoftTerms_AFII.config"),
"Failed to set property");
699 top::check(metSyst->setProperty(
"ConfigSoftTrkFile",
"TrackSoftTerms.config"),
"Failed to set property");
703 top::check(metSyst->setProperty(
"ConfigSoftCaloFile",
""),
"Failed to set property");
709 if (asg::ToolStore::contains<IMETSignificance>(
"metSignificance")) {
710 m_metSignif = asg::ToolStore::get<IMETSignificance>(
"metSignificance");
714 if (
m_config->METSignifSoftTermParam().compare(
"Random")==0) {
716 }
else if (
m_config->METSignifSoftTermParam().compare(
"PthardParam")==0) {
718 }
else if (
m_config->METSignifSoftTermParam().compare(
"TSTParam")==0) {
721 ATH_MSG_ERROR(
"top::JetMETCPTools: Unkown SoftTermParam for MetSignificance");
724 top::check(metSignificance->setProperty(
"SoftTermParam", softTerm),
"Failed to set MetSignificance::SoftTermParam!");
725 top::check(metSignificance->setProperty(
"DoPhiReso",
true),
"Failed to set MetSignificance::DoPhiReso!");
726 top::check(metSignificance->setProperty(
"IsDataJet",
false),
"Failed to set MetSignificance::IsDataJet!");
727 top::check(metSignificance->setProperty(
"IsAFII",
m_config->isAFII()),
"Failed to set MetSignificance::IsAFII!");
730 std::string deleteString =
"Jets";
735 top::check(metSignificance->setProperty(
"TreatPUJets",(
jetCollectionName !=
"AntiKt4EMTopo") || (
m_config->doForwardJVTinMET()) ),
"Failed to set MetSignificance::TreatPUJets!");
741 return StatusCode::SUCCESS;
746 const std::string& jet_def,
747 const std::string& mc_type,
749 const std::string& config_file,
751 const std::string& analysis_file,
752 const std::string& calib_area
756 if (asg::ToolStore::contains<ICPJetUncertaintiesTool>(
name)) {
757 tool = asg::ToolStore::get<ICPJetUncertaintiesTool>(
name);
761 "Failed to set JetDefinition for " +
name);
763 "Failed to set MCType for " +
name);
765 "Failed to set IsData (for JER only)");
767 "Failed to set ConfigFile for " +
name);
770 "Failed to set VariablesToShift for LargeR Jes Uncertainty " +
name);
772 if (analysis_file !=
"None") {
773 if (
m_config->jetUncertainties_QGHistPatterns().size() == 0 || analysis_file ==
"") {
775 "Failed to set AnalysisFile for " +
name);
776 }
else if (
m_config->jetUncertainties_QGHistPatterns().size() == 1) {
778 "Failed to set AnalysisFile for " +
name);
780 "Failed to set AnalysisHistPattern for " +
name);
783 for (
auto s :
m_config->jetUncertainties_QGHistPatterns()) {
786 "Failed to set AnalysisFile for " +
name);
788 "Failed to set AnalysisHistPattern for " +
name);
795 if (calib_area !=
"None") {
797 "Failed to set CalibArea " + calib_area);
807 std::string
name =
"JetCleaningTool" +
WP;
808 if (asg::ToolStore::contains<IJetSelector>(
name)) {
809 tool = asg::ToolStore::get<IJetSelector>(
name);
813 "Failed to set CutLevel to " +
WP +
" for " +
name);
815 "Failed to set DoUgly for " +
name);
817 "Failed to set UserDecorations for " +
name);
824 const ToolHandle<IJetSelector>& JetCleaningToolHandle)
827 std::string
name =
"JetEventCleaningTool" +
WP;
828 if (asg::ToolStore::contains<ECUtils::IEventCleaningTool>(
name)) {
829 tool = asg::ToolStore::get<ECUtils::IEventCleaningTool>(
name);
833 "Failed to set jet container name for JetEventCleaningTool");
835 "Failed to set jet pt cut in JetEventCleaningTool");
837 "Failed to set jet eta cut in JetEventCleaningTool");
839 "Failed to set JVT property in JetEventCleaningTool");
840 std::string OrDecorator =
"";
841 if (
m_config->doLooseEvents()) OrDecorator =
"ORToolDecorationLoose";
842 else OrDecorator =
"ORToolDecoration";
844 "Failed to set jet OR decoration in JetEventCleaningTool");
846 "Failed to set jet WP " +
WP +
" in JetEventCleaningTool");
847 top::check(asg::setProperty(
tool,
"JetCleaningTool", JetCleaningToolHandle),
848 "Failed to associate the JetCleaningTool object to JetEventCleaningTool");