ATLAS Offline Software
Loading...
Searching...
No Matches
jet::CorrelationMatrix Class Reference

#include <CorrelationMatrix.h>

Inheritance diagram for jet::CorrelationMatrix:
Collaboration diagram for jet::CorrelationMatrix:

Public Member Functions

 CorrelationMatrix (const TString &name, const int numBins, const double minVal, const double maxVal, const double fixedVal1, const double fixedVal2)
virtual ~CorrelationMatrix ()
virtual StatusCode initializeForPt (const JetUncertaintiesTool &uncTool)
virtual StatusCode initializeForEta (const JetUncertaintiesTool &uncTool)
virtual TString getName () const
virtual const TH2D * getMatrix () const
void setLevel (MSG::Level lvl)
 Change the current logging level.
Functions providing the same interface as AthMessaging
bool msgLvl (const MSG::Level lvl) const
 Test the output level of the object.
MsgStream & msg () const
 The standard message stream.
MsgStream & msg (const MSG::Level lvl) const
 The standard message stream.

Private Member Functions

 CorrelationMatrix (const std::string &name="")
StatusCode checkInitialization (const JetUncertaintiesTool &uncTool) const
StatusCode createStore ()
StatusCode clearStore ()
StatusCode setDefaultProperties (const JetUncertaintiesTool &uncTool)
TH2D * buildMatrix (const std::vector< double > &bins) const
double getCorrelation (const JetUncertaintiesTool &uncTool) const
double getCovariance (const JetUncertaintiesTool &uncTool, const xAOD::Jet *jet1, const xAOD::Jet *jet2) const
void initMessaging () const
 Initialize our message level and MessageSvc.

Private Attributes

bool m_isInit
const TString m_name
const int m_numBins
const double m_minVal
const double m_maxVal
const double m_fixedVal1
const double m_fixedVal2
TH2D * m_corrMat
xAOD::JetContainerm_jets
xAOD::EventInfoContainerm_eInfos
xAOD::Jetm_jet1
xAOD::Jetm_jet2
xAOD::EventInfom_eInfo
std::string m_nm
 Message source name.
boost::thread_specific_ptr< MsgStream > m_msg_tls
 MsgStream instance (a std::cout like with print-out levels)
std::atomic< IMessageSvc * > m_imsg { nullptr }
 MessageSvc pointer.
std::atomic< MSG::Level > m_lvl { MSG::NIL }
 Current logging level.
std::atomic_flag m_initialized ATLAS_THREAD_SAFE = ATOMIC_FLAG_INIT
 Messaging initialized (initMessaging)

Detailed Description

Definition at line 26 of file CorrelationMatrix.h.

Constructor & Destructor Documentation

◆ CorrelationMatrix() [1/2]

jet::CorrelationMatrix::CorrelationMatrix ( const TString & name,
const int numBins,
const double minVal,
const double maxVal,
const double fixedVal1,
const double fixedVal2 )

Definition at line 38 of file CorrelationMatrix.cxx.

39 : asg::AsgMessaging(name.Data())
40 , m_isInit(false)
41 , m_name(name)
42 , m_numBins(numBins)
43 , m_minVal(minVal)
44 , m_maxVal(maxVal)
45 , m_fixedVal1(fixedVal1)
46 , m_fixedVal2(fixedVal2)
47 , m_corrMat(nullptr)
48 , m_jets(nullptr)
49 , m_eInfos(nullptr)
50 , m_jet1(nullptr)
51 , m_jet2(nullptr)
52 , m_eInfo(nullptr)
53{
54 ATH_MSG_DEBUG("Creating CorrelationMatrix named " << m_name.Data());
55}
#define ATH_MSG_DEBUG(x)
xAOD::EventInfoContainer * m_eInfos
xAOD::EventInfo * m_eInfo
xAOD::JetContainer * m_jets

◆ ~CorrelationMatrix()

jet::CorrelationMatrix::~CorrelationMatrix ( )
virtual

◆ CorrelationMatrix() [2/2]

jet::CorrelationMatrix::CorrelationMatrix ( const std::string & name = "")
private

Definition at line 19 of file CorrelationMatrix.cxx.

20 : asg::AsgMessaging(name)
21 , m_isInit(false)
22 , m_name(name.c_str())
23 , m_numBins(-1)
24 , m_minVal(1e10)
25 , m_maxVal(-1e10)
26 , m_fixedVal1(0)
27 , m_fixedVal2(0)
28 , m_corrMat(nullptr)
29 , m_jets(nullptr)
30 , m_eInfos(nullptr)
31 , m_jet1(nullptr)
32 , m_jet2(nullptr)
33 , m_eInfo(nullptr)
34{
36}

Member Function Documentation

◆ buildMatrix()

TH2D * jet::CorrelationMatrix::buildMatrix ( const std::vector< double > & bins) const
private

Definition at line 322 of file CorrelationMatrix.cxx.

323{
324 TH2D* matrix = new TH2D(m_name,m_name,bins.size()-1,&bins[0],bins.size()-1,&bins[0]);
325 matrix->GetZaxis()->SetRangeUser(-1,1);
326 return matrix;
327}
static const std::vector< std::string > bins

◆ checkInitialization()

StatusCode jet::CorrelationMatrix::checkInitialization ( const JetUncertaintiesTool & uncTool) const
private

Definition at line 197 of file CorrelationMatrix.cxx.

198{
199 // Prevent double-initialization
200 if (m_isInit)
201 {
202 ATH_MSG_ERROR("CorrelationMatrix is already initialized: " << m_name.Data());
203 return StatusCode::FAILURE;
204 }
205
206 // Warn about any non-four-vector terms which will be ignored
207 bool scalesFourVec = false;
208 for (size_t iComp = 0; iComp < uncTool.getNumComponents(); ++iComp)
209 if (!uncTool.getComponentScalesFourVec(iComp))
210 ATH_MSG_WARNING("CorrelationMatrix will ignore component which does not scale the jet four-vector: " << uncTool.getComponentName(iComp));
211 else
212 scalesFourVec = true;
213
214 // If no components scale the four-vector, end now
215 if (!scalesFourVec)
216 {
217 ATH_MSG_ERROR("No components scale the four-vector for the CorrelationMatrix: " << m_name.Data());
218 return StatusCode::FAILURE;
219 }
220
221 return StatusCode::SUCCESS;
222}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
virtual bool getComponentScalesFourVec(const size_t index) const
virtual size_t getNumComponents() const
virtual std::string getComponentName(const size_t index) const

◆ clearStore()

StatusCode jet::CorrelationMatrix::clearStore ( )
private

Definition at line 243 of file CorrelationMatrix.cxx.

244{
245 m_jet1 = nullptr;
246 m_jet2 = nullptr;
247 m_eInfo = nullptr;
248
249 //for (size_t iJet = 0; iJet < m_jets->size(); ++iJet)
250 // JESUNC_SAFE_DELETE((*m_jets)[iJet]);
251 m_jets->clear();
253
254 //for (size_t iInfo = 0; iInfo < m_eInfos->size(); ++iInfo)
255 // JESUNC_SAFE_DELETE((*m_eInfos)[iInfo]);
256 m_eInfos->clear();
258
259 return StatusCode::SUCCESS;
260}

◆ createStore()

StatusCode jet::CorrelationMatrix::createStore ( )
private

Definition at line 224 of file CorrelationMatrix.cxx.

225{
226 // Build a jet container and a pair of jets for us to manipulate later
228 m_jets->setStore(new xAOD::JetAuxContainer());
229 m_jets->push_back(new xAOD::Jet());
230 m_jets->push_back(new xAOD::Jet());
231 m_jet1 = m_jets->at(0);
232 m_jet2 = m_jets->at(1);
233
234 // Build an EventInfo object for us to manipulate later
236 m_eInfos->setStore(new xAOD::EventInfoAuxContainer());
237 m_eInfos->push_back(new xAOD::EventInfo());
238 m_eInfo = m_eInfos->at(0);
239
240 return StatusCode::SUCCESS;
241}
Jet_v1 Jet
Definition of the current "jet version".
EventInfoContainer_v1 EventInfoContainer
Define the latest version of the container.
EventInfo_v1 EventInfo
Definition of the latest event info version.
EventInfoAuxContainer_v1 EventInfoAuxContainer
Define the latest version of the auxiliary container.
JetAuxContainer_v1 JetAuxContainer
Definition of the current jet auxiliary container.
JetContainer_v1 JetContainer
Definition of the current "jet container version".

◆ getCorrelation()

double jet::CorrelationMatrix::getCorrelation ( const JetUncertaintiesTool & uncTool) const
private

Definition at line 329 of file CorrelationMatrix.cxx.

330{
331 return getCovariance(uncTool,m_jet1,m_jet2)/sqrt(getCovariance(uncTool,m_jet1,m_jet1)*getCovariance(uncTool,m_jet2,m_jet2));
332}
double getCovariance(const JetUncertaintiesTool &uncTool, const xAOD::Jet *jet1, const xAOD::Jet *jet2) const

