46 assert(gammas.
size() == relSigmas.size());
48 for (std::size_t i = 0; i < gammas.
size(); ++i) {
50 double sigmaRel = relSigmas[i];
54 gamma.setConstant(
true);
59 gamma.setMax(1. + 5. * sigmaRel);
70 gamma.setError(sigmaRel);
74 if (sigmaRel < minSigma) {
76 <<
"Warning: relative sigma " << sigmaRel <<
" for \"" << gamma.GetName() <<
"\" falls below threshold of "
77 << minSigma <<
". Setting: " << gamma.GetName() <<
" to constant" << std::endl;
78 gamma.setConstant(
true);
86 std::span<const double> relSigmas,
double minSigma,
92 if (relSigmas.size() != paramSet.
size()) {
93 std::cout <<
"Error: In createGammaConstraints, encountered bad number of relative sigmas" << std::endl;
94 std::cout <<
"Given vector with " << relSigmas.size() <<
" bins,"
95 <<
" but require exactly " << paramSet.
size() << std::endl;
101 for (std::size_t i = 0; i < paramSet.
size(); ++i) {
106 <<
"Creating constraint for: " << gamma.GetName() <<
". Type of constraint: " <<
type << std::endl;
108 const double sigmaRel = relSigmas[i];
114 <<
"Not creating constraint term for " << gamma.GetName() <<
" because sigma = " << sigmaRel
116 <<
" (bin number = " << i <<
")" << std::endl;
121 std::string constrName = std::string(gamma.GetName()) +
"_constraint";
122 std::string nomName = std::string(
"nom_") + gamma.GetName();
129 std::string sigmaName = std::string(gamma.GetName()) +
"_sigma";
130 auto constrSigma = std::make_unique<RooConstVar>(sigmaName.c_str(), sigmaName.c_str(), sigmaRel);
133 auto constrNom = std::make_unique<RooRealVar>(nomName.c_str(), nomName.c_str(), 1.0, 0, 10);
134 constrNom->setConstant(
true);
137 auto term = std::make_unique<RooGaussian>(constrName.c_str(), constrName.c_str(), *constrNom, gamma, *constrSigma);
139 out.globalObservables.push_back(constrNom.get());
141 term->addOwnedComponents(std::move(constrSigma));
142 term->addOwnedComponents(std::move(constrNom));
144 out.constraints.emplace_back(std::move(term));
148 const double tau = 1. / (sigmaRel * sigmaRel);
151 auto constrNom = std::make_unique<RooRealVar>(nomName.c_str(), nomName.c_str(), tau);
152 constrNom->setMin(0);
153 constrNom->setConstant(
true);
156 std::string scalingName = std::string(gamma.GetName()) +
"_tau";
157 auto poissonScaling = std::make_unique<RooConstVar>(scalingName.c_str(), scalingName.c_str(), tau);
160 std::string poisMeanName = std::string(gamma.GetName()) +
"_poisMean";
161 auto constrMean = std::make_unique<RooProduct>(poisMeanName.c_str(), poisMeanName.c_str(), gamma, *poissonScaling);
164 auto term = std::make_unique<RooPoisson>(constrName.c_str(), constrName.c_str(), *constrNom, *constrMean);
165 term->setNoRounding(
true);
167 out.globalObservables.push_back(constrNom.get());
169 term->addOwnedComponents(std::move(poissonScaling));
170 term->addOwnedComponents(std::move(constrMean));
171 term->addOwnedComponents(std::move(constrNom));
173 out.constraints.emplace_back(std::move(term));
176 std::cout <<
"Error: Did not recognize Stat Error constraint term type: " <<
type
177 <<
" for : " << gamma.GetName() << std::endl;
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
Storage_t::size_type size() const
RooArgList is a container object that can hold multiple RooAbsArg objects.
RooAbsArg * at(Int_t idx) const
Return object at given index, or nullptr if index is out of range.
RooRealVar represents a variable that can be changed from the outside.
void configureConstrainedGammas(RooArgList const &gammas, std::span< const double > relSigmas, double minSigma)
Configure constrained gamma parameters for fitting.
CreateGammaConstraintsOutput createGammaConstraints(RooArgList const ¶mList, std::span< const double > relSigmas, double minSigma, Constraint::Type type)
Namespace for the RooStats classes.