27{
28 using namespace asg::SFHelper;
30 setMsgLevel(MSG::INFO);
31
33 if (!isToys) {
34
35
36
37
38
39
40
41 std::vector<CP::SystematicVariation> positiveVar{};
42 std::vector<CP::SystematicVariation> negativeVar{};
43 for (const auto& sys : systs) {
44 float param =
sys.parameter();
45 if (param < 0) {
46 negativeVar.push_back(sys);
47 } else {
48 positiveVar.push_back(sys);
49 }
50 }
51
52 auto totalSyst =
54 const std::vector<CP::SystematicVariation>&
variations,
55 const double nominal) {
56 double total2{};
57 double systematic{};
58 for (const auto& sys : variations) {
59 if (
tool->applySystematicVariation({ sys }) != StatusCode::SUCCESS ||
60 tool->getEfficiencyScaleFactor(el, systematic) !=
63 return -999.0;
64 }
65 total2 += (nominal - systematic) * (nominal - systematic);
66 }
67 return std::sqrt(total2);
68 };
69
70
71
75 totalNeg = totalSyst(el, negativeVar, nominalSF);
76 totalPos = totalSyst(el, positiveVar, nominalSF);
77 } else {
78 CP::MakeSystematicsVector sysVec;
82 std::vector<CP::SystematicSet> toys = sysVec.
result(
"toys");
83 std::vector<double> toysVal{};
84 toysVal.reserve(toys.size());
85
86
87 for (const auto& sys : toys) {
88 double systematic{};
89 ANA_CHECK(
tool->applySystematicVariation(sys) == StatusCode::SUCCESS &&
90 tool->getEfficiencyScaleFactor(el, systematic) ==
93 << " toy Result : " << systematic);
94 toysVal.push_back(systematic);
95 }
96
97
98
99
100
101
102 double meanK{ toysVal[0] };
103 double meanK_1{ toysVal[0] };
106 const size_t N = toysVal.size();
107
108 for (
size_t i = 1;
i !=
N; ++
i) {
109 const double x{ toysVal[
i] };
110 const double invk{ (1.0 / (++
k)) };
111 meanK_1 = meanK + (
x - meanK) * invk;
112 s += (
x - meanK_1) * (
x - meanK);
113 meanK = meanK_1;
114 }
115 const double variance =
s / (
N - 1);
116 nominalSF = meanK;
117 totalNeg = sqrt(variance);
118 totalPos = sqrt(variance);
119 }
120 return 0;
121}
@ Ok
The correction was done successfully.
void addGroup(const std::string &val_label)
finish configuration for this group and add a new one
void setToys(unsigned val_toys)
set the number of toys to run for this group
const std::vector< SystematicSet > & result(const std::string &label) const
the list of nuisance parameter points generated with the given label
void calc(const SystematicSet &sysList)
fill in result
Class to wrap a set of SystematicVariations.
Electron_v1 Electron
Definition of the current "egamma version".