◆ getCovariance()

double jet::CorrelationMatrix::getCovariance ( const JetUncertaintiesTool & uncTool,
const xAOD::Jet * jet1,
const xAOD::Jet * jet2 ) const
private

Definition at line 334 of file CorrelationMatrix.cxx.

335{
336 double covariance = 0;
337 for (size_t iComp = 0; iComp < uncTool.getNumComponents(); ++iComp)
338 covariance += uncTool.getUncertainty(iComp,*jet1,*m_eInfo)*uncTool.getUncertainty(iComp,*jet2,*m_eInfo);
339
340 return covariance;
341}
virtual double getUncertainty(size_t index, const xAOD::Jet &jet) const

◆ getMatrix()

virtual const TH2D * jet::CorrelationMatrix::getMatrix ( ) const
inlinevirtual

Definition at line 45 of file CorrelationMatrix.h.

45{ return m_corrMat; }

◆ getName()

virtual TString jet::CorrelationMatrix::getName ( ) const
inlinevirtual

Definition at line 44 of file CorrelationMatrix.h.

44{ return m_name; }

◆ initializeForEta()

StatusCode jet::CorrelationMatrix::initializeForEta ( const JetUncertaintiesTool & uncTool)
virtual

Definition at line 130 of file CorrelationMatrix.cxx.

131{
132 // Check for initialization and tool status
133 if (checkInitialization(uncTool).isFailure())
134 return StatusCode::FAILURE;
135 m_isInit = true;
136
137 // Determine the center of mass energy for kinematic limits if possible
138 // If not possible, then ignores kinematic limits
139 // pt * cosh(eta) = sqrtS/2 for kinematic limit
140 const double sqrtS = uncTool.getSqrtS();
141 const double kinLimit1 = sqrtS > 0 ? acosh((sqrtS/2.) / m_fixedVal1) : 1e99;
142 const double kinLimit2 = sqrtS > 0 ? acosh((sqrtS/2.) / m_fixedVal2) : 1e99;
143
144 // Build the correlation matrix
146
147 // Prepare the objects for use
148 if (createStore().isFailure())
149 return StatusCode::FAILURE;
150
151 // Set default values
152 if (setDefaultProperties(uncTool).isFailure())
153 return StatusCode::FAILURE;
154
155 // Fill the correlation matrix
156 for (int binX = 1; binX <= m_corrMat->GetNbinsX(); ++binX)
157 {
158 // Set the jet values, (pT, eta, phi, m)
159 // note that only pT and eta matter right now
160 const double valX = m_corrMat->GetXaxis()->GetBinCenter(binX);
161 m_jet1->setJetP4(xAOD::JetFourMom_t(m_fixedVal1,valX,0,0));
162
163 for (int binY = 1; binY <= m_corrMat->GetNbinsY(); ++binY)
164 {
165 const double valY = m_corrMat->GetYaxis()->GetBinCenter(binY);
166
167 // Check for the kinematic limit (simple case)
168 if (valX > kinLimit1 || valY > kinLimit2) {
169 m_corrMat->SetBinContent(binX,binY,JESUNC_ERROR_CODE);
170 } else
171 {
172 // Set the jet values, (pT, eta, phi, m)
173 // note that only pT and eta matter right now
174 m_jet2->setJetP4(xAOD::JetFourMom_t(m_fixedVal2,valY,0,0));
175
176 // Now determine the correlation for the two jets
177 m_corrMat->SetBinContent(binX,binY,getCorrelation(uncTool));
178 }
179 }
180 }
181
182 // Clear up the objects we used
183 if (clearStore().isFailure())
184 return StatusCode::FAILURE;
185
186 // Done
187 return StatusCode::SUCCESS;
188}
virtual float getSqrtS() const
TH2D * buildMatrix(const std::vector< double > &bins) const
StatusCode setDefaultProperties(const JetUncertaintiesTool &uncTool)
double getCorrelation(const JetUncertaintiesTool &uncTool) const
StatusCode checkInitialization(const JetUncertaintiesTool &uncTool) const
@ binX
Definition BinningType.h:47
@ binY
Definition BinningType.h:48
std::vector< double > getUniformBins(const size_t numBins, const double minVal, const double maxVal)
ROOT::Math::LorentzVector< ROOT::Math::PtEtaPhiM4D< double > > JetFourMom_t
Base 4 Momentum type for Jet.
Definition JetTypes.h:17

◆ initializeForPt()

StatusCode jet::CorrelationMatrix::initializeForPt ( const JetUncertaintiesTool & uncTool)
virtual

Definition at line 64 of file CorrelationMatrix.cxx.

65{
66 // Check for initialization and tool status
67 if (checkInitialization(uncTool).isFailure())
68 return StatusCode::FAILURE;
69 m_isInit = true;
70
71 // Determine the center of mass energy for kinematic limits if possible
72 // If not possible, then ignores kinematic limits
73 // pt * cosh(eta) = sqrtS/2 for kinematic limit
74 const double sqrtS = uncTool.getSqrtS();
75 const double kinLimit1 = sqrtS > 0 ? (sqrtS/2.) / cosh(m_fixedVal1) : 1e99;
76 const double kinLimit2 = sqrtS > 0 ? (sqrtS/2.) / cosh(m_fixedVal2) : 1e99;
77
78 std::cout << "Initializing for Pt with fixedVal1, fixedVal2 " << m_fixedVal1 << " " << m_fixedVal2 << std::endl;
79 std::cout << "Corresponding to kinematic limits " << kinLimit1 << " " << kinLimit2 << std::endl;
80
81
82 // Build the correlation matrix
84
85 // Prepare the objects for use
86 if (createStore().isFailure())
87 return StatusCode::FAILURE;
88
89 // Set default values
90 if (setDefaultProperties(uncTool).isFailure())
91 return StatusCode::FAILURE;
92
93 // Fill the correlation matrix
94 for (int binX = 1; binX <= m_corrMat->GetNbinsX(); ++binX)
95 {
96 // Set the jet values, (pT, eta, phi, m)
97 // note that only pT and eta matter right now
98 const double valX = m_corrMat->GetXaxis()->GetBinCenter(binX);
99 m_jet1->setJetP4(xAOD::JetFourMom_t(valX,m_fixedVal1,0,0));
100
101 for (int binY = 1; binY <= m_corrMat->GetNbinsY(); ++binY)
102 {
103 const double valY = m_corrMat->GetYaxis()->GetBinCenter(binY);
104
105 // Check for the kinematic limit (simple case)
106 if (valX > kinLimit1 || valY > kinLimit2 ) {
107// std::cout << "Setting error code in space 2" << std::endl;
108// std::cout << "Values, kin limits are " << valX << " " << kinLimit1 << " " << valY << " " << kinLimit2 << std::endl;
109 m_corrMat->SetBinContent(binX,binY,JESUNC_ERROR_CODE);
110 } else
111 {
112 // Set the jet values, (pT, eta, phi, m)
113 // note that only pT and eta matter right now
114 m_jet2->setJetP4(xAOD::JetFourMom_t(valY,m_fixedVal2,0,0));
115
116 // Now determine the correlation for the two jets
117 m_corrMat->SetBinContent(binX,binY,getCorrelation(uncTool));
118 }
119 }
120 }
121
122 // Clear up the objects we used
123 if (clearStore().isFailure())
124 return StatusCode::FAILURE;
125
126 // Done
127 return StatusCode::SUCCESS;
128}
std::vector< double > getLogBins(const size_t numBins, const double minVal, const double maxVal)

◆ 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 // If user did not set an explicit level, set a default
43 if (m_lvl == MSG::NIL) {
44 m_lvl = m_imsg ?
45 static_cast<MSG::Level>( m_imsg.load()->outputLevel(m_nm) ) :
46 MSG::INFO;
47 }
48}
std::string m_nm
Message source name.
std::atomic< IMessageSvc * > m_imsg
MessageSvc pointer.
std::atomic< MSG::Level > m_lvl
Current logging level.
IMessageSvc * getMessageSvc(bool quiet=false)

◆ 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
51 return ::AthMessaging::msg();
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
59 return ::AthMessaging::msg( lvl );
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 }

◆ setDefaultProperties()

StatusCode jet::CorrelationMatrix::setDefaultProperties ( const JetUncertaintiesTool & uncTool)
private

Definition at line 262 of file CorrelationMatrix.cxx.

