Commit 8effcbf1 authored by Iwona Grabowska-Bold's avatar Iwona Grabowska-Bold Committed by Nils Erik Krumnack
Browse files

Support in AnalysisTop for MC samples with data overlay

parent b67d6ddb
......@@ -3721,6 +3721,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();
......
......@@ -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);
......
......@@ -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;
}
......
......@@ -238,9 +238,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);
......@@ -307,9 +311,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);
......
......@@ -390,6 +390,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",
......
......@@ -17,6 +17,7 @@
#include "TopConfiguration/Tokenize.h"
#include "TopConfiguration/MsgCategory.h"
using namespace TopConfiguration;
namespace top {
......@@ -70,6 +71,8 @@ namespace top {
m_isMC(false),
// Is AFII
m_isAFII(false),
// Is Data Overlay
m_isDataOverlay(false),
// Generators
m_generators("SetMe"),
// AMITag
......@@ -959,6 +962,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");
......@@ -1758,6 +1763,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
......@@ -3462,6 +3471,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;
......@@ -3616,6 +3626,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;
......@@ -3793,6 +3804,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
......
......@@ -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),
......
......@@ -123,6 +123,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) {
......@@ -2096,6 +2104,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;
......@@ -2782,6 +2791,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;
......
......@@ -33,6 +33,7 @@ namespace top {
bool m_isMC;
bool m_isAFII;
bool m_isDataOverlay;
bool m_applyElectronInJetSubtraction;
bool m_doOverlapRemovalOnLooseLeptonDef;
bool m_doKLFitter;
......
......@@ -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");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment