ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
ResidualOffsetCorrection Class Reference

#include <ResidualOffsetCorrection.h>

Inheritance diagram for ResidualOffsetCorrection:
Collaboration diagram for ResidualOffsetCorrection:

Public Member Functions

 ResidualOffsetCorrection ()
 
 ResidualOffsetCorrection (const std::string &name, TEnv *config, TString jetAlgo, TString calibAreaTag, bool isData, bool dev)
 
virtual ~ResidualOffsetCorrection ()
 
virtual StatusCode initialize ()
 
double GetResidualOffset (double abseta, double mu, double NPV, int nJet, bool MuOnly, bool NOnly) const
 
void setLevel (MSG::Level lvl)
 Change the current logging level. More...
 

Private Member Functions

double GetResidualOffsetET (double abseta, double mu, double NPV, int nJet, bool MuOnly, bool NOnly, const std::vector< double > &OffsetMu, const std::vector< double > &OffsetNPV, const std::vector< double > &OffsetNjet, const TAxis *OffsetBins) const
 
double GetNPVBeamspotCorrection (double NPV) const
 
void initMessaging () const
 Initialize our message level and MessageSvc. More...
 

Private Attributes

TEnv * m_config {}
 
TString m_jetAlgo
 
TString m_calibAreaTag
 
bool m_dev {}
 
bool m_isData {}
 
NPVBeamspotCorrectionm_npvBeamspotCorr {}
 
TString m_resOffsetDesc
 
TAxis * m_resOffsetBins {}
 
bool m_applyNPVBeamspotCorrection {}
 
double m_muSF {}
 
double m_mu_ref {}
 
double m_NPV_ref {}
 
double m_nJet_ref {}
 
bool m_useNjet {}
 
std::vector< double > m_resOffsetMu
 
std::vector< double > m_resOffsetNPV
 
std::vector< double > m_resOffsetNjet
 
std::string m_nm
 Message source name. More...
 
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels) More...
 
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer. More...
 
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level. More...
 
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging) More...
 

Static Private Attributes

static constexpr float m_GeV = 1000
 

Detailed Description

Definition at line 26 of file ResidualOffsetCorrection.h.

Constructor & Destructor Documentation

◆ ResidualOffsetCorrection() [1/2]

ResidualOffsetCorrection::ResidualOffsetCorrection ( )

Definition at line 15 of file ResidualOffsetCorrection.cxx.

16  : asg::AsgMessaging("ResidualOffsetCorrection"),
17  m_config(nullptr), m_jetAlgo(""), m_calibAreaTag(""), m_dev(false), m_isData(false),
18  m_npvBeamspotCorr(nullptr), m_resOffsetBins(nullptr)
19 { }

◆ ResidualOffsetCorrection() [2/2]

ResidualOffsetCorrection::ResidualOffsetCorrection ( const std::string &  name,
TEnv *  config,
TString  jetAlgo,
TString  calibAreaTag,
bool  isData,
bool  dev 
)

Definition at line 21 of file ResidualOffsetCorrection.cxx.

23  m_config(config), m_jetAlgo(std::move(jetAlgo)), m_calibAreaTag(std::move(calibAreaTag)), m_dev(dev), m_isData(isData),
24  m_npvBeamspotCorr(nullptr), m_resOffsetBins(nullptr)
25 { }

◆ ~ResidualOffsetCorrection()

ResidualOffsetCorrection::~ResidualOffsetCorrection ( )
virtual

Definition at line 27 of file ResidualOffsetCorrection.cxx.

27  {
28 
31 
32 }

Member Function Documentation

◆ GetNPVBeamspotCorrection()

double ResidualOffsetCorrection::GetNPVBeamspotCorrection ( double  NPV) const
private

Definition at line 179 of file ResidualOffsetCorrection.cxx.

179  {
180  if(!m_isData && m_applyNPVBeamspotCorrection) return std::as_const(m_npvBeamspotCorr)->GetNVertexBsCorrection(NPV);
181  return NPV;
182 }

◆ GetResidualOffset()

double ResidualOffsetCorrection::GetResidualOffset ( double  abseta,
double  mu,
double  NPV,
int  nJet,
bool  MuOnly,
bool  NOnly 
) const

Definition at line 118 of file ResidualOffsetCorrection.cxx.

119  {
120  return GetResidualOffsetET(abseta, mu, NPV, nJet, MuOnly, NOnly,
122 }

◆ GetResidualOffsetET()

double ResidualOffsetCorrection::GetResidualOffsetET ( double  abseta,
double  mu,
double  NPV,
int  nJet,
bool  MuOnly,
bool  NOnly,
const std::vector< double > &  OffsetMu,
const std::vector< double > &  OffsetNPV,
const std::vector< double > &  OffsetNjet,
const TAxis *  OffsetBins 
) const
private

Definition at line 124 of file ResidualOffsetCorrection.cxx.

129  {
130 
131  //mu rescaling
132  const double muCorr = m_isData ? mu : mu*m_muSF;
133  if(m_useNjet) {
134  // further correction to nJet if desired
135  int nJetCorr = nJet;
136 
137  double alpha, beta, etaEdge;
138  if(!MuOnly){ beta = OffsetNjet[0];
139  } else { beta = 0; }
140  if(!NOnly){ alpha = OffsetMu[0];
141  } else { alpha = 0; }
142  etaEdge=0;
143  int bin=1;
144  for (;bin<=OffsetBins->GetNbins();++bin) {
145  etaEdge = OffsetBins->GetBinLowEdge(bin);
146  const double width=OffsetBins->GetBinWidth(bin);
147  if (abseta<etaEdge+width) break;
148  if(!NOnly) alpha += width*OffsetMu[bin];
149  if(!MuOnly) beta += width*OffsetNjet[bin];
150  }
151  if(!NOnly) alpha += OffsetMu[bin]*(abseta-etaEdge);
152  if(!MuOnly) beta += OffsetNjet[bin]*(abseta-etaEdge);
153  return (alpha*(muCorr-m_mu_ref) + beta*(nJetCorr-m_nJet_ref))*m_GeV;
154  } else {
155  //NPV beamspot correction
156  const double NPVCorr = GetNPVBeamspotCorrection(NPV);
157 
158  double alpha, beta, etaEdge;
159  if(!MuOnly){ beta = OffsetNPV[0];
160  } else { beta = 0; }
161  if(!NOnly){ alpha = OffsetMu[0];
162  } else { alpha = 0; }
163  etaEdge = 0;
164  int bin=1;
165  for (;bin<=OffsetBins->GetNbins();++bin) {
166  etaEdge = OffsetBins->GetBinLowEdge(bin);
167  const double width=OffsetBins->GetBinWidth(bin);
168  if (abseta<etaEdge+width) break;
169  if(!NOnly) alpha += width*OffsetMu[bin];
170  if(!MuOnly) beta += width*OffsetNPV[bin];
171  }
172  if(!NOnly) alpha += OffsetMu[bin]*(abseta-etaEdge);
173  if(!MuOnly) beta += OffsetNPV[bin]*(abseta-etaEdge);
174  return (alpha*(muCorr-m_mu_ref) + beta*(NPVCorr-m_NPV_ref))*m_GeV;
175  }
176 
177 }

◆ initialize()

StatusCode ResidualOffsetCorrection::initialize ( )
virtual

Definition at line 34 of file ResidualOffsetCorrection.cxx.

34  {
35 
36  //Read mu scale factor from global config
37  m_muSF = m_config->GetValue("MuScaleFactor",1.0);
38 
39  // Read useNjet from global config
40  m_useNjet = m_config->GetValue("OffsetCorrection.UseNjet",false);
41 
42  bool doMuOnly = m_config->GetValue("ApplyOnlyMuResidual",false);
43  bool doNPVOnly = m_config->GetValue("ApplyOnlyNPVResidual",false);
44  bool doNJetOnly = m_config->GetValue("ApplyOnlyNJetResidual",false);
45 
46  //Read reference mu, NPV and nJet from global config
47  m_mu_ref = m_config->GetValue("OffsetCorrection.DefaultMuRef",-99.0);
48  if (m_mu_ref==-99 && !doNPVOnly && !doNJetOnly) {
49  ATH_MSG_FATAL("OffsetCorrection.DefaultMuRef not specified.");
50  return StatusCode::FAILURE;
51  }
52  m_NPV_ref = m_config->GetValue("OffsetCorrection.DefaultNPVRef",-99.0);
53  if (m_NPV_ref==-99 && !doMuOnly && !m_useNjet) {
54  ATH_MSG_FATAL("OffsetCorrection.DefaultNPVRef not specified.");
55  return StatusCode::FAILURE;
56  }
57 
58  if (m_NPV_ref==-99 && !doMuOnly && !m_useNjet) {
59  ATH_MSG_FATAL("OffsetCorrection.DefaultNPVRef not specified.");
60  return StatusCode::FAILURE;
61  }
62  m_nJet_ref = m_config->GetValue("OffsetCorrection.DefaultNjetRef",-99.0);
63  if (m_nJet_ref==-99 && m_useNjet) {
64  ATH_MSG_FATAL("OffsetCorrection.DefaultNjetRef not specified.");
65  return StatusCode::FAILURE;
66  }
67 
68  //Add the residual offset correction factors to the config TEnv
69  TString ResidualOffsetCalibFile = m_config->GetValue("ResidualOffset.CalibFile","");
70  if(m_dev){
71  ResidualOffsetCalibFile.Remove(0,33);
72  ResidualOffsetCalibFile.Insert(0,"JetCalibTools/");
73  }
74  else{ResidualOffsetCalibFile.Insert(14,m_calibAreaTag);}
75  TString calibFile = PathResolverFindCalibFile(ResidualOffsetCalibFile.Data());
76  m_config->ReadFile(calibFile, kEnvLocal);
77  //Retrieve information specific to the residual offset correction from the TEnv
78  TString offsetName = m_config->GetValue("ResidualOffsetCorrection.Name","");
79  m_resOffsetDesc = m_config->GetValue(offsetName+".Description","");
80  ATH_MSG_INFO("Reading residual jet-area pile-up correction factors from: " << calibFile);
81  ATH_MSG_INFO("Description: " << m_resOffsetDesc);
82 
83  //Check if the config is set to apply the beamspot correction to NPV
84  m_applyNPVBeamspotCorrection = m_config->GetValue("ApplyNPVBeamspotCorrection",false);
85 
86  std::vector<double> offsetEtaBins = JetCalibUtils::VectorizeD( m_config->GetValue(offsetName+".AbsEtaBins","") );
87  if (offsetEtaBins.size()<3) { ATH_MSG_FATAL(offsetName << ".AbsEtaBins not specified"); return StatusCode::FAILURE; }
88  m_resOffsetBins = new TAxis(offsetEtaBins.size()-1,&offsetEtaBins[0]);
89 
90  if(!doNPVOnly && !doNJetOnly){
91  m_resOffsetMu = JetCalibUtils::VectorizeD(m_config->GetValue(offsetName+".MuTerm."+m_jetAlgo,""));
92  if ( (int)m_resOffsetMu.size()!=m_resOffsetBins->GetNbins()+1 ) {
93  ATH_MSG_FATAL( "Incorrect specification of " << offsetName << ".MuTerm." << m_jetAlgo );
94  return StatusCode::FAILURE;
95  }
96  }
97  if(m_useNjet) {
98  m_resOffsetNjet = JetCalibUtils::VectorizeD(m_config->GetValue(offsetName+".nJetTerm."+m_jetAlgo,""));
99  if ((int)m_resOffsetNjet.size()!=m_resOffsetBins->GetNbins()+1) {
100  ATH_MSG_FATAL( "Incorrect specification of " << offsetName << ".nJetTerm." << m_jetAlgo );
101  return StatusCode::FAILURE;
102  }
103  } else if(!doMuOnly){
104  m_resOffsetNPV = JetCalibUtils::VectorizeD(m_config->GetValue(offsetName+".NPVTerm."+m_jetAlgo,""));
105  if ((int)m_resOffsetNPV.size()!=m_resOffsetBins->GetNbins()+1) {
106  ATH_MSG_FATAL( "Incorrect specification of " << offsetName << ".NPVTerm." << m_jetAlgo );
107  return StatusCode::FAILURE;
108  }
111  ATH_MSG_INFO("\n NPV beamspot correction will be applied.");
112  }
113  }
114 
115  return StatusCode::SUCCESS;
116 }