263{
264
265 // TODO make this part of a common file
266 static const SG::AuxElement::Accessor<int> Nsegments("GhostMuonSegmentCount");
267 static const SG::AuxElement::Accessor<char> IsBjet("IsBjet");
268 static const SG::AuxElement::Accessor<float> mu("averageInteractionsPerCrossing");
269 static const SG::AuxElement::Accessor<float> NPV("NPV");
270
271 // 25 segments is about average for jets receiving a correction
272 // This is modulated by the probability of punchthrough
273 // TODO add punch-through Nsegments/etc dependence on probability
274 Nsegments(*m_jet1) = 0; //25;
275 Nsegments(*m_jet2) = 0; //25;
276 IsBjet(*m_jet1) = false;
277 IsBjet(*m_jet2) = false;
278
279 float sigmaMu = 0;
280 float sigmaNPV = 0;
281
282 const TString config = uncTool.getConfigFile();
283 if (config.Contains("_2011/"))
284 {
285 // Dag, night of Febuary 4/5, 2013
286 sigmaMu = 3.0;
287 sigmaNPV = 3.0;
288 }
289 else if (config.Contains("_2012/") || config.Contains("_2015/Prerec"))
290 {
291 // Craig Sawyer, Jan 22 2013
292 sigmaMu = 5.593*1.11;
293 sigmaNPV = 3.672;
294 }
295 else if (config.Contains("_2015"))
296 {
297 // Kate, Jan 31 2016
298 sigmaMu = 1.9;
299 sigmaNPV = 2.9;
300 }
301 else if (config.Contains("_2016"))
302 {
303 // Kate, Nov 2016
304 // via Eric Corrigan's pileup studies
305 // Scaling term taken from
306 // https://indico.cern.ch/event/437993/contributions/1925644/attachments/1138739/1630981/spagan_MuRescaling.pdf
307 sigmaMu = 5.35;
308 sigmaNPV = 3.49;
309 }
310 else
311 {
312 ATH_MSG_ERROR("Unexpected year for setPileupShiftsForYear in config: " << config.Data());
313 return StatusCode::FAILURE;
314 }
315
316 mu(*m_eInfo) = uncTool.getRefMu()+sigmaMu;
317 NPV(*m_eInfo) = uncTool.getRefNPV()+sigmaNPV;
318
319 return StatusCode::SUCCESS;
320}
virtual std::string getConfigFile() const
virtual float getRefNPV() const
virtual float getRefMu() const
SG::Accessor< T, ALLOC > Accessor
Definition AuxElement.h:572

◆ 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_corrMat

TH2D* jet::CorrelationMatrix::m_corrMat
private

Definition at line 61 of file CorrelationMatrix.h.

◆ m_eInfo

xAOD::EventInfo* jet::CorrelationMatrix::m_eInfo
private

Definition at line 69 of file CorrelationMatrix.h.

◆ m_eInfos

xAOD::EventInfoContainer* jet::CorrelationMatrix::m_eInfos
private

Definition at line 65 of file CorrelationMatrix.h.

◆ m_fixedVal1

const double jet::CorrelationMatrix::m_fixedVal1
private

Definition at line 58 of file CorrelationMatrix.h.

◆ m_fixedVal2

const double jet::CorrelationMatrix::m_fixedVal2
private

Definition at line 59 of file CorrelationMatrix.h.

◆ m_imsg

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

MessageSvc pointer.

Definition at line 135 of file AthMessaging.h.

135{ nullptr };

◆ m_isInit

bool jet::CorrelationMatrix::m_isInit
private

Definition at line 52 of file CorrelationMatrix.h.

◆ m_jet1

xAOD::Jet* jet::CorrelationMatrix::m_jet1
private

Definition at line 67 of file CorrelationMatrix.h.

◆ m_jet2

xAOD::Jet* jet::CorrelationMatrix::m_jet2
private

Definition at line 68 of file CorrelationMatrix.h.

◆ m_jets

xAOD::JetContainer* jet::CorrelationMatrix::m_jets
private

Definition at line 64 of file CorrelationMatrix.h.

◆ m_lvl

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

Current logging level.

Definition at line 138 of file AthMessaging.h.

138{ MSG::NIL };

◆ m_maxVal

const double jet::CorrelationMatrix::m_maxVal
private

Definition at line 57 of file CorrelationMatrix.h.

◆ m_minVal

const double jet::CorrelationMatrix::m_minVal
private

Definition at line 56 of file CorrelationMatrix.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_name

const TString jet::CorrelationMatrix::m_name
private

Definition at line 53 of file CorrelationMatrix.h.

◆ m_nm

std::string AthMessaging::m_nm
privateinherited

Message source name.

Definition at line 129 of file AthMessaging.h.

◆ m_numBins

const int jet::CorrelationMatrix::m_numBins
private

Definition at line 55 of file CorrelationMatrix.h.


The documentation for this class was generated from the following files: