@@ -1499,6 +1499,7 @@ vector<double> fitAsym(
14991499* @param workspace_title Title of workspace in which to work
15001500* @param dataset_name Dataset name
15011501* @param dataset_title Dataset title
1502+ * @param weight_name Name of weight variable, ignored if empty
15021503* @param categories_as_float List of category variables to include as asymmetry fit variables in dataset
15031504* @param helicity Name of helicity variable
15041505* @param helicity_states Map of state names to helicity values
@@ -1591,6 +1592,7 @@ void getKinBinnedAsym(
15911592 // parameters passed to data::createDataset()
15921593 string dataset_name,
15931594 string dataset_title,
1595+ string weight_name,
15941596 vector<string> categories_as_float,
15951597 string helicity,
15961598 map<string,int > helicity_states,
@@ -1820,6 +1822,7 @@ void getKinBinnedAsym(
18201822 ws,
18211823 dataset_name,
18221824 dataset_title,
1825+ weight_name,
18231826 categories_as_float,
18241827 helicity,
18251828 helicity_states,
@@ -1901,6 +1904,7 @@ void getKinBinnedAsym(
19011904 saga::signal::applySPlot (
19021905 ws,
19031906 dataset_name,
1907+ weight_name,
19041908 Form (" %s_%s" ,massfit_sgYield_name.c_str (),scheme_binid.c_str ()),// NOTE: getGenAsymPdf() renames these variables to ensure workspace uniqueness
19051909 Form (" %s_%s" ,massfit_bgYield_name.c_str (),scheme_binid.c_str ()),
19061910 Form (" %s_%s" ,massfit_pdf_name.c_str (),scheme_binid.c_str ()),
@@ -1976,6 +1980,7 @@ void getKinBinnedAsym(
19761980 ws_sg, // NOTE: Use separate sideband workspace for dataset, variable, and pdf name uniqueness.
19771981 dataset_name,
19781982 dataset_title,
1983+ weight_name,
19791984 categories_as_float,
19801985 helicity,
19811986 helicity_states,
@@ -2050,6 +2055,7 @@ void getKinBinnedAsym(
20502055 ws_sb, // NOTE: Use separate sideband workspace for dataset, variable, and pdf name uniqueness.
20512056 dataset_name,
20522057 dataset_title,
2058+ weight_name,
20532059 categories_as_float,
20542060 helicity,
20552061 helicity_states,
@@ -2113,49 +2119,47 @@ void getKinBinnedAsym(
21132119 LOG_DEBUG (Form (" [%s]: Extracting results..." , method_name.c_str ()));
21142120 int nbinvars = binvars.size ();
21152121 int nparams = asymfitpar_inits.size ();
2116- double xs[nbinvars] ;
2117- double exs[nbinvars] ;
2122+ vector< double > xs;
2123+ vector< double > exs;
21182124 int count;
21192125
2120- double ys[nparams];
2121- double eys[nparams];
2122- double ys_sb[nparams];
2123- double eys_sb[nparams];
2124- double depols[nparams];
2125- double edepols[nparams];
2126- double ys_corrected[nparams];
2127- double eys_corrected[nparams];
2128- double rawasyms[(const int )rawasymvars.size ()];
2129- double rawasymerrs[(const int )rawasymvars.size ()];
2126+ vector<double > ys;
2127+ vector<double > eys;
2128+ vector<double > ys_sb;
2129+ vector<double > eys_sb;
2130+ vector<double > depols;
2131+ vector<double > edepols;
2132+ vector<double > rawasyms;
2133+ vector<double > rawasymerrs;
21302134
21312135 // Get asymmetry fit bin data
21322136 int k = 0 ;
21332137 count = (int )asymfit_result[k++];
21342138 for (int idx=0 ; idx<binvars.size (); idx++) {
2135- xs[idx] = asymfit_result[k++];
2136- exs[idx] = asymfit_result[k++];
2139+ xs. push_back ( asymfit_result[k++]) ;
2140+ exs. push_back ( asymfit_result[k++]) ;
21372141 }
21382142 for (int idx=0 ; idx<depolvars.size (); idx++) {
2139- depols[idx] = asymfit_result[k++];
2140- edepols[idx] = asymfit_result[k++];
2143+ depols. push_back ( asymfit_result[k++]) ;
2144+ edepols. push_back ( asymfit_result[k++]) ;
21412145 }
21422146 for (int idx=0 ; idx<rawasymvars.size (); idx++) {
2143- rawasyms[idx] = asymfit_result[k++];
2144- rawasymerrs[idx] = asymfit_result[k++];
2147+ rawasyms. push_back ( asymfit_result[k++]) ;
2148+ rawasymerrs. push_back ( asymfit_result[k++]) ;
21452149 }
21462150 for (int idx=0 ; idx<nparams; idx++) {
2147- ys[idx] = asymfit_result[k++];
2148- eys[idx] = asymfit_result[k++];
2151+ ys. push_back ( asymfit_result[k++]) ;
2152+ eys. push_back ( asymfit_result[k++]) ;
21492153 }
21502154 if (use_binned_sb_bgfracs) {
21512155 for (int idx=0 ; idx<nparams; idx++) {
2152- ys_sb[idx] = asymfit_result[k++];
2153- eys_sb[idx] = asymfit_result[k++];
2156+ ys_sb. push_back ( asymfit_result[k++]) ;
2157+ eys_sb. push_back ( asymfit_result[k++]) ;
21542158 }
21552159 }
21562160
2157-
21582161 // Get mass fit bin data
2162+ LOG_DEBUG (Form (" [%s]: Extracting mass fit results..." , method_name.c_str ()));
21592163 double int_sg_pdf_val;
21602164 double int_sg_pdf_err;
21612165 double int_bg_pdf_val;
@@ -2178,7 +2182,7 @@ void getKinBinnedAsym(
21782182 if (massfit_result.size ()>0 ) {
21792183
21802184 // Start counter
2181- int m = 1 ; // NOTE: Ignore count which should first entry
2185+ int m = 1 ; // NOTE: Ignore count which should be first entry
21822186
21832187 // Add signal region integration values
21842188 int_sg_pdf_val = massfit_result[m++];
@@ -2223,7 +2227,7 @@ void getKinBinnedAsym(
22232227 double epsilon, epsilon_err;
22242228 if (use_sb_subtraction) {
22252229 LOG_DEBUG (Form (" [%s]: Applying sideband subtraction..." , method_name.c_str ()));
2226- int k2 = 1 + binvars.size () + depolvars.size ();
2230+ int k2 = 1 + 2 * ( binvars.size () + depolvars.size () + rawasymvars. size () );
22272231 epsilon = eps_bg_pdf;
22282232 epsilon_err = eps_bg_pdf_err;
22292233 for (int idx=0 ; idx<nparams; idx++) {
@@ -2238,13 +2242,8 @@ void getKinBinnedAsym(
22382242 if (use_average_depol) {
22392243 LOG_DEBUG (Form (" [%s]: Dividing out depolarization factors..." , method_name.c_str ()));
22402244 for (int idx=0 ; idx<nparams; idx++) {
2241- ys_corrected[idx] = ys[idx] / depols[idx];
2242- eys_corrected[idx] = eys[idx] / depols[idx];
2243- }
2244- } else {
2245- for (int idx=0 ; idx<nparams; idx++) {
2246- ys_corrected[idx] = ys[idx];
2247- eys_corrected[idx] = eys[idx];
2245+ ys[idx] = ys[idx] / depols[idx];
2246+ eys[idx] = eys[idx] / depols[idx];
22482247 }
22492248 }
22502249
@@ -2260,8 +2259,6 @@ void getKinBinnedAsym(
22602259 out << " ys_sb[" << idx <<" ] = " << ys_sb[idx] << " \n " ;
22612260 out << " eys_sb[" << idx <<" ] = " << eys_sb[idx] << " \n " ;
22622261 }
2263- out << " ys_corrected[" << idx <<" ] = " << ys_corrected[idx] << " \n " ;
2264- out << " eys_corrected[" << idx <<" ] = " << eys_corrected[idx] << " \n " ;
22652262 }
22662263 out << " ---------------------------\n " ;
22672264
@@ -2283,8 +2280,8 @@ void getKinBinnedAsym(
22832280 csvout << rawasymerrs[rr] << csv_separator.c_str ();
22842281 }
22852282 for (int aa=0 ; aa<nparams; aa++) {
2286- csvout << ys_corrected [aa] << csv_separator.c_str ();// NOTE: This is the default naming from analysis::fitAsym()
2287- csvout << eys_corrected [aa];
2283+ csvout << ys [aa] << csv_separator.c_str ();// NOTE: This is the default naming from analysis::fitAsym()
2284+ csvout << eys [aa];
22882285 if (aa<nparams-1 || single_massfit || use_binned_sb_bgfracs) csvout << csv_separator.c_str ();
22892286 else csvout << endl;// NOTE: IMPORTANT!
22902287 }
0 commit comments