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);
62 gamma.setError(sigmaRel);
72 gamma.setError(sigmaRel);
76 if (sigmaRel < minSigma) {
78 <<
"Warning: relative sigma " << sigmaRel <<
" for \"" << gamma.GetName() <<
"\" falls below threshold of "
79 << minSigma <<
". Setting: " << gamma.GetName() <<
" to constant" << std::endl;
80 gamma.setConstant(
true);
88 std::span<const double> relSigmas,
double minSigma,
94 if (relSigmas.size() != paramSet.
size()) {
95 std::cout <<
"Error: In createGammaConstraints, encountered bad number of relative sigmas" << std::endl;
96 std::cout <<
"Given vector with " << relSigmas.size() <<
" bins,"
97 <<
" but require exactly " << paramSet.
size() << std::endl;
103 for (std::size_t i = 0; i < paramSet.
size(); ++i) {
108 <<
"Creating constraint for: " << gamma.GetName() <<
". Type of constraint: " <<
type << std::endl;
110 const double sigmaRel = relSigmas[i];
116 <<
"Not creating constraint term for " << gamma.GetName() <<
" because sigma = " << sigmaRel
118 <<
" (bin number = " << i <<
")" << std::endl;
123 std::string constrName = std::string(gamma.GetName()) +
"_constraint";
124 std::string nomName = std::string(
"nom_") + gamma.GetName();
131 std::string sigmaName = std::string(gamma.GetName()) +
"_sigma";
132 auto constrSigma = std::make_unique<RooConstVar>(sigmaName.c_str(), sigmaName.c_str(), sigmaRel);
135 auto constrNom = std::make_unique<RooRealVar>(nomName.c_str(), nomName.c_str(), 1.0, 0, 10);
136 constrNom->setConstant(
true);
139 auto term = std::make_unique<RooGaussian>(constrName.c_str(), constrName.c_str(), *constrNom, gamma, *constrSigma);
141 out.globalObservables.push_back(constrNom.get());
143 term->addOwnedComponents(std::move(constrSigma));
144 term->addOwnedComponents(std::move(constrNom));
146 out.constraints.emplace_back(std::move(term));
150 const double tau = 1. / (sigmaRel * sigmaRel);
153 auto constrNom = std::make_unique<RooRealVar>(nomName.c_str(), nomName.c_str(), tau);
154 constrNom->setMin(0);
155 constrNom->setConstant(
true);
158 std::string scalingName = std::string(gamma.GetName()) +
"_tau";
159 auto poissonScaling = std::make_unique<RooConstVar>(scalingName.c_str(), scalingName.c_str(), tau);
162 std::string poisMeanName = std::string(gamma.GetName()) +
"_poisMean";
163 auto constrMean = std::make_unique<RooProduct>(poisMeanName.c_str(), poisMeanName.c_str(), gamma, *poissonScaling);
166 auto term = std::make_unique<RooPoisson>(constrName.c_str(), constrName.c_str(), *constrNom, *constrMean);
167 term->setNoRounding(
true);
169 out.globalObservables.push_back(constrNom.get());
171 term->addOwnedComponents(std::move(poissonScaling));
172 term->addOwnedComponents(std::move(constrMean));
173 term->addOwnedComponents(std::move(constrNom));
175 out.constraints.emplace_back(std::move(term));
178 std::cout <<
"Error: Did not recognize Stat Error constraint term type: " <<
type
179 <<
" 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.
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.