11 std::cout <<
"Configuring BhMassResSystematicsProcessor" << std::endl;
12 std::string temp_file_name =
"";
13 std::string temp_func_name =
"";
15 debug_ = parameters.getInteger(
"debug");
17 mass_hypo_ = parameters.getDouble(
"mass_hypo");
20 seed_ = parameters.getInteger(
"seed");
21 bkg_model_ = parameters.getInteger(
"bkg_model");
22 res_runs_ = parameters.getInteger(
"num_iters");
23 res_width_ = parameters.getDouble(
"res_sigma");
24 temp_file_name = parameters.getString(
"function_file");
27 nToys_ = parameters.getInteger(
"num_toys");
28 }
catch(std::runtime_error& error) {
29 std::cout << error.what() << std::endl;
32 std::cout <<
"[ DEBUG ] :: Creating ROOT file \"" << temp_file_name <<
"\"." << std::endl;
33 if(temp_file_name !=
"") {
function_file_ =
new TFile(temp_file_name.c_str()); }
38 inF_ =
new TFile(inFilename.c_str());
45 std::cout <<
"Background Model ID: " <<
bkg_model_ << std::endl;
65 std::cout <<
"[ DEBUG ] :: Attempting to acquire parameterization function." << std::endl;
67 std::cout <<
"[ DEBUG ] :: Function file and name are defined!" << std::endl;
68 std::cout <<
"[ DEBUG ] :: Function name is \"" <<
function_name_ <<
"\"." << std::endl;
70 std::cout <<
"[ DEBUG ] :: Acquired function object." << std::endl;
72 std::cout <<
"[ DEBUG ] :: Resolution width for " <<
mass_hypo_ <<
" MeV is " <<
res_width_ <<
"." << std::endl;
73 std::cout <<
"Using mass resolution error parameterization function " <<
function_name_ <<
" from file." << std::endl;
75 std::cout <<
"Using constant mass resolution error " <<
res_width_ <<
"." << std::endl;
146 std::cout <<
"Running on mass spectrum: " <<
massSpectrum_ << std::endl;
147 std::cout <<
"Running with polynomial order: " <<
poly_order_ << std::endl;
148 std::cout <<
"Running with window factor: " <<
win_factor_ << std::endl;
149 std::cout <<
"Running on mass hypothesis: " <<
mass_hypo_ << std::endl;
196 TRandom3 *rng =
new TRandom3();
204 double res_scale = rng->Gaus(1.00,
res_width_);
213 std::cout <<
"Filling Fit Results " << std::endl;
253 std::sort(vec_sigYield.begin(), vec_sigYield.end());
254 std::sort(vec_sigYieldErr.begin(), vec_sigYieldErr.end());
255 std::sort(vec_bkgRate.begin(), vec_bkgRate.end());
256 std::sort(vec_upperLimit.begin(), vec_upperLimit.end());
257 std::sort(vec_pValue.begin(), vec_pValue.end());
260 int median = (int) rint(vec_sigYield.size() / 2.0);
261 int sigma_1_u = (int) rint((vec_sigYield.size() / 2.0) + (0.341 * vec_sigYield.size()));
262 int sigma_1_l = (int) rint((vec_sigYield.size() / 2.0) - (0.341 * vec_sigYield.size()));
311 int toy_sig_samples_ = 0;
312 double bkg_mult_ = 1.00;
313 TH1* signal_shape_h_ =
nullptr;
345 std::cout <<
"Generating " <<
nToys_ <<
" Toys" << std::endl;
350 for(TH1* hist : toys_hist) {
353 std::cout <<
"Fitting Toy " << toyFitN << std::endl;
361 double res_scale = rng->Gaus(1.00,
res_width_);
#define DECLARE_PROCESSOR(CLASS)
Macro which allows the framework to construct a producer given its name during configuration.
Insert description here. more details.
TFile * function_file_
The file that contains the mass resolution error parameterization.
virtual void configure(const ParameterSet ¶meters)
Configure using given parameters.
int bkg_model_
What background model type to use.
virtual void finalize()
description
double res_width_
The width of the resolution Gaussian.
int res_runs_
How many resolution variance runs to make.
double seed_
The toy generator seed. This is always zero.
BhMassResSystematicsProcessor(const std::string &name, Process &process)
Constructor.
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_
How many toys to generated.
int win_factor_
The factor that determines the size of the mass window as.
virtual void initialize(std::string inFilename, std::string outFilename)
Initialize processor.
int toy_res_runs_
How many resolution variance runs to make.
FlatTupleMaker * flat_tuple_
The flat tuple manager.
~BhMassResSystematicsProcessor()
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.
std::string function_name_
The name of the function object in the error file.
virtual bool process()
description
std::string massSpectrum_
The name of the mass spectrum to fit.
void setWindowSizeUsesResScale(bool window_use_res_scale)
Sets whether the window size is scaled according to the resolution scaling factor.
double getMassResolution(double mass)
void setResolutionScale(double res_scale)
Set the resolution after instantiation.
void enableDebug(bool debug=true)
Enable/disable debug.
void setBounds(double low_bound, double high_bound)
Set the histogram bounds.
std::vector< TH1 * > generateToys(TH1 *histogram, double n_toys, int seed, int toy_sig_samples, int bkg_mult=1, TH1 *signal_hist=nullptr)
description
HpsFitResult * performSearch(TH1 *histogram, double mass_hypothesis, bool skip_bkg_fit, bool skip_ul)
Perform a search for a resonance at the given mass hypothesis.
std::vector< double > getVector(std::string variable_name)
description
void addVector(std::string vector_name)
description
void addVariable(std::string variable_name)
description
void addToVector(std::string variable_name, double value)
description
void setVariableValue(std::string variable_name, double value)
description
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
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.
double getMass() const
Get the mass hypothesis for the fit.
Base class for all event processing components.