ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
DerivationFramework
DerivationFrameworkSUSY
src
SUSYIDWeight.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
DerivationFrameworkSUSY/SUSYIDWeight.h
"
6
#include "
xAODTruth/TruthEventContainer.h
"
7
8
//namespace DerivationFramework {
9
10
static
const
SG::AuxElement::Accessor<int>
acc_procID
(
"SUSY_procID"
);
11
12
SUSYIDWeight::SUSYIDWeight
(
const
std::string& name )
13
:
WeightToolBase
( name ),
14
m_SUSYProcID
(0),
15
m_eventInfoName
(
"EventInfo"
) {
16
declareProperty
(
"SUSYProcID"
,
m_SUSYProcID
= 0);
17
declareProperty
(
"EventInfoName"
,
m_eventInfoName
=
"EventInfo"
);
18
declareProperty
(
"UseTruthEvents"
,
m_useTruthEvents
=
false
,
"To solve ATLASSIM-2989 we have to switch to using TruthEvents for weights"
);
19
}
20
21
// returns: the value that was calculated from the xAOD::IParticle composite built event
22
// This is the implementation of the interface
23
double
SUSYIDWeight::evaluate
(
const
xAOD::IParticle
*
/*part*/
)
const
24
{
25
ATH_MSG_DEBUG
(
"Evaluating "
<< name() <<
"..."
);
26
27
// Get the proper weight (from EventInfo)
28
return
this->
getWeight
();
29
}
30
31
double
SUSYIDWeight::computeWeight
(
const
xAOD::EventInfo
* evtInfo)
const
{
32
// don't do anything for data
33
if
(!evtInfo->
eventType
(
xAOD::EventInfo::IS_SIMULATION
)){
34
ATH_MSG_DEBUG
(
" Returning weight=1. for data."
);
35
return
1.;
36
}
37
38
//Check for requested Process ID, otherwise return 0.
39
if
(
acc_procID
.isAvailable(*(evtInfo))) {
40
if
(
acc_procID
(*(evtInfo)) !=
m_SUSYProcID
)
41
return
0.;
42
}
43
else
{
44
ATH_MSG_WARNING
(
"The SUSY_procID decoration requested is not available! You need to run SUSYSignalTagger beforehand."
);
45
return
0.;
46
}
47
48
if
(
m_useTruthEvents
) {
49
//access TruthEvents container instead
50
const
xAOD::TruthEventContainer
* te = 0;
51
if
(
evtStore
()->retrieve( te,
"TruthEvents"
).isFailure() ) {
52
ATH_MSG_ERROR
(
"TruthEvents could not be retrieved. Throwing exception"
);
53
throw
std::runtime_error(
"SUSYIDWeight ASG Tool: TruthEvents could not be retrieved"
);
54
}
55
if
( te->
size
() == 0 ) {
56
ATH_MSG_ERROR
(
"TruthEvents has no events in it. Throwing exception"
);
57
throw
std::runtime_error(
"SUSYIDWeight ASG Tool: TruthEvents has no events in it"
);
58
}
59
const
double
weight = te->
at
(0)->weights()[0];
60
ATH_MSG_DEBUG
(
"Got weight in SUSYIDWeight::computeWeight() = "
<< weight <<
"."
);
61
return
weight;
62
}
63
64
const
double
weight = evtInfo->
mcEventWeight
(0);
65
ATH_MSG_DEBUG
(
"Got weight in SUSYIDWeight::computeWeight() = "
<< weight <<
"."
);
66
return
weight;
67
}
68
69
double
SUSYIDWeight::getWeight
()
const
{
70
//Retrieveing eventInfo
71
const
xAOD::EventInfo
* evtInfo;
72
StatusCode
sc
=
evtStore
()->retrieve( evtInfo,
m_eventInfoName
);
73
if
(
sc
.isFailure() || !evtInfo) {
74
ATH_MSG_ERROR
(
" EventInfo could not be retrieved !!"
);
75
return
0.;
76
}
77
78
double
weight = this->
computeWeight
(evtInfo);
79
ATH_MSG_VERBOSE
(
" "
<< name() <<
" returning weight= "
<< weight <<
"."
);
80
return
weight;
81
}
82
//}
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition
AthMsgStreamMacros.h:27
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:28
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
acc_procID
static const SG::AuxElement::Accessor< int > acc_procID("SUSY_procID")
SUSYIDWeight.h
TruthEventContainer.h
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
Definition
AthCommonDataStore.h:145
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
Definition
AthCommonDataStore.h:85
DataVector::at
const T * at(size_type n) const
Access an element, as an rvalue.
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
SUSYIDWeight::m_eventInfoName
std::string m_eventInfoName
Definition
SUSYIDWeight.h:52
SUSYIDWeight::m_useTruthEvents
bool m_useTruthEvents
Definition
SUSYIDWeight.h:53
SUSYIDWeight::computeWeight
double computeWeight(const xAOD::EventInfo *) const
Definition
SUSYIDWeight.cxx:31
SUSYIDWeight::getWeight
virtual double getWeight() const override
returns: the value that was calculated from the usual Athena storegate
Definition
SUSYIDWeight.cxx:69
SUSYIDWeight::SUSYIDWeight
SUSYIDWeight(const std::string &name)
Create a proper constructor for Athena.
Definition
SUSYIDWeight.cxx:12
SUSYIDWeight::m_SUSYProcID
int m_SUSYProcID
Definition
SUSYIDWeight.h:51
SUSYIDWeight::evaluate
virtual double evaluate(const xAOD::IParticle *part) const override
returns: the value that was calculated from the xAOD::IParticle (composite built event object for ins...
Definition
SUSYIDWeight.cxx:23
WeightToolBase::WeightToolBase
WeightToolBase(const std::string &name)
Create a proper constructor for Athena.
Definition
WeightToolBase.cxx:14
xAOD::EventInfo_v1::eventType
bool eventType(EventType type) const
Check for one particular bitmask value.
xAOD::EventInfo_v1::IS_SIMULATION
@ IS_SIMULATION
true: simulation, false: data
Definition
EventInfo_v1.h:151
xAOD::EventInfo_v1::mcEventWeight
float mcEventWeight(size_t i=0) const
The weight of one specific MC event used in the simulation.
Definition
EventInfo_v1.cxx:203
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition
Event/xAOD/xAODBase/xAODBase/IParticle.h:41
xAOD::TruthEventContainer
TruthEventContainer_v1 TruthEventContainer
Declare the latest version of the truth event container.
Definition
TruthEventContainer.h:18
xAOD::EventInfo
EventInfo_v1 EventInfo
Definition of the latest event info version.
Definition
IEventInfoCnvTool.h:16
Generated on
for ATLAS Offline Software by
1.17.0