23 IsolationCorrectionTool::IsolationCorrectionTool(
const std::string &
name )
24 : asg::AsgMetadataTool(
name), m_systDDonoff(
"PH_Iso_DDonoff") {
25 declareProperty(
"CorrFile", m_corr_file =
"IsolationCorrections/v5/isolation_ptcorrections_rel20_2.root") ;
26 declareProperty(
"CorrFile_ddshift", m_corr_ddshift_file =
"IsolationCorrections/v3/isolation_ddcorrection_shift.root");
27 declareProperty(
"CorrFile_ddsmearing", m_corr_ddsmearing_file =
"IsolationCorrections/v1/isolation_ddcorrection_smearing.root",
"a run I smearing for MC calo iso");
28 declareProperty(
"ToolVer", m_tool_ver_str =
"REL21");
29 declareProperty(
"DataDrivenVer", m_ddVersion =
"2017");
30 declareProperty(
"AFII_corr", m_AFII_corr =
false);
31 declareProperty(
"IsMC", m_is_mc =
true);
32 declareProperty(
"Correct_etcone", m_correct_etcone =
false);
33 declareProperty(
"Trouble_categories", m_trouble_categories =
true);
34 declareProperty(
"LogLogFitForLeakage", m_useLogLogFit =
false);
35 declareProperty(
"FixTimingIssueInCore", m_fixCoreTime =
false);
36 declareProperty(
"ForcePartType", m_forcePartType =
false);
37 declareProperty(
"Apply_ddshifts", m_apply_ddDefault =
false);
38 declareProperty(
"Apply_SC_leakcorr", m_apply_SC_leak_corr =
false);
39 declareProperty(
"Apply_etaEDParPU_correction", m_apply_etaEDParPU_corr =
false);
40 declareProperty(
"Apply_etaEDPar_mc_correction", m_apply_etaEDParPU_mc_corr =
false);
41 declareProperty(
"CorrFile_etaEDParPU_correction", m_corr_etaEDParPU_file =
"IsolationCorrections/v6/zetas.root");
42 declareProperty(
"CorrFile_etaEDPar_mc_correction", m_corr_etaEDPar_mc_corr_file =
"IsolationCorrections/v6/zetas_correction.root");
44 m_isol_corr =
new IsolationCorrection(name);
59 std::vector < std::string > corrFileNameList;
64 for (
unsigned int i=0; i<corrFileNameList.size(); ++i ){
68 if (filename.empty()){
69 ATH_MSG_ERROR (
"Could NOT resolve file name " << corrFileNameList.at(i) );
70 return StatusCode::FAILURE ;
74 corrFileNameList.at(i) = filename;
86 return StatusCode::FAILURE;
89 if(TString(corrFileNameList[0]).Contains(
"isolation_ptcorrections_rel17_2.root") &&
m_tool_ver_str !=
"REL17_2"){
91 return StatusCode::FAILURE;
94 if (TString(corrFileNameList[0]).Contains(
"isolation_ptcorrections_rel20_2.root") && !(
m_tool_ver_str ==
"REL20_2" ||
m_tool_ver_str ==
"REL21" ) ){
96 return StatusCode::FAILURE;
98 if (TString(corrFileNameList[0]).Contains(
"isolation_ptcorrections_rel22_") &&
m_tool_ver_str !=
"REL22" ){
100 return StatusCode::FAILURE;
115 if( registry.
registerSystematics( *
this ) != StatusCode::SUCCESS )
return StatusCode::FAILURE;
134 if (filename.empty()){
136 return StatusCode::FAILURE ;
139 std::unique_ptr<TFile> f(TFile::Open(filename.c_str(),
"READ"));
148 if (filename.empty()){
150 return StatusCode::FAILURE ;
153 std::unique_ptr<TFile> f_corr(TFile::Open(filename.c_str(),
"READ"));
173 for (
auto type : topoisolation_types) {
181 if (!eg.isolationValue(iso,
type)) {
185 iso += (oldleak-newleak);
186 bool setIso = eg.setIsolationValue(iso,
type);
201 for(
auto type : topoisolation_types){
202 float Etcone_value_corr =
m_isol_corr->GetPtCorrectedIsolation(eg,
type);
203 eg.setIsolationValue(Etcone_value_corr,
type);
220 float topoetconecoreConeEnergyCorrection = 0;
226 ATH_MSG_WARNING(
"Could not find core57cells to apply SC based core correction");
229 ATH_MSG_VERBOSE(
"SC based core correction value: " << topoetconecoreConeEnergyCorrection);
230 SCsub = - topoetconecoreConeEnergyCorrection +
core57cells;
233 float centralDensity = 0.;
234 float forwardDensity = 0.;
247 for (
auto type : topoisolation_types) {
254 bool gotIso = eg.isolationValue(oldiso,
type);
255 if (!gotIso)
continue;
259 unsigned int theRunNumber = 0 ;
265 theRunNumber = randomrunnumber(*(eventInfo)) ;
270 if (theRunNumber >= 320000)
272 else if (theRunNumber > 0)
283 iso += (SCsub + oldleak);
288 iso += (oldleak - newleak);
294 float abseta = fabs(eg.caloCluster()->etaBE(2));
295 float densityOldCorrection = 0.;
297 densityOldCorrection = centralDensity;
300 densityOldCorrection = forwardDensity;
303 static const float a_core = 5*7*0.025*TMath::Pi()/128;
304 float area = TMath::Pi()*dR*dR-a_core;
305 float oldpu_corr = densityOldCorrection*
area;
307 float pu_mc_corr = 0.;
311 iso = iso + oldpu_corr - newpu_corr + pu_mc_corr;
312 ATH_MSG_VERBOSE(
"Applying parametrized pileup correction to " << eg.type() <<
" with |eta|="<< abseta);
321 float coshEta = std::cosh(eg.caloCluster()->etaBE(2)) ;
322 float outTimeCore = (decEadded_Lr2(eg) + decEadded_Lr3(eg))/coshEta ;
328 decDDcor20(eg) = ddcorr;
330 decDDcor40(eg) = ddcorr;
333 bool setIso = eg.setIsolationValue(iso,
type);
335 ATH_MSG_VERBOSE(
"oldeak = " << oldleak <<
" ddcor = " << ddcorr <<
" leak param = " << newleak
347 return m_isol_corr->GetPtCorrectedIsolation(input, isol);
360 if( output )
ATH_MSG_WARNING(
"Non-null pointer received. There's a possible memory leak!" );
364 output->makePrivateStore(
static_cast<const xAOD::Electron&
>(input) );
369 output->makePrivateStore(
static_cast<const xAOD::Photon&
>(input) );
382 return sys.find( systematic ) != sys.end();
395 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Return value from object correction CP tools.
@ Error
Some error happened during the object correction.
@ Ok
The correction was done successfully.
This module implements the central registry for handling systematic uncertainties with CP tools.
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
StatusCode registerSystematics(const IReentrantSystematicsTool &tool)
effects: register all the systematics from the tool
Class to wrap a set of SystematicVariations.
SG::Accessor< T, ALLOC > Accessor
bool isAvailable(const ELT &e) const
Test to see if this variable exists in the store.
const_pointer_type ptr()
Dereference the pointer.
uint32_t runNumber() const
The current event's run number.
bool getDensity(EventDensityID id, double &v) const
Get a density variable from the object.
Select isolated Photons, Electrons and Muons.
@ Photon
The object is a photon.
@ Electron
The object is an electron.
IsolationType
Overall enumeration for isolation types in xAOD files.
@ topoetcone20
Topo-cluster ET-sum.
@ etcone20
Calorimeter isolation.
@ topoetcone
Topo-cluster ET-sum.
static const char * toCString(IsolationConeSize conesize)
@ coreEnergy
energy stored for this correction
@ ptCorrection
egamma ptcorrection
@ pileupCorrection
fully corrected
@ coreCone
core energy (in dR<0.1).
@ core57cells
core 5x7 cells
float coneSize(IsolationConeSize type)
convert Isolation Size into cone size
EventInfo_v1 EventInfo
Definition of the latest event info version.
Egamma_v1 Egamma
Definition of the current "egamma version".
Photon_v1 Photon
Definition of the current "egamma version".
EventShape_v1 EventShape
Definition of the current event format version.
Electron_v1 Electron
Definition of the current "egamma version".