![Logo](../../ATLAS-Logo-Square-Blue-RGB.png) |
ATLAS Offline Software
|
Go to the documentation of this file.
22 m_electronSF(nullptr),
23 m_fwdElectronSF(nullptr),
29 m_sherpa_22_reweight_tool(
"PMGSherpa22VJetsWeightTool"),
30 m_globalLeptonTriggerSF(nullptr),
31 m_pmg_truth_weight_tool(
"PMGTruthWeightTool"),
32 m_nominal_weight_name(
"") {
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;
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;
201 eventInfo->
auxdecor<
double>(
"Sherpa22VJetsWeight") = sherpa_weight;
207 return StatusCode::SUCCESS;
212 return StatusCode::SUCCESS;
224 "Failed to retrieve EventInfo");
243 "AnalysisTop_eventWeight");
247 eventInfo->
auxdecor<
float>(
"AnalysisTop_eventWeight") =
sf;
248 }
catch (std::out_of_range &
e) {
250 <<
" does not exist: ");
def retrieve(aClass, aKey=None)
ToolHandle< PMGTools::IPMGTruthWeightTool > m_pmg_truth_weight_tool
TopConfig A simple configuration that is NOT a singleton.
std::string find(const std::string &s)
return a remapped string
std::unique_ptr< top::ElectronScaleFactorCalculator > m_electronSF
const std::vector< float > & mcEventWeights() const
The weights of all the MC events used in the simulation.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
float mcEventWeight() const
StatusCode initialize_nominal_MC_weight()
std::unique_ptr< top::GlobalLeptonTriggerCalculator > m_globalLeptonTriggerSF
StatusCode initialize()
Dummy implementation of the initialisation function.
Decorator< T, ALLOC >::reference_type auxdecor(const std::string &name) const
Fetch an aux decoration, as a non-const reference.
Accessor< T, ALLOC >::const_reference_type auxdataConst(const std::string &name) const
Fetch an aux data variable, as a const reference.
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
::StatusCode StatusCode
StatusCode definition for legacy code.
float pileupWeight() const
void check(bool thingToCheck, const std::string &usefulFailureMessage)
Print an error message and terminate if thingToCheck is false.
std::unique_ptr< top::JetScaleFactorCalculator > m_jetSF
bool isAvailable(const std::string &name, const std::string &clsname="") const
Check if an aux variable is available for reading.
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)
StatusCode executePileup()
ScaleFactorCalculator(const std::string &name)
std::shared_ptr< top::TopConfig > m_config
std::unique_ptr< top::FwdElectronScaleFactorCalculator > m_fwdElectronSF
std::unique_ptr< top::PhotonScaleFactorCalculator > m_photonSF