16 std::cout <<
"Configuring BhToysHistoProcessor" << std::endl;
18 debug_ = parameters.getInteger(
"debug");
20 mass_hypo_ = parameters.getDouble(
"mass_hypo");
24 seed_ = parameters.getInteger(
"seed");
25 nToys_ = parameters.getInteger(
"nToys");
27 bkg_mult_ = parameters.getInteger(
"toy_bkg_mult");
28 res_scale_ = parameters.getDouble(
"res_scale");
31 bkg_model_ = parameters.getInteger(
"bkg_model");
33 }
catch(std::runtime_error& error) {
34 std::cout << error.what() << std::endl;
40 inF_ =
new TFile(inFilename.c_str());
52 std::cout <<
"[BumpHunter] :: !! WARNING !! Signal injection file, but no histogram, specified! Defaulting to Gaussian.";
54 std::cout <<
"[BumpHunter] :: !! WARNING !! Signal injection histogram, but no file, specified! Defaulting to Gaussian.";
59 std::cout <<
"Background Model ID: " <<
bkg_model_ << std::endl;
107 flat_tuple_->addVariable(
"bkg_rate_mass_hypo_err");
129 flat_tuple_->addVector(
"toy_bkg_rate_mass_hypo_err");
137 std::cout <<
"Running on mass spectrum: " <<
massSpectrum_ << std::endl;
138 std::cout <<
"Running with polynomial order: " <<
poly_order_ << std::endl;
139 std::cout <<
"Running with window factor: " <<
win_factor_ << std::endl;
140 std::cout <<
"Running on mass hypo: " <<
mass_hypo_ << std::endl;
149 std::cout <<
"Filling Fit Results " << std::endl;
164 flat_tuple_->setVariableValue(
"bkg_chi2_prob", bkg_result->Prob());
165 flat_tuple_->setVariableValue(
"bkgsig_chi2_prob", sig_result->Prob());
167 flat_tuple_->setVariableValue(
"bkg_edm", bkg_result->Edm());
168 flat_tuple_->setVariableValue(
"bkg_minuit_status", bkg_result->Status());
169 flat_tuple_->setVariableValue(
"bkg_nll", bkg_result->MinFcnValue());
171 flat_tuple_->setVariableValue(
"edm", sig_result->Edm());
172 flat_tuple_->setVariableValue(
"minuit_status", sig_result->Status());
173 flat_tuple_->setVariableValue(
"nll", sig_result->MinFcnValue());
191 std::vector<HpsFitResult*> toy_results;
197 std::cout <<
"Generating " <<
nToys_ <<
" Toys" << std::endl;
202 std::cout <<
" Signal Shape :: Gaussian" << std::endl;
204 std::cout <<
" Background Multiplier :: " <<
bkg_mult_ << std::endl;
208 for(TH1* hist : toys_hist) {
209 std::cout <<
"Fitting Toy " << toyFitN << std::endl;
215 int toyModelIndex = 0;
216 for(
auto& toy_result : toy_results) {
218 TFitResultPtr toy_bkg_result = toy_result->getBkgFitResult();
220 flat_tuple_->addToVector(
"toy_bkg_chi2_prob", toy_bkg_result->Prob());
221 flat_tuple_->addToVector(
"toy_bkg_edm", toy_bkg_result->Edm());
222 flat_tuple_->addToVector(
"toy_bkg_minuit_status", toy_bkg_result->Status());
223 flat_tuple_->addToVector(
"toy_bkg_nll", toy_bkg_result->MinFcnValue());
226 TFitResultPtr toy_sig_result = toy_result->getCompFitResult();
229 flat_tuple_->addToVector(
"toy_minuit_status", toy_sig_result->Status());
230 flat_tuple_->addToVector(
"toy_nll", toy_sig_result->MinFcnValue());
231 flat_tuple_->addToVector(
"toy_p_value", toy_result->getPValue());
232 flat_tuple_->addToVector(
"toy_q0", toy_result->getQ0());
233 flat_tuple_->addToVector(
"toy_bkg_rate_mass_hypo", toy_result->getFullBkgRate());
234 flat_tuple_->addToVector(
"toy_bkg_rate_mass_hypo_err", toy_result->getFullBkgRateError());
235 flat_tuple_->addToVector(
"toy_sig_yield", toy_result->getSignalYield());
236 flat_tuple_->addToVector(
"toy_sig_yield_err", toy_result->getSignalYieldErr());
237 flat_tuple_->addToVector(
"toy_upper_limit", toy_result->getUpperLimit());
238 flat_tuple_->addToVector(
"toy_model_index", toyModelIndex);
#define DECLARE_PROCESSOR(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Insert description here. more details.
virtual void configure(const ParameterSet ¶meters)
Configure using given parameters.
int bkg_model_
What background model type to use.
int toy_poly_order_
Order of polynomial used to create the toy generator function.
virtual void finalize()
description
TH1 * signal_shape_h_
The signal shape histogram to use.
double mass_hypo_
The signal hypothesis to use in the fit.
int poly_order_
Order of polynomial used to model the background.
BumpHunter * bump_hunter_
The bump hunter manager.
int nToys_
Number of toys to throw and fit.
double res_scale_
The factor by which to scale the mass resolution function.
virtual void initialize(std::string inFilename, std::string outFilename)
description
BhToysHistoProcessor(const std::string &name, Process &process)
Constructor.
FlatTupleMaker * flat_tuple_
The flat tuple manager.
std::string signal_shape_h_file_
The signal shpae histogram file path, if defined.
std::string signal_shape_h_name_
The signal shape histogram name to use, if defined.
TH1 * mass_spec_h
The mass spectrum to fit.
bool asymptotic_limit_
Whether to use the asymptotic upper limit or the power constrained. Defaults to asymptotic.
virtual bool process()
description
std::string massSpectrum_
The name of the mass spectrum to fit.
double getIntegral()
Get the integral within the fit window.
TFitResultPtr getBkgFitResult()
Get background fit result.
TFitResultPtr getCompFitResult()
Get the complete fit result.
float getSignalYieldErr()
Get the error of the signal yield.
double getUpperLimit()
Get the upper fit limit.
double getUpperLimitPValue()
Get the p-value at the upper limit.
double getWindowSize()
Get the size of the fit window.
double getCorrectedMass() const
Get the corrected mass.
double getPValue()
description
std::vector< double > getLikelihoods()
Get the likelihoods.
double getFullBkgRate()
Get the background rate obtained from the signal+background hit at the mass hypo.
float getSignalYield()
Get the signal yield obtained from the signal+background fit.
double getQ0()
description
double getFullBkgRateError()
Get the background rate error from the signal+background fit at the mass hypo.
TFitResultPtr getBkgToysFitResult()
Get background toy model fit result.
std::vector< double > getSignalYields()
Get the signal yields.
double getMass() const
Get the mass hypothesis for the fit.
Processor(const std::string &name, Process &process)
Class constructor.