|
ATLAS Offline Software
|
#include <ScaleFactorCalculator.h>
|
| ScaleFactorCalculator (const std::string &name) |
|
virtual | ~ScaleFactorCalculator () |
|
| ScaleFactorCalculator (const ScaleFactorCalculator &rhs)=delete |
|
| ScaleFactorCalculator (ScaleFactorCalculator &&rhs)=delete |
|
ScaleFactorCalculator & | operator= (const ScaleFactorCalculator &rhs)=delete |
|
StatusCode | initialize () |
| Dummy implementation of the initialisation function. More...
|
|
StatusCode | initialize_nominal_MC_weight () |
|
StatusCode | execute () |
|
StatusCode | executePileup () |
|
float | pileupWeight () const |
|
float | mcEventWeight () const |
|
virtual void | print () const |
| Print the state of the tool. More...
|
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysInitialize () override |
| Perform system initialization for an algorithm. More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
Definition at line 44 of file ScaleFactorCalculator.h.
◆ StoreGateSvc_t
◆ ScaleFactorCalculator() [1/3]
top::ScaleFactorCalculator::ScaleFactorCalculator |
( |
const std::string & |
name | ) |
|
|
explicit |
◆ ~ScaleFactorCalculator()
virtual top::ScaleFactorCalculator::~ScaleFactorCalculator |
( |
| ) |
|
|
inlinevirtual |
◆ ScaleFactorCalculator() [2/3]
◆ ScaleFactorCalculator() [3/3]
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ execute()
StatusCode top::ScaleFactorCalculator::execute |
( |
| ) |
|
Definition at line 182 of file ScaleFactorCalculator.cxx.
201 eventInfo->auxdecor<
double>(
"Sherpa22VJetsWeight") = sherpa_weight;
207 return StatusCode::SUCCESS;
◆ executePileup()
StatusCode top::ScaleFactorCalculator::executePileup |
( |
| ) |
|
◆ extraDeps_update_handler()
Add StoreName to extra input/output deps as needed.
use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given
◆ getKey()
Get the (hashed) key of an object that is in the event store.
This is a bit of a special one. StoreGateSvc
and xAOD::TEvent
both provide ways for getting the SG::sgkey_t
key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
- See also
- asg::AsgTool::getName
- Parameters
-
ptr | The bare pointer to the object that the event store should know about |
- Returns
- The hashed key of the object in the store. If not found, an invalid (zero) key.
Definition at line 119 of file AsgTool.cxx.
121 #ifdef XAOD_STANDALONE
124 return evtStore()->event()->getKey( ptr );
127 return (
proxy ==
nullptr ? 0 :
proxy->sgkey() );
128 #endif // XAOD_STANDALONE
◆ getName()
const std::string & asg::AsgTool::getName |
( |
const void * |
ptr | ) |
const |
|
inherited |
Get the name of an object that is / should be in the event store.
This is a bit of a special one. StoreGateSvc
and xAOD::TEvent
both provide ways for getting the std::string
name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
- See also
- asg::AsgTool::getKey
- Parameters
-
ptr | The bare pointer to the object that the event store should know about |
- Returns
- The string name of the object in the store. If not found, an empty string.
Definition at line 106 of file AsgTool.cxx.
108 #ifdef XAOD_STANDALONE
111 return evtStore()->event()->getName( ptr );
114 static const std::string
dummy =
"";
116 #endif // XAOD_STANDALONE
◆ getProperty()
template<class T >
const T* asg::AsgTool::getProperty |
( |
const std::string & |
name | ) |
const |
|
inherited |
Get one of the tool's properties.
◆ initialize()
StatusCode top::ScaleFactorCalculator::initialize |
( |
| ) |
|
|
virtual |
Dummy implementation of the initialisation function.
It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...
Reimplemented from asg::AsgTool.
Definition at line 36 of file ScaleFactorCalculator.cxx.
39 m_photonSF = std::make_unique<top::PhotonScaleFactorCalculator>(
"top::PhotonScaleFactorCalculator");
40 m_electronSF = std::make_unique<top::ElectronScaleFactorCalculator>(
"top::ElectronScaleFactorCalculator");
41 m_fwdElectronSF = std::make_unique<top::FwdElectronScaleFactorCalculator>(
"top::FwdElectronScaleFactorCalculator");
42 m_muonSF = std::make_unique<top::MuonScaleFactorCalculator>(
"top::MuonScaleFactorCalculator");
43 m_tauSF = std::make_unique<top::TauScaleFactorCalculator>(
"top::TauScaleFactorCalculator");
44 m_jetSF = std::make_unique<top::JetScaleFactorCalculator>(
"top::JetScaleFactorCalculator");
45 m_btagSF = std::make_unique<top::BTagScaleFactorCalculator>(
"top::BTagScaleFactorCalculator");
46 m_pileupSF = std::make_unique<top::PileupScaleFactorCalculator>(
"top::PileupScaleFactorCalculator");
48 std::make_unique<top::GlobalLeptonTriggerCalculator>(
"top::GlobalLeptonTriggerCalculator");
85 "Failed to retrieve PMGSherpa22VJetsWeightTool");
95 if (
m_config->doPileupReweighting()) {
100 return StatusCode::SUCCESS;
◆ initialize_nominal_MC_weight()
StatusCode top::ScaleFactorCalculator::initialize_nominal_MC_weight |
( |
| ) |
|
– Start using the PMG tool to get the nominal event weights –///
Definition at line 103 of file ScaleFactorCalculator.cxx.
107 if (
m_config->forceNominalWeightFallbackIndex()) {
108 ATH_MSG_WARNING(
"ForceNominalWeightFallbackIndex option was set to true."
109 <<
"\nWill use weight with index: " <<
m_config->nominalWeightIndex()
110 <<
" instead of determining it from metadata!");
111 return StatusCode::SUCCESS;
117 ATH_MSG_ERROR(
"\nPMGTruthWeightTool instance could not be retrieved."
118 <<
"\nWe cannot determine if this sample has multiple weights, "
119 <<
"nor which one is nominal. Please specify the index of "
120 <<
"nominal MC weight via config option NominalWeightFallbackIndex, "
121 <<
" and set ForceNominalWeightFallbackIndex to true.");
122 return StatusCode::FAILURE;
129 if (pmg_weight_names.size() == 1) {
130 ATH_MSG_INFO(
"PMGTruthWeightTool reports single weight in sample, assuming nominal weight index = 0");
132 return StatusCode::SUCCESS;
139 const std::vector<std::string> &nominal_weight_names =
m_config->nominalWeightNames();
140 bool found_match =
false;
141 std::vector<std::string> multiple_matches;
142 for (
const std::string&
weight_name : nominal_weight_names) {
155 m_config->setNominalWeightIndex(weight_index - pmg_weight_names.begin());
156 if (multiple_matches.size() > 1) {
157 std::stringstream s_multiple_matches;
158 for (
const std::string &wname : multiple_matches)
159 s_multiple_matches <<
"\"" << wname <<
"\"\n";
160 ATH_MSG_WARNING(
"Multiple NominalWeightNames match for this MC sample!\n" + s_multiple_matches.str()
161 +
"\nThe one we will use is \"" +
m_nominal_weight_name +
"\". Check whether this is really correct!");
166 ATH_MSG_ERROR(
"No MC weight matches any of the names specified by NominalWeightNames "
167 "option\nThis may indicate a sample with non-standard nominal MC weight name!");
168 std::stringstream weights_log;
169 for (
size_t w_indx=0; w_indx < pmg_weight_names.size(); ++w_indx) {
170 weights_log <<
"Weight " << w_indx <<
": \"" << pmg_weight_names.at(w_indx) <<
"\"\n";
172 ATH_MSG_ERROR(
"The following weight names are available based on sample metadata:\n" + weights_log.str()
173 +
"\nAdd the correct nominal weight name from this list into the NominalWeightNames option in your config file.");
174 return StatusCode::FAILURE;
178 <<
"\", index: " <<
m_config->nominalWeightIndex());
179 return StatusCode::SUCCESS;
◆ inputHandles()
Return this algorithm's input handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ mcEventWeight()
float top::ScaleFactorCalculator::mcEventWeight |
( |
| ) |
const |
Definition at line 231 of file ScaleFactorCalculator.cxx.
242 if (eventInfo->isAvailable<
float>(
"AnalysisTop_eventWeight"))
return eventInfo->auxdataConst<
float>(
243 "AnalysisTop_eventWeight");
246 sf = eventInfo->mcEventWeights().at(
m_config->nominalWeightIndex());
247 eventInfo->auxdecor<
float>(
"AnalysisTop_eventWeight") =
sf;
248 }
catch (std::out_of_range &
e) {
250 <<
" does not exist: ");
◆ msg() [1/2]
◆ msg() [2/2]
◆ msg_level_name()
const std::string & asg::AsgTool::msg_level_name |
( |
| ) |
const |
|
inherited |
A deprecated function for getting the message level's name.
Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:
MSG::name( msg().level() )
This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.
- Returns
- The string name of the current minimum message level that's printed
Definition at line 101 of file AsgTool.cxx.
◆ msgLvl()
◆ operator=()
◆ outputHandles()
Return this algorithm's output handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ pileupWeight()
float top::ScaleFactorCalculator::pileupWeight |
( |
| ) |
const |
Definition at line 215 of file ScaleFactorCalculator.cxx.
224 "Failed to retrieve EventInfo");
226 if (eventInfo->isAvailable<
float>(
"PileupWeight"))
sf = eventInfo->auxdataConst<
float>(
"PileupWeight");
◆ print()
void asg::AsgTool::print |
( |
| ) |
const |
|
virtualinherited |
Print the state of the tool.
Implements asg::IAsgTool.
Reimplemented in JetRecTool, JetFinder, JetModifiedMassDrop, JetFromPseudojet, JetReclusterer, JetReclusteringTool, JetTruthLabelingTool, JetPileupLabelingTool, HI::HIPileupTool, top::TopObjectSelection, JetDumper, JetBottomUpSoftDrop, JetRecursiveSoftDrop, JetSoftDrop, JetConstituentsRetriever, JetSubStructureMomentToolsBase, JetSplitter, JetToolRunner, JetPruner, JetPseudojetRetriever, JetTrimmer, AsgHelloTool, and KtDeltaRTool.
Definition at line 131 of file AsgTool.cxx.
◆ renounce()
◆ renounceArray()
◆ sysInitialize()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ m_btagSF
◆ m_config
◆ m_detStore
◆ m_electronSF
◆ m_evtStore
◆ m_fwdElectronSF
◆ m_globalLeptonTriggerSF
◆ m_jetSF
◆ m_muonSF
◆ m_nominal_weight_name
std::string top::ScaleFactorCalculator::m_nominal_weight_name |
|
private |
◆ m_photonSF
◆ m_pileupSF
◆ m_pmg_truth_weight_tool
◆ m_sherpa_22_reweight_tool
◆ m_tauSF
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files:
def retrieve(aClass, aKey=None)
ToolHandle< PMGTools::IPMGTruthWeightTool > m_pmg_truth_weight_tool
std::string find(const std::string &s)
return a remapped string
std::unique_ptr< top::ElectronScaleFactorCalculator > m_electronSF
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
StatusCode initialize_nominal_MC_weight()
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
std::unique_ptr< top::GlobalLeptonTriggerCalculator > m_globalLeptonTriggerSF
virtual void setOwner(IDataHandleHolder *o)=0
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
std::string m_nominal_weight_name
std::unique_ptr< top::BTagScaleFactorCalculator > m_btagSF
ToolHandle< PMGTools::PMGSherpa22VJetsWeightTool > m_sherpa_22_reweight_tool
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
std::unique_ptr< top::JetScaleFactorCalculator > m_jetSF
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
std::unique_ptr< top::TauScaleFactorCalculator > m_tauSF
Class describing the basic event information.
std::unique_ptr< top::MuonScaleFactorCalculator > m_muonSF
std::unique_ptr< top::PileupScaleFactorCalculator > m_pileupSF
#define ATH_MSG_WARNING(x)
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
std::shared_ptr< top::TopConfig > m_config
std::unique_ptr< top::FwdElectronScaleFactorCalculator > m_fwdElectronSF
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
std::unique_ptr< top::PhotonScaleFactorCalculator > m_photonSF