◆ initMessaging()

void AthMessaging::initMessaging ( ) const
privateinherited

Initialize our message level and MessageSvc.

This method should only be called once.

Definition at line 39 of file AthMessaging.cxx.

40 {
42  m_lvl = m_imsg ?
43  static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
44  MSG::INFO;
45 }

◆ msg() [1/2]

MsgStream & asg::AsgMessaging::msg ( ) const
inherited

The standard message stream.

Returns
A reference to the default message stream of this object.

Definition at line 49 of file AsgMessaging.cxx.

49  {
50 #ifndef XAOD_STANDALONE
52 #else // not XAOD_STANDALONE
53  return m_msg;
54 #endif // not XAOD_STANDALONE
55  }

◆ msg() [2/2]

MsgStream & asg::AsgMessaging::msg ( const MSG::Level  lvl) const
inherited

The standard message stream.

Parameters
lvlThe message level to set the stream to
Returns
A reference to the default message stream, set to level "lvl"

Definition at line 57 of file AsgMessaging.cxx.

57  {
58 #ifndef XAOD_STANDALONE
60 #else // not XAOD_STANDALONE
61  m_msg << lvl;
62  return m_msg;
63 #endif // not XAOD_STANDALONE
64  }

◆ msgLvl()

bool asg::AsgMessaging::msgLvl ( const MSG::Level  lvl) const
inherited

Test the output level of the object.

Parameters
lvlThe message level to test against
Returns
boolean Indicting if messages at given level will be printed
true If messages at level "lvl" will be printed

Definition at line 41 of file AsgMessaging.cxx.

41  {
42 #ifndef XAOD_STANDALONE
43  return ::AthMessaging::msgLvl( lvl );
44 #else // not XAOD_STANDALONE
45  return m_msg.msgLevel( lvl );
46 #endif // not XAOD_STANDALONE
47  }

◆ setLevel()

void AthMessaging::setLevel ( MSG::Level  lvl)
inherited

Change the current logging level.

Use this rather than msg().setLevel() for proper operation with MT.

Definition at line 28 of file AthMessaging.cxx.

29 {
30  m_lvl = lvl;
31 }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::atomic_flag m_initialized AthMessaging::ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
mutableprivateinherited

Messaging initialized (initMessaging)

Definition at line 141 of file AthMessaging.h.

◆ m_applyNPVBeamspotCorrection

bool ResidualOffsetCorrection::m_applyNPVBeamspotCorrection {}
private

Definition at line 58 of file ResidualOffsetCorrection.h.

◆ m_calibAreaTag

TString ResidualOffsetCorrection::m_calibAreaTag
private

Definition at line 49 of file ResidualOffsetCorrection.h.

◆ m_config

TEnv* ResidualOffsetCorrection::m_config {}
private

Definition at line 48 of file ResidualOffsetCorrection.h.

◆ m_dev

bool ResidualOffsetCorrection::m_dev {}
private

Definition at line 50 of file ResidualOffsetCorrection.h.

