diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx index 18d3eb5af3dc5838438c3bdb466f55b58f5d26dd..604e408b09cce651635c3a5ceae244121d46186f 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/Root/EventSaverFlatNtuple.cxx @@ -4145,6 +4145,13 @@ namespace top { top::check(evtStore()->retrieve(eventInfo, m_config->sgKeyEventInfo()), "Failed to retrieve EventInfo"); + + if(m_config->isDataOverlay()){ + eventInfo->auxdecor<unsigned int>("RandomRunNumber") = eventInfo->runNumber(); + eventInfo->auxdecor<unsigned int>("RandomLumiBlockNumber") = eventInfo->lumiBlock(); + eventInfo->auxdecor<float>("PileupWeight") = 1.; + } + m_weight_mc = eventInfo->auxdataConst<float>("AnalysisTop_eventWeight"); m_eventNumber = eventInfo->eventNumber(); m_runNumber = eventInfo->runNumber(); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx index c5d53cccf598657400103d1415b764eaa853b929..edc6f5aa6718bffb79f6307a4aecd355287480af 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopAnalysis/util/top-xaod.cxx @@ -215,6 +215,7 @@ int main(int argc, char** argv) { } topConfig->setIsMC(isMC); + topConfig->setIsDataOverlay(isOverlay); const bool isPrimaryxAOD = top::isFilePrimaryxAOD(testFile.get()); topConfig->setIsPrimaryxAOD(isPrimaryxAOD); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx index 2f645b9c118040ee1d1ec2910d86f14a6a48e519..69c1931681de0668dc91fa7b0e32f294e5de13dc 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopMuonCPTools.cxx @@ -113,13 +113,14 @@ namespace top { // Muon SF tools now require you to have setup an instance of // the pileup reweighting tool! // If we haven't set it up then tell the user this and exit. - if (!m_config->doPileupReweighting()) { + if (!m_config->doPileupReweighting() and !m_config->isDataOverlay()) { ATH_MSG_ERROR("\nThe Muon SF tools now require that you have" " previously setup an instance of " "the pileup reweighting tool.\n\n" "To do this set the options:\n\n\t" "PRWLumiCalcFiles\n and \n\tPRWConfigFiles \n\n" "in your config file."); + return StatusCode::FAILURE; } diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopTauCPTools.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopTauCPTools.cxx index 9244882e6d08bbb9ce3e79e9993dfd5f1c2a7829..4b9b3272d9d36e3f6a994505fc8fab97430cf1de 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopTauCPTools.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopCPTools/Root/TopTauCPTools.cxx @@ -234,9 +234,13 @@ namespace top { std::unique_ptr<ITauEffCorrTool> tauEffCorrTool = std::make_unique<TauAnalysisTools::TauEfficiencyCorrectionsTool>(tauEffCorrName); if (m_config->isMC()) { - top::check(m_pileupReweightingTool.retrieve(), "Failed to retireve pileup reweighting tool"); - top::check(asg::setProperty(tauEffCorrTool, "PileupReweightingTool", m_pileupReweightingTool), + + + if(!m_config->isDataOverlay()){ + top::check(m_pileupReweightingTool.retrieve(), "Failed to retireve pileup reweighting tool"); + top::check(asg::setProperty(tauEffCorrTool, "PileupReweightingTool", m_pileupReweightingTool), "Failed to set PileupReweightingTool for " + tauEffCorrName); + } top::check(asg::setProperty(tauEffCorrTool, "UseTauSubstructure", m_config->tauSubstructureSF()), "Failed to set UseTauSubstructure for " + tauEffCorrName); @@ -303,9 +307,13 @@ namespace top { std::unique_ptr<ITauEffCorrTool> tauEffCorrTool = std::make_unique<TauAnalysisTools::TauEfficiencyCorrectionsTool>(tauEffCorrNameLoose); if (m_config->isMC()) { - top::check(m_pileupReweightingTool.retrieve(), "Failed to retireve pileup reweighting tool"); - top::check(asg::setProperty(tauEffCorrTool, "PileupReweightingTool", m_pileupReweightingTool), - "Failed to set PileupReweightingTool for " + tauEffCorrNameLoose); + + if(!m_config->isDataOverlay()){ + top::check(m_pileupReweightingTool.retrieve(), "Failed to retireve pileup reweighting tool"); + top::check(asg::setProperty(tauEffCorrTool, "PileupReweightingTool", m_pileupReweightingTool), + "Failed to set PileupReweightingTool for " + tauEffCorrNameLoose); + } + top::check(asg::setProperty(tauEffCorrTool, "UseTauSubstructure", m_config->tauSubstructureSFLoose()), "Failed to set UseTauSubstructure for " + tauEffCorrNameLoose); diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx index c5f455ea61268ad36af17294c30ae9128e993903..e82352ac44cba16f8d770a6a616f20d1605c9ae9 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/ConfigurationSettings.cxx @@ -370,6 +370,7 @@ namespace top { "0"); registerParameter("PerfStats", " I/O Performance printouts. None, Summary or Full", "None"); registerParameter("IsAFII", "Define if you are running over a fastsim sample: True or False", " "); + registerParameter("IsDataOverlay", "Define if you are running over a data overlay MC sample: True or False", " "); registerParameter("FilterBranches", "Comma separated list of names of the branches that will be removed from the output", " "); registerParameter("FilterPartonLevelBranches", diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx index 65f7c7da4116ce27bf754c76bb872ebc35f7c194..3f36e2ff643880638cee9a75412c6a668cf2609f 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopConfig.cxx @@ -17,6 +17,7 @@ #include "TopConfiguration/Tokenize.h" #include "TopConfiguration/MsgCategory.h" + using namespace TopConfiguration; namespace top { @@ -69,6 +70,8 @@ namespace top { m_isMC(false), // Is AFII m_isAFII(false), + // Is Data Overlay + m_isDataOverlay(false), // Generators m_generators("SetMe"), // AMITag @@ -896,6 +899,8 @@ namespace top { ATH_MSG_WARNING("An error was encountered handling AodMetaData : " << aodMetaDataError.what()); ATH_MSG_WARNING("We will attempt to read the IsAFII flag from your config."); this->ReadIsAFII(settings); + ATH_MSG_WARNING("We will attempt to read the IsDataOverlay flag from your config."); + this->ReadIsDataOverlay(settings); ATH_MSG_WARNING("Unfortunately, we can not read MC generators and AMITag without valid MetaData."); this->setGenerators("unknown"); this->setAMITag("unknown"); @@ -1687,6 +1692,10 @@ namespace top { // TRUTH derivations do not contain pile-up weights if (m_isTruthDxAOD) m_pileup_reweighting.apply = false; + + //Switch off PRW for MC samples with data overlay + if(m_isDataOverlay) m_pileup_reweighting.apply = false; + /************************************************************ * * Muon trigger SF configuration @@ -3375,6 +3384,7 @@ namespace top { out->m_isMC = m_isMC; out->m_isAFII = m_isAFII; + out->m_isDataOverlay = m_isDataOverlay; out->m_applyElectronInJetSubtraction = m_applyElectronInJetSubtraction; out->m_doOverlapRemovalOnLooseLeptonDef = m_doOverlapRemovalOnLooseLeptonDef; out->m_doKLFitter = m_doKLFitter; @@ -3529,6 +3539,7 @@ namespace top { m_makeAllCPTools = false; m_isMC = settings->m_isMC; m_isAFII = settings->m_isAFII; + m_isDataOverlay = settings->m_isDataOverlay; m_applyElectronInJetSubtraction = settings->m_applyElectronInJetSubtraction; m_doOverlapRemovalOnLooseLeptonDef = settings->m_doOverlapRemovalOnLooseLeptonDef; m_doKLFitter = settings->m_doKLFitter; @@ -3706,6 +3717,14 @@ namespace top { else if (this->isMC()) throw std::runtime_error("TopConfig: option IsAFII not set"); } + // Set up isDataOverlay + void TopConfig::ReadIsDataOverlay(top::ConfigurationSettings* const& settings) { + if (settings->value("IsDataOverlay") == "True") this->setIsDataOverlay(true); + else if (settings->value("IsDataOverlay") == "False") this->setIsDataOverlay(false); + else if (settings->value("IsDataOverlay") != " ") throw std::runtime_error( + "TopConfig: option IsDataOverlay must be either True or False"); + } + // Function to set the release series (this method may change so refactor) void TopConfig::setReleaseSeries() { // Method taken from TopCPTools diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopPersistentSettings.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopPersistentSettings.cxx index 47a4bdf30d04f205d38c02d9fdfbc5d55f2c18e8..f64349b69574de1308750a928cb4887869705ce7 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopPersistentSettings.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/Root/TopPersistentSettings.cxx @@ -8,6 +8,7 @@ namespace top { TopPersistentSettings::TopPersistentSettings() : m_isMC(false), m_isAFII(false), + m_isDataOverlay(false), m_applyElectronInJetSubtraction(false), m_doOverlapRemovalOnLooseLeptonDef(false), m_doKLFitter(false), diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h index 0c32daeb424ac32c50064d66be445809761588a9..0e6e2a887daa76213421373cbf9aec9a8254c953 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopConfig.h @@ -122,6 +122,14 @@ namespace top { } } + // DataOverlay? + inline bool isDataOverlay() const {return m_isDataOverlay;} + inline void setIsDataOverlay(const bool value) { + if (!m_configFixed) { + m_isDataOverlay = value; + } + } + // List of branches to be removed inline std::vector<std::string> filterBranches() const {return m_filterBranches;} inline void setFilterBranches(const std::vector<std::string>& value) { @@ -2051,6 +2059,7 @@ namespace top { bool m_isMC; bool m_isAFII; + bool m_isDataOverlay; std::vector<std::string> m_filterBranches, m_filterPartonLevelBranches, m_filterParticleLevelBranches, m_filterNominalLooseBranches; std::string m_generators; std::string m_AMITag; @@ -2729,6 +2738,9 @@ namespace top { // Private function only to simplify the setting of AFII values void ReadIsAFII(top::ConfigurationSettings* const& settings); + + // Private function only to simplify the setting of DataOverlay values + void ReadIsDataOverlay(top::ConfigurationSettings* const& settings); // Int holding the release series value int m_release_series; diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopPersistentSettings.h b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopPersistentSettings.h index ed72fa8a0d4f54e7ce514948ce217870da953f6a..aec6ffbc19616d0e7cbcfd2cdda5b7786356e0d9 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopPersistentSettings.h +++ b/PhysicsAnalysis/TopPhys/xAOD/TopConfiguration/TopConfiguration/TopPersistentSettings.h @@ -33,6 +33,7 @@ namespace top { bool m_isMC; bool m_isAFII; + bool m_isDataOverlay; bool m_applyElectronInJetSubtraction; bool m_doOverlapRemovalOnLooseLeptonDef; bool m_doKLFitter; diff --git a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx index be233b338490a6766ca405fdf853c592fde2f82e..602dab6ed8b631424645eb909e81e985b2a1dc44 100644 --- a/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx +++ b/PhysicsAnalysis/TopPhys/xAOD/TopCorrections/Root/MuonScaleFactorCalculator.cxx @@ -165,8 +165,8 @@ namespace top { * which we can get from the PRW tool. * *************************************************************/ - - if (m_config->doPileupReweighting()) { + + if (m_config->isMC()) { const xAOD::EventInfo* eventInfo(nullptr); top::check(evtStore()->retrieve(eventInfo, m_config->sgKeyEventInfo()), "Failed to retrieve EventInfo");