259 genie::Messenger* messenger = genie::Messenger::Instance();
266 genie::utils::app_init::MesgThresholds(
"Messenger_whisper.xml" );
273 MF_LOG_INFO(
"GENIEWeightCalc") <<
"Configuring GENIE weight"
274 <<
" calculator " << this->
GetName();
280 messenger->SetPriorityLevel(
"TransverseEnhancementFFModel",
292 std::string genie_tune_name =
p.get<std::string>(
"TuneName",
"${GENIE_XSEC_TUNE}");
297 std::string evgen_list_name =
p.get<std::string>(
"EventGeneratorList",
"");
300 evgb::SetEventGeneratorListAndTune( evgen_list_name, genie_tune_name );
305 const fhicl::ParameterSet& param_CVs =
p.get<fhicl::ParameterSet>(
306 "genie_central_values", fhicl::ParameterSet() );
307 std::vector< std::string > CV_knob_names = param_CVs.get_all_keys();
309 std::map< genie::rew::GSyst_t, double > gsyst_to_cv_map;
310 genie::rew::GSyst_t temp_knob;
312 if ( !CV_knob_names.empty() && !
fQuietMode ) MF_LOG_INFO(
"GENIEWeightCalc")
313 <<
"Configuring non-default GENIE knob central values from input"
314 <<
" FHiCL parameter set";
316 for (
const auto& knob_name : CV_knob_names ) {
317 double CV_knob_value = param_CVs.get<
double>( knob_name );
318 if ( valid_knob_name(knob_name, temp_knob) ) {
319 if ( gsyst_to_cv_map.count( temp_knob ) ) {
320 throw cet::exception(__PRETTY_FUNCTION__) <<
"Duplicate central values"
321 <<
" were configured for the " << knob_name <<
" GENIE knob.";
323 gsyst_to_cv_map[ temp_knob ] = CV_knob_value;
325 MF_LOG_INFO(
"GENIEWeightCalc") <<
"Central value for the " << knob_name
326 <<
" knob was set to " << CV_knob_value;
332 const fhicl::ParameterSet& pset =
p.get<fhicl::ParameterSet>(
GetName());
334 auto const& pars = pset.get<std::vector<std::string> >(
"parameter_list");
336 std::vector<float> parsigmas = pset.get<std::vector<float> >(
"parameter_sigma", std::vector<float>() );
341 std::vector< genie::rew::GSyst_t > knobs_to_use;
342 for (
const auto& knob_name : pars ) {
343 if ( valid_knob_name(knob_name, temp_knob) ) knobs_to_use.push_back( temp_knob );
347 std::vector< genie::rew::GSyst_t > all_knobs_vec = knobs_to_use;
348 for (
const auto& pair : gsyst_to_cv_map ) {
349 genie::rew::GSyst_t cv_knob = pair.first;
350 auto begin = all_knobs_vec.cbegin();
351 auto end = all_knobs_vec.cend();
354 std::map< std::string, int >
358 std::string
mode = pset.get<std::string>(
"mode");
360 int num_universes = 1;
362 std::string array_name_for_exception;
364 if (pars.size() != parsigmas.size()) {
365 array_name_for_exception =
"parameter_sigma";
369 if(mode.find(
"pmNsigma") != std::string::npos){
374 for (
size_t i=0; i<pars.size(); i++){
378 }
else if(mode.find(
"multisigma") != std::string::npos){
381 array_name_for_exception =
"";
383 array_name_for_exception =
"multisigma";
384 throw cet::exception(__PRETTY_FUNCTION__) <<
GetName()
385 <<
"::Bad fcl configuration. multisigma only supports one parameter_list";
388 for (
size_t i=0; i<pars.size(); i++){
389 num_universes = pars.size() * parsigmas.size();
390 std::vector<float> withds;
391 for (
size_t j=0; j<parsigmas.size(); j++){
392 withds.push_back(parsigmas[j]);
397 }
else if(mode.find(
"multisim") != std::string::npos){
399 num_universes = pset.get<
int>(
"number_of_multisims", 1 );
401 MF_LOG_INFO(
"GENIEWeightCalc") <<
"GENIE weight calculator "
402 << this->
GetName() <<
" will generate " << num_universes
403 <<
" multisim universes";
405 for (
size_t i=0; i<pars.size(); i++) {
409 }
else if(mode.find(
"fixed") != std::string::npos){
413 for (
size_t i=0; i<pars.size(); i++) {
419 throw cet::exception(__PRETTY_FUNCTION__) <<
GetName()
420 <<
":: Mode is not recognized: "<<
mode;
424 if( array_name_for_exception.size() > 1){
426 throw cet::exception(__PRETTY_FUNCTION__) <<
GetName()
427 <<
"::Bad fcl configuration. parameter_list and "
428 << array_name_for_exception
429 <<
" need to have same number of parameters.";
438 std::cout <<
GetFullName() <<
": Initialize WeightCalculators with "<<num_universes<<
" univeres."<<std::endl;
444 for (
size_t univ = 0; univ < reweightVector.size(); ++univ ) {
446 auto& rwght = reweightVector.at( univ );
447 genie::rew::GSystSet& syst = rwght.Systematics();
455 std::string
name = it.first.fName;
459 auto iter = gsyst_to_cv_map.find( knob );
460 if ( iter != gsyst_to_cv_map.end() ) {
461 cv_shift = iter->second;
462 if ( !
fQuietMode ) MF_LOG_INFO(
"GENIEWeightCalc")
463 <<
"CV offset added to the "
464 << genie::rew::GSyst::AsString( knob )
465 <<
" knob. New sigma for universe #" << univ <<
" is "
469 double twk_dial_value = it.second[univ]+cv_shift;
470 syst.Set( knob, twk_dial_value );
472 std::cout <<
GetFullName() <<
": univ "<<univ<<
" "<<genie::rew::GSyst::AsString( knob )<<
" Knob value: "<<twk_dial_value<<std::endl;
475 MF_LOG_INFO(
"GENIEWeightCalc") <<
"In universe #" << univ <<
", knob name" << name
476 <<
" (" << genie::rew::GSyst::AsString( knob ) <<
") was set to"
477 <<
" the value " << twk_dial_value <<
" with shift "<<cv_shift;
void AddParameter(std::string name, float width, float mean=0, size_t covIndex=0)
EventWeightParameterSet fParameterSet
void Configure(std::string name, ReweightType rwtype, size_t nuni=1)
std::string fGenieModuleLabel
std::string FromString(const std::string &value)
void Sample(CLHEP::HepRandomEngine &engine)
auto end(FixedBins< T, C > const &) noexcept
std::map< EventWeightParameter, std::vector< float > > fParameterMap
Mapping of definitions to the set of values.
auto begin(FixedBins< T, C > const &) noexcept
std::vector< genie::rew::GReWeight > reweightVector
void SetupWeightCalculators(genie::rew::GReWeight &rw, const std::map< std::string, int > &modes_to_use)
std::size_t count(Cont const &cont)
std::map< std::string, int > CheckForIncompatibleSystematics(const std::vector< genie::rew::GSyst_t > &knob_vec)
BEGIN_PROLOG don t mess with this pandoraTrackGausCryoW true
BEGIN_PROLOG could also be cout
std::string GetFullName()