diff --git a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrection.cxx b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrection.cxx index b072f9e15735b813895332aa679fa8168fbd1451..929e851a0fdb86397a0b90f38257d5513a6a8204 100644 --- a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrection.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrection.cxx @@ -531,19 +531,19 @@ namespace CP { m_graph_dd_2015_cone20_conv_photon_shift.push_back( (TGraph*) file_ptleakagecorr->Get("topoetcone20_DataDriven_converted_photon_eta_1.81_2.37_2015")); } - for (auto gr : m_graph_dd_2015_cone40_conv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_cone40_conv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (conv,40)"); } - for (auto gr : m_graph_dd_2015_cone40_unconv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_cone40_unconv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (unconv,40)"); } - for (auto gr : m_graph_dd_2015_cone20_conv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_cone20_conv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (conv,20)"); } - for (auto gr : m_graph_dd_2015_cone20_unconv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_cone20_unconv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (unconv, 20)"); } @@ -600,19 +600,19 @@ namespace CP { m_graph_dd_2015_2016_cone20_conv_photon_shift.push_back( (TGraph*) file_ptleakagecorr->Get("topoETcone20_DataDriven_converted_photon_eta_1.81_2.37_2016")); } - for (auto gr : m_graph_dd_2015_2016_cone40_conv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_2016_cone40_conv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (conv,40)"); } - for (auto gr : m_graph_dd_2015_2016_cone40_unconv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_2016_cone40_unconv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (unconv,40)"); } - for (auto gr : m_graph_dd_2015_2016_cone20_conv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_2016_cone20_conv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (conv,20)"); } - for (auto gr : m_graph_dd_2015_2016_cone20_unconv_photon_shift) { + for (TGraph* gr : m_graph_dd_2015_2016_cone20_unconv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (unconv, 20)"); } @@ -668,19 +668,19 @@ namespace CP { m_graph_dd_2017_cone20_conv_photon_shift.push_back( (TGraph*) file_ptleakagecorr->Get("topoETcone20_DataDriven_converted_photon_eta_1.81_2.37_2017")); } - for (auto gr : m_graph_dd_2017_cone40_conv_photon_shift) { + for (TGraph* gr : m_graph_dd_2017_cone40_conv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (conv,40)"); } - for (auto gr : m_graph_dd_2017_cone40_unconv_photon_shift) { + for (TGraph* gr : m_graph_dd_2017_cone40_unconv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (unconv,40)"); } - for (auto gr : m_graph_dd_2017_cone20_conv_photon_shift) { + for (TGraph* gr : m_graph_dd_2017_cone20_conv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (conv,20)"); } - for (auto gr : m_graph_dd_2017_cone20_unconv_photon_shift) { + for (TGraph* gr : m_graph_dd_2017_cone20_unconv_photon_shift) { if (gr == nullptr) ATH_MSG_ERROR("Null pointer for one of the DD correction bins (unconv, 20)"); } diff --git a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx index c1b59deb5cd4f55e82d36e1cd3ea157dcf33a39a..cdea7c5406764d6a0d8ea19ba8fc82027fd3ea15 100644 --- a/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx +++ b/PhysicsAnalysis/ElectronPhotonID/IsolationCorrections/Root/IsolationCorrectionTool.cxx @@ -23,12 +23,12 @@ namespace CP { IsolationCorrectionTool::IsolationCorrectionTool( const std::string &name ) : asg::AsgMetadataTool(name), m_systDDonoff("PH_Iso_DDonoff"){ declareProperty("CorrFile", m_corr_file = "IsolationCorrections/v1/isolation_ptcorrections_rel20_2.root"); - declareProperty("CorrFile_ddshift_2015_2016", m_corr_ddshift_2015_2016_file = "PhotonEfficiencyCorrection/2015_2017/rel21.2/Winter2018_Prerec_v1/isolation/isolation_ddcorrection_shift_rel21_2016.root"); - declareProperty("CorrFile_ddshift_2017", m_corr_ddshift_2017_file = "PhotonEfficiencyCorrection/2015_2017/rel21.2/Winter2018_Prerec_v1/isolation/isolation_ddcorrection_shift_rel21_2017.root"); + declareProperty("CorrFile_ddshift_2015_2016", m_corr_ddshift_2015_2016_file = "PhotonEfficiencyCorrection/2015_2017/rel21.2/Winter2018_Prerec_v1/isolation/isolation_ddcorrection_shift_REL21_2016.root"); + declareProperty("CorrFile_ddshift_2017", m_corr_ddshift_2017_file = "PhotonEfficiencyCorrection/2015_2017/rel21.2/Winter2018_Prerec_v1/isolation/isolation_ddcorrection_shift_REL21_2017.root"); declareProperty("CorrFile_ddsmearing", m_corr_ddsmearing_file = "IsolationCorrections/v1/isolation_ddcorrection_smearing.root"); declareProperty("ToolVer", m_tool_ver_str = "REL21"); - declareProperty("DataDrivenVer", m_ddVersion = "2015_2016"); - declareProperty("UseMetadata", m_usemetadata = true); + declareProperty("DataDrivenVer", m_ddVersion = "2017"); + declareProperty("UseMetadata", m_usemetadata = false); declareProperty("AFII_corr", m_AFII_corr = false); declareProperty("IsMC", m_is_mc = true); declareProperty("Correct_etcone", m_correct_etcone = false); @@ -91,18 +91,20 @@ namespace CP { m_isol_corr->SetToolVer(tool_ver); m_isol_corr->SetTroubleCategories(m_trouble_categories); - - // If Default is false, there is no correction, and no topoEtconeXX systematic uncertainty ! + // Note that systematics in Rel 21 are NOT done with the DD-Corr ON/OFF method! if (m_apply_ddDefault) { if (m_ddVersion == "2015_2016" or m_ddVersion == "2017") { - //register ourselves with the systematic registry! - CP::SystematicRegistry& registry = CP::SystematicRegistry::getInstance(); - if( registry.registerSystematics( *this ) != CP::SystematicCode::Ok ) return StatusCode::FAILURE; - } else - ATH_MSG_WARNING("Unknown data driven correction"); - } else{ - m_apply_dd = false; - } + //if not REL21, register ourselves with the systematic registry! + if( m_tool_ver_str!="REL21" ){ + CP::SystematicRegistry& registry = CP::SystematicRegistry::getInstance(); + if( registry.registerSystematics( *this ) != CP::SystematicCode::Ok ) return StatusCode::FAILURE; + } + m_apply_dd = true; + } else{ + ATH_MSG_WARNING("Unknown data driven correction"); + m_apply_dd = false; + } + } else m_apply_dd = false; // Don't use DD Corrections for AFII (not yet available for mc16) if( m_tool_ver_str == "REL21" && m_AFII_corr) m_apply_dd = false; @@ -175,10 +177,10 @@ namespace CP { } // // Check if tag is from mc16a of mc16c (determines which year of DD corrections to use) - std::string amiTag; - fmd->value(xAOD::FileMetaData::amiTag, amiTag); // AMI tag used to process the file the last time - if (TPRegexp("r9364").MatchB(amiTag)) { m_ddVersion = "2015_2016" ; } // mc16a - else if (TPRegexp("r9781").MatchB(amiTag)) { m_ddVersion = "2017" ; } // mc16c +// std::string amiTag; +// fmd->value(xAOD::FileMetaData::amiTag, amiTag); // AMI tag used to process the file the last time +// if (TPRegexp("r9364").MatchB(amiTag)) { m_ddVersion = "2015_2016" ; } // mc16a +// else if (TPRegexp("r9781").MatchB(amiTag)) { m_ddVersion = "2017" ; } // mc16c // return StatusCode::SUCCESS; } @@ -242,7 +244,7 @@ namespace CP { // //If not metadata have been available and want to use them go via event info const xAOD::EventInfo* evtInfo(0); - if( (evtStore()->retrieve(evtInfo, "")).isFailure()){ + if( (evtStore()->retrieve(evtInfo, "EventInfo")).isFailure()){ ATH_MSG_WARNING(" No default Event Info collection found") ; return StatusCode::SUCCESS; } @@ -304,12 +306,31 @@ namespace CP { float oldiso = 0; bool gotIso = eg.isolationValue(oldiso,type); if (!gotIso) continue; - if (eg.pt() > 25e3) - ATH_MSG_DEBUG("pt = " << eg.pt() << " eta = " << eg.eta() << ", def Iso " << xAOD::Iso::toString(type) << " = " << oldiso - << " old leak = " << oldleak << " new leak = " << newleak); +// if (eg.pt() > 25e3) +// ATH_MSG_DEBUG("pt = " << eg.pt() << " eta = " << eg.eta() << ", def Iso " << xAOD::Iso::toString(type) << " = " << oldiso +// << " old leak = " << oldleak << " new leak = " << newleak); + + // Use the Random Run Number from the Event Info to check which year's DD-Corrections to use + // If the RandomRunNo can't be obtained, then default to what is set by either the default choice or by the AuxData check + unsigned int theRunNumber = 0 ; + const xAOD::EventInfo *eventInfo = evtStore()->retrieve< const xAOD::EventInfo>("EventInfo"); + if(eventInfo){ + static const SG::AuxElement::Accessor<unsigned int> randomrunnumber("RandomRunNumber"); + if(randomrunnumber.isAvailable(*eventInfo)){ + theRunNumber = randomrunnumber(*(eventInfo)) ; + } + } else ATH_MSG_WARNING("Could not retrieve EventInfo object"); + if (theRunNumber>=300000) m_ddVersion = "2017" ; // RunNo found, and is in 2017 range + else if( theRunNumber > 0 ) m_ddVersion = "2015_2016" ; // RunNo found, but less than 2017 range + // otherwise, stick with default (m_ddVersion is already assigned) + + // Don't use DD Corrections for AFII (not yet available for mc16) + if( m_tool_ver_str == "REL21" && m_AFII_corr) m_apply_dd = false; + float iso = oldiso + (oldleak-newleak); float ddcorr = 0; if (m_is_mc && m_apply_dd && type != xAOD::Iso::topoetcone30) { + ddcorr = this->GetDDCorrection(eg,type); if (type == xAOD::Iso::topoetcone20) decDDcor20(eg) = ddcorr; @@ -317,8 +338,7 @@ namespace CP { decDDcor40(eg) = ddcorr; iso += ddcorr; } - if (eg.pt() > 25e3) - ATH_MSG_DEBUG("ddcor = " << ddcorr << " new Iso = " << iso << "\n"); + //if (eg.pt() > 25e3) ATH_MSG_DEBUG("ddcor = " << ddcorr << " new Iso = " << iso << "\n"); bool setIso = eg.setIsolationValue(iso,type); setIso = (setIso && eg.setIsolationCaloCorrection(newleak-ddcorr,type,xAOD::Iso::ptCorrection)); if (!setIso) { @@ -335,7 +355,7 @@ namespace CP { float IsolationCorrectionTool::GetPtCorrection(const xAOD::Egamma& input, xAOD::Iso::IsolationType isol) const { return m_isol_corr->GetPtCorrection(input, isol); } - + float IsolationCorrectionTool::GetDDCorrection(const xAOD::Egamma& input, xAOD::Iso::IsolationType isol){ if (m_ddVersion == "2015_2016") { // corrections derived in 2018 (Rel 21), 2015+2016 data return m_isol_corr->GetDDCorrection_2015_2016(input, isol); @@ -374,10 +394,8 @@ namespace CP { CP::SystematicSet IsolationCorrectionTool::affectingSystematics() const { CP::SystematicSet result; - - if (m_apply_ddDefault) - result.insert( m_systDDonoff ); - +// if (m_apply_ddDefault && m_tool_ver_str!="REL21") +// result.insert( m_systDDonoff ); return result; } @@ -386,10 +404,6 @@ namespace CP { } CP::SystematicCode IsolationCorrectionTool::applySystematicVariation( const CP::SystematicSet& systConfig ) { - if (systConfig.find(m_systDDonoff) != systConfig.end()) - m_apply_dd = false; - else - m_apply_dd = m_apply_ddDefault ? true : false; return CP::SystematicCode::Ok; }