◆ m_GeV

constexpr float ResidualOffsetCorrection::m_GeV = 1000
staticconstexprprivate

Definition at line 52 of file ResidualOffsetCorrection.h.

◆ m_imsg

std::atomic<IMessageSvc*> AthMessaging::m_imsg { nullptr }
mutableprivateinherited

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

◆ m_isData

bool ResidualOffsetCorrection::m_isData {}
private

Definition at line 51 of file ResidualOffsetCorrection.h.

◆ m_jetAlgo

TString ResidualOffsetCorrection::m_jetAlgo
private

Definition at line 49 of file ResidualOffsetCorrection.h.

◆ m_lvl

std::atomic<MSG::Level> AthMessaging::m_lvl { MSG::NIL }
mutableprivateinherited

Current logging level.

Definition at line 138 of file AthMessaging.h.

◆ m_msg_tls

boost::thread_specific_ptr<MsgStream> AthMessaging::m_msg_tls
mutableprivateinherited

MsgStream instance (a std::cout like with print-out levels)

Definition at line 132 of file AthMessaging.h.

◆ m_mu_ref

double ResidualOffsetCorrection::m_mu_ref {}
private

Definition at line 60 of file ResidualOffsetCorrection.h.

◆ m_muSF

double ResidualOffsetCorrection::m_muSF {}
private

Definition at line 59 of file ResidualOffsetCorrection.h.

◆ m_nJet_ref

double ResidualOffsetCorrection::m_nJet_ref {}
private

Definition at line 60 of file ResidualOffsetCorrection.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_NPV_ref

double ResidualOffsetCorrection::m_NPV_ref {}
private

Definition at line 60 of file ResidualOffsetCorrection.h.

◆ m_npvBeamspotCorr

NPVBeamspotCorrection* ResidualOffsetCorrection::m_npvBeamspotCorr {}
private

Definition at line 54 of file ResidualOffsetCorrection.h.

◆ m_resOffsetBins

TAxis* ResidualOffsetCorrection::m_resOffsetBins {}
private

Definition at line 57 of file ResidualOffsetCorrection.h.

◆ m_resOffsetDesc

TString ResidualOffsetCorrection::m_resOffsetDesc
private

Definition at line 56 of file ResidualOffsetCorrection.h.

◆ m_resOffsetMu

std::vector<double> ResidualOffsetCorrection::m_resOffsetMu
private

Definition at line 63 of file ResidualOffsetCorrection.h.

◆ m_resOffsetNjet

std::vector<double> ResidualOffsetCorrection::m_resOffsetNjet
private

Definition at line 63 of file ResidualOffsetCorrection.h.

◆ m_resOffsetNPV

std::vector<double> ResidualOffsetCorrection::m_resOffsetNPV
private

Definition at line 63 of file ResidualOffsetCorrection.h.

◆ m_useNjet

bool ResidualOffsetCorrection::m_useNjet {}
private

Definition at line 61 of file ResidualOffsetCorrection.h.


The documentation for this class was generated from the following files:
AthMessaging::m_lvl
std::atomic< MSG::Level > m_lvl
Current logging level.
Definition: AthMessaging.h:138
ResidualOffsetCorrection::m_npvBeamspotCorr
NPVBeamspotCorrection * m_npvBeamspotCorr
Definition: ResidualOffsetCorrection.h:54
ATH_MSG_FATAL
#define ATH_MSG_FATAL(x)
Definition: AthMsgStreamMacros.h:34
ResidualOffsetCorrection::m_resOffsetNjet
std::vector< double > m_resOffsetNjet
Definition: ResidualOffsetCorrection.h:63
ResidualOffsetCorrection::m_config
TEnv * m_config
Definition: ResidualOffsetCorrection.h:48
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
ResidualOffsetCorrection::m_applyNPVBeamspotCorrection
bool m_applyNPVBeamspotCorrection
Definition: ResidualOffsetCorrection.h:58
ResidualOffsetCorrection::m_resOffsetDesc
TString m_resOffsetDesc
Definition: ResidualOffsetCorrection.h:56
bin
Definition: BinsDiffFromStripMedian.h:43
ResidualOffsetCorrection::m_muSF
double m_muSF
Definition: ResidualOffsetCorrection.h:59
AthMessaging::m_imsg
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
Definition: AthMessaging.h:135
Athena::getMessageSvc
IMessageSvc * getMessageSvc(bool quiet=false)
Definition: getMessageSvc.cxx:20
config
Definition: PhysicsAnalysis/AnalysisCommon/AssociationUtils/python/config.py:1
ResidualOffsetCorrection::m_mu_ref
double m_mu_ref
Definition: ResidualOffsetCorrection.h:60
TrigConf::MSGTC::Level
Level
Definition: Trigger/TrigConfiguration/TrigConfBase/TrigConfBase/MsgStream.h:21
jet::PileupComp::OffsetNPV
@ OffsetNPV
Definition: UncertaintyEnum.h:165
ResidualOffsetCorrection::m_jetAlgo
TString m_jetAlgo
Definition: ResidualOffsetCorrection.h:49
ResidualOffsetCorrection::m_resOffsetMu
std::vector< double > m_resOffsetMu
Definition: ResidualOffsetCorrection.h:63
ResidualOffsetCorrection::m_isData
bool m_isData
Definition: ResidualOffsetCorrection.h:51
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
asg::AsgMessaging
Class mimicking the AthMessaging class from the offline software.
Definition: AsgMessaging.h:40
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
jet::PileupComp::OffsetMu
@ OffsetMu
Definition: UncertaintyEnum.h:166
ResidualOffsetCorrection::m_calibAreaTag
TString m_calibAreaTag
Definition: ResidualOffsetCorrection.h:49
ResidualOffsetCorrection::m_resOffsetNPV
std::vector< double > m_resOffsetNPV
Definition: ResidualOffsetCorrection.h:63
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
ResidualOffsetCorrection::m_NPV_ref
double m_NPV_ref
Definition: ResidualOffsetCorrection.h:60
ResidualOffsetCorrection::m_GeV
static constexpr float m_GeV
Definition: ResidualOffsetCorrection.h:52
AthMessaging::m_nm
std::string m_nm
Message source name.
Definition: AthMessaging.h:129
ResidualOffsetCorrection::GetNPVBeamspotCorrection
double GetNPVBeamspotCorrection(double NPV) const
Definition: ResidualOffsetCorrection.cxx:179
ResidualOffsetCorrection::m_useNjet
bool m_useNjet
Definition: ResidualOffsetCorrection.h:61
ResidualOffsetCorrection::GetResidualOffsetET
double GetResidualOffsetET(double abseta, double mu, double NPV, int nJet, bool MuOnly, bool NOnly, const std::vector< double > &OffsetMu, const std::vector< double > &OffsetNPV, const std::vector< double > &OffsetNjet, const TAxis *OffsetBins) const
Definition: ResidualOffsetCorrection.cxx:124
JetCalibUtils::VectorizeD
VecD VectorizeD(const TString &str, const TString &sep=" ")
Definition: JetCalibUtils.cxx:25
ResidualOffsetCorrection::m_resOffsetBins
TAxis * m_resOffsetBins
Definition: ResidualOffsetCorrection.h:57
MuonParameters::beta
@ beta
Definition: MuonParamDefs.h:144
CaloNoise_fillDB.mu
mu
Definition: CaloNoise_fillDB.py:53
ResidualOffsetCorrection::m_dev
bool m_dev
Definition: ResidualOffsetCorrection.h:50
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
NPVBeamspotCorrection
Definition: NPVBeamspotCorrection.h:21
ResidualOffsetCorrection::m_nJet_ref
double m_nJet_ref
Definition: ResidualOffsetCorrection.h:60