62 void MakeSystematicsVector ::
63 testInvariant ()
const
70 MakeSystematicsVector ::
71 MakeSystematicsVector ()
79 const std::vector<SystematicSet>& MakeSystematicsVector ::
80 result (
const std::string&
label)
const
86 throw std::runtime_error (
"unknown systematics group: " +
label);
92 void MakeSystematicsVector ::
99 std::map<std::string,std::vector<SystematicSet>> myresult;
101 for (std::size_t group = 0; group !=
m_config.size(); ++ group)
103 const auto& config =
m_config[group];
108 auto& subresult = myresult[config.label];
113 if (baseSys[group].
empty())
116 if (config.toys == 0)
118 for (
auto sys : baseSys[group])
121 RCU_ASSERT (!sys.second.front().isToyEnsemble());
122 if (sys.second.front().isContinuousEnsemble())
129 }
else if (sys.second.front().isEnsemble())
133 throw std::runtime_error (
"unsupported ensemble systematic: " + sys.first);
137 for (
const auto & mysys : sys.second)
140 subresult.back().insert(mysys);
146 std::vector<CP::SystematicSet> toys (config.toys);
148 for (
auto sys : baseSys[group])
153 if (sys.second.front().isContinuousEnsemble())
155 std::unique_ptr<TRandom3> random (
new TRandom3);
156 random->SetSeed (hash_string (sys.first));
158 for (
auto& toy : toys)
160 }
else if (sys.second.front().isToyEnsemble())
162 for (
unsigned toy = 0; toy != config.toys; ++ toy)
168 throw std::runtime_error (
"unsupported ensemble systematic for toys: " + sys.first);
171 for (
auto& toy : toys)
172 subresult.push_back (std::move (toy));
181 void MakeSystematicsVector ::
182 addGroup (
const std::string& val_label)
186 config.label = val_label;
187 m_config.push_back (std::move(config));
192 void MakeSystematicsVector ::
193 setPattern (
const std::string& val_pattern)
196 m_config.back().pattern = val_pattern;
201 void MakeSystematicsVector ::
202 setSigma (
float val_sigma)
211 void MakeSystematicsVector ::
212 setToys (
unsigned val_toys)
221 void MakeSystematicsVector ::
230 std::vector<std::map<std::string,std::vector<SystematicVariation>>>
231 MakeSystematicsVector ::
234 std::map<std::string,std::vector<SystematicVariation> > basesys;
235 for (
const auto & sys : sysList)
237 basesys[sys.basename()].push_back (sys);
239 std::vector<std::map<std::string,std::vector<SystematicVariation> >>
241 for (
auto sys : basesys)
245 for (
const auto & mysys : sys.second)
247 if (mysys.isEnsemble())
249 if (!ensemble.
empty())
250 throw std::runtime_error (
"inconsistent ensembles requested: " + ensemble.
name() +
" " + mysys.name());
256 std::size_t group =
m_config.size();
257 for (std::size_t iter = 0; iter !=
m_config.size(); ++ iter)
277 throw std::runtime_error (
"toys only supported for ensemble systematics");
282 throw std::runtime_error (
"no systematics group for systematic: " + sys.first);
284 if (!ensemble.
empty())
286 basesysList[group][sys.first].push_back (std::move(ensemble));
289 basesysList[group][sys.first] = std::move (sys.second);
#define RCU_REQUIRE2(x, y)
#define RCU_CHANGE_INVARIANT(x)
#define RCU_NEW_INVARIANT(x)
#define RCU_READ_INVARIANT(x)
static const Attributes_t empty
std::string m_useForNominal
the group for which useForNominal was set
std::vector< std::map< std::string, std::vector< SystematicVariation > > > calcBaseSys(const SystematicSet &sysList)
make the list of base systematics for calc
std::vector< GroupConfig > m_config
the configuration on a per-group basis
std::map< std::string, std::vector< SystematicSet > > m_result
the value of result
Class to wrap a set of SystematicVariations.
static SystematicVariation makeToyVariation(const std::string &basename, unsigned toyIndex, float toyScale)
constructor for toy systematics
bool isToyEnsemble() const
whether this represents a toy ensemble
bool empty() const
returns: whether this is an empty systematic, i.e.
const std::string & name() const
description: the full systematics name, for use in strings, etc.
std::string label(const std::string &format, int i)
Select isolated Photons, Electrons and Muons.
bool match_expr(const std::regex &expr, std::string_view str)
returns: whether we can match the entire string with the regular expression guarantee: strong failure...
std::string str(const TrigT2MbtsBits_v1 &trigT2MbtsBits)
the configuration for the given group