Classes | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cmf::ShifterAndWeighter Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-03/CovarianceMatrixFit/core/ShifterAndWeighter.h"

Classes

struct  WeighterInfo
 

Public Member Functions

void OscillationCalculatorToUse (cmf::CalcType_t calcType)
 
void InitShiftsAndWeightsToUse (cmf::Location const &loc, fhicl::ParameterSet const &parset)
 
void SetCurrentVals (cmf::Location const &loc)
 
void SetCurrentVals (std::vector< std::string > const &pars, const double *vals)
 
void SetOscillationVals ()
 
void ReportCurrentVals ()
 
float FractionalShift (uint8_t const &param)
 
double Weight (cmf::EventPtr const &curEvent, cmf::MetaData const &md)
 

Static Public Member Functions

static ShifterAndWeighterInstance ()
 

Private Member Functions

 ShifterAndWeighter ()
 
 ~ShifterAndWeighter ()=default
 
void InitShiftsAndWeightsForDetector (cmf::DetType_t const &det, cmf::ParameterSpaceLoc const &detLoc, std::string const &calibFileName, std::vector< WeighterInfo > &weighters, std::map< std::string, uint8_t > &shifters)
 
double TotalWeightFromWeighters ()
 
void SetCurrentEvent (cmf::EventPtr const &curEvent, cmf::MetaData const &md)
 
double const CurrentParameterValue (std::string const &parName)
 
void FillShifterInfo (std::string const &name, cmf::DetType_t const &det)
 
float ShiftForParameter (std::map< std::string, uint8_t > const &shifterMap, cmf::ParameterSpaceLoc const &loc, uint8_t const &param)
 
double OscillationWeight ()
 
double OscillationWeightTrueE ()
 
double OscillationWeightBinCenter ()
 
double AbsNormWeight (std::string const &wgtType, cmf::SelectionType_t const &sel)
 
double BeamSystWeight (std::string const &wgtType, cmf::DetType_t const &det)
 
double BirksNormWeight (std::string const &wgtType, cmf::DetType_t const &det)
 
double CalibSystWeight (std::string const &wgtType)
 
double COHScale2018Weight (std::string const &wgtType, cmf::InteractionType_t const &intType)
 
double CosmicMuNormWeight ()
 
double CosmicOverlayNormWeight ()
 
double DISvnCC1piWeight ()
 
double FluxPCAWeight (size_t index)
 
double GeniePCASystWeight (size_t index)
 
double GENIESystWeight (std::string const &systName)
 
double HornNormWeight (std::string const &wgtType, cmf::BeamType_t const &beam)
 
double MaCCQEReducedWeight ()
 
double MECNormWeight ()
 
double MECShapeWeight (bool anti)
 
double MECInitStateNPFracWeight (bool anti)
 
double MECEnuShapeWeight (bool anti)
 
double NoiseFarNormWeight ()
 
double NCNormWeight ()
 
double NueAcceptSignalKin2018Weight (cmf::BeamType_t const &beamType)
 
double NueAcceptBkg2018Weight (cmf::BeamType_t const &beamType)
 
double NueFDRockMuonWeight ()
 
double RadCorrNueWeight ()
 
double RadCorrNueBarWeight ()
 
double RelNormWeight (std::string const &wgtType, cmf::SelectionType_t const &sel)
 
double RPACCQEWeight ()
 
double RPARESWeight ()
 
double RPACCQEshapeEnhWeight ()
 
double RPACCQEshapeSuppWeight ()
 
double RockNormOnFidWeight ()
 
double SecondClassCurrWeight ()
 
double SumSmallXSec2017Weight (std::string const &wgtType, cmf::SelectionType_t const &selType)
 
double TauScaleSystWeight ()
 
double XSecCVPPFXWeight ()
 
bool UseMECWeight (bool anti)
 
double CalcLinearInterpWgt (double sigma, std::map< float, float > const &wgtsBySigma)
 
void LoadBeamSystHists2017 ()
 
void LoadFluxBeamSystHists ()
 
void LoadCalibrationSystRatios (const std::string &CalibFilename)
 
void LoadGeniePCASystHists ()
 

Private Attributes

cmf::EventfCurrentEvent
 the current event to weight/shift More...
 
cmf::MetaData fCurrentMD
 the metadata for the current event More...
 
cmf::Location fCurrentLoc
 the current point in parameter space More...
 
osc::IOscCalcAdjustablefOscCalc
 the oscillation calculator More...
 
cmf::CalcType_t fCalcType
 type of oscillation calculator More...
 
cmf::WeightType_t fWeightType
 which type of weights to use - oscillation, systematic or both More...
 
bool fTrueEOscillationWeight
 flag to calculate the oscillation weight at the true E_nu vs bin center More...
 
std::unique_ptr< TGraph > fNDMuonCatcherPlusGr
 Graph for the positive shift in the muon catcher. More...
 
std::unique_ptr< TGraph > fNDMuonCatcherMinusGr
 Graph for the negative shift in the muon catcher. More...
 
std::unique_ptr< TF1 > fNDMuonCatcherEShiftPlus
 positive shift in the muon catcher energy More...
 
std::unique_ptr< TF1 > fNDMuonCatcherEShiftMinus
 negative shift in the muon catcher energy More...
 
std::set< double > fTrueEnergyBins
 the true energy binning used by CAF More...
 
std::vector< WeighterInfofWeightersToUseFD
 
std::vector< WeighterInfofWeightersToUseND
 
std::map< std::string, uint8_t > fShiftersToUseFD
 
std::map< std::string, uint8_t > fShiftersToUseND
 
TH1 * fNueAcceptSignalKin2018FHCWgtHist
 
TH1 * fNueAcceptSignalKin2018RHCWgtHist
 
BeamSyst fBeamSyst2017
 
std::vector< BeamSystfVecFluxPrincipals
 This is each of the Flux PCA weights. More...
 
CalibSyst fCalibSyst
 
std::vector< GeniePCASystfVecGeniePCASysts
 This is each of the Genie PCA weights. More...
 

Detailed Description

Definition at line 78 of file ShifterAndWeighter.h.

Constructor & Destructor Documentation

cmf::ShifterAndWeighter::ShifterAndWeighter ( )
private

Definition at line 485 of file ShifterAndWeighter.cxx.

References fNDMuonCatcherEShiftMinus, fNDMuonCatcherEShiftPlus, fNDMuonCatcherMinusGr, fNDMuonCatcherPlusGr, and submit_syst::x.

486  : fOscCalc (nullptr)
488  {
489  // create graphs for the muon catcher positive and negative energy shifts,
490  // then use those to create functions that can be used during the evaluation
491  // of the shifts
492  std::vector<double> initialEnergy({0.00872008, 0.0640129, 0.119306, 0.174598, 0.229891,
493  0.285184, 0.340477, 0.616941, 0.672234, 0.727526,
494  0.782819, 0.838112, 0.893405, 0.948697, 1.00399,
495  1.05928, 1.11458, 1.16987, 1.36119, 1.3964,
496  1.43162, 1.46684, 1.50206, 1.53728, 1.57249,
497  1.60771, 1.64293, 1.67815, 1.71337, 1.74858,
498  1.7838, 1.81902, 1.85424, 1.88946, 1.92467,
499  1.95989, 1.99511, 2.03033, 2.06555, 2.10076,
500  2.20642, 2.24164, 2.27685, 2.31207, 2.34729,
501  2.38251, 2.41773, 2.45294, 2.48816, 2.52338,
502  2.5586, 2.59381, 2.62903, 2.66425, 2.69947,
503  2.73469, 2.7699, 2.80512, 2.84034, 2.87556,
504  2.91078, 2.94599, 2.98121, 3.01643, 3.05165,
505  3.08687, 3.12208, 3.1573, 3.19252, 3.22774,
506  3.26296, 3.29817});
507  std::vector<double> posShift({7.6579, 1.90696, 1.48663, 1.33252, 1.25254,
508  1.20358, 1.17052, 1.09411, 1.08636, 1.0798,
509  1.07416, 1.06927, 1.06498, 1.0612, 1.05783,
510  1.05481, 1.05209, 1.04963, 1.02717, 1.02648,
511  1.02583, 1.02521, 1.02462, 1.02405, 1.02352,
512  1.023, 1.02251, 1.02204, 1.02158, 1.02115,
513  1.02073, 1.02033, 1.01994, 1.01957, 1.01921,
514  1.01887, 1.01853, 1.01821, 1.0179, 1.0176,
515  1.01676, 1.0165, 1.01624, 1.01599, 1.01575,
516  1.01552, 1.01529, 1.01508, 1.01486, 1.01465,
517  1.01445, 1.01426, 1.01407, 1.01388, 1.0137,
518  1.01352, 1.01335, 1.01318, 1.01302, 1.01286,
519  1.0127, 1.01255, 1.0124, 1.01226, 1.01212,
520  1.01198, 1.01184, 1.01171, 1.01158, 1.01146,
521  1.01133, 1.01121});
522  std::vector<double> negShift({0, 0, 0.513372, 0.66748, 0.747457,
523  0.796421, 0.829482, 0.905895, 0.913635, 0.920199,
524  0.925835, 0.930728, 0.935016, 0.938803, 0.942173,
525  0.945192, 0.947911, 0.950373, 0.972833, 0.973519,
526  0.97417, 0.97479, 0.975381, 0.975945, 0.976484,
527  0.976999, 0.977492, 0.977964, 0.978417, 0.978852,
528  0.97927, 0.979671, 0.980057, 0.980429, 0.980787,
529  0.981132, 0.981465, 0.981787, 0.982097, 0.982397,
530  0.98324, 0.983504, 0.983759, 0.984006, 0.984246,
531  0.984479, 0.984705, 0.984925, 0.985138, 0.985346,
532  0.985547, 0.985743, 0.985934, 0.98612, 0.986301,
533  0.986478, 0.98665, 0.986817, 0.986981, 0.98714,
534  0.987296, 0.987448, 0.987596, 0.987741, 0.987882,
535  0.988021, 0.988156, 0.988288, 0.988417, 0.988543,
536  0.988667, 0.988788});
537 
538  // Make TGraphs for the positive and negative shifts
539  fNDMuonCatcherPlusGr = std::make_unique<TGraph>(initialEnergy.size(), &initialEnergy[0], &posShift[0]);
540  fNDMuonCatcherMinusGr = std::make_unique<TGraph>(initialEnergy.size(), &initialEnergy[0], &negShift[0]);
541 
542  // Use the TGraphs to make the stored TF1s
543  fNDMuonCatcherEShiftPlus = std::make_unique<TF1>("posMuonEnergyShift",[&](double*x, double *p){ return fNDMuonCatcherPlusGr ->Eval(x[0]); }, 0., 3.5, 1);
544  fNDMuonCatcherEShiftMinus = std::make_unique<TF1>("negMuonEnergyShift",[&](double*x, double *p){ return fNDMuonCatcherMinusGr->Eval(x[0]); }, 0., 3.5, 1);
545 
546  }
const char * p
Definition: xmltok.h:285
std::unique_ptr< TF1 > fNDMuonCatcherEShiftMinus
negative shift in the muon catcher energy
cmf::CalcType_t fCalcType
type of oscillation calculator
std::unique_ptr< TF1 > fNDMuonCatcherEShiftPlus
positive shift in the muon catcher energy
std::unique_ptr< TGraph > fNDMuonCatcherMinusGr
Graph for the negative shift in the muon catcher.
std::unique_ptr< TGraph > fNDMuonCatcherPlusGr
Graph for the positive shift in the muon catcher.
osc::IOscCalcAdjustable * fOscCalc
the oscillation calculator
cmf::ShifterAndWeighter::~ShifterAndWeighter ( )
privatedefault

Member Function Documentation

double cmf::ShifterAndWeighter::AbsNormWeight ( std::string const &  wgtType,
cmf::SelectionType_t const &  sel 
)
private

Definition at line 1388 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentMD, cmf::ParameterUtility::Instance(), cmf::MetaData::IsNCSelected(), cmf::MetaData::IsNuESelected(), cmf::MetaData::IsNuMuSelected(), cmf::kNCSelection, cmf::kNuESelection, cmf::kNuMuSelection, LOG_DEBUG, cmf::ParameterUtility::ParameterInfo(), sigma(), and cmf::Parameter::Sigma().

Referenced by InitShiftsAndWeightsForDetector().

1390  {
1391  // check for the correct selection for the current event with this function
1392  // sel is one of the two generic selection types, kNuMuSelection or kNuESelection
1393  if(fCurrentMD.IsNuMuSelected() &&
1394  sel == cmf::kNuMuSelection &&
1395  wgtType.find("NuMu") == std::string::npos) return 1.;
1396  else if(fCurrentMD.IsNuESelected() &&
1397  sel == cmf::kNuESelection &&
1398  wgtType.find("Nue") == std::string::npos) return 1.;
1399  else if(fCurrentMD.IsNCSelected() &&
1400  sel == cmf::kNCSelection &&
1401  wgtType.find("NC") == std::string::npos) return 1.;
1402 
1403  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo(wgtType).Sigma();
1404 
1405  LOG_DEBUG("AbsNormWeight")
1406  << " Sigma Value"
1407  << sigma;
1408 
1409  return 1. + sigma * this->CurrentParameterValue(wgtType);
1410 
1411  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
cmf::Parameter const & ParameterInfo(std::string const &parName)
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
bool IsNuMuSelected() const
Definition: Structs.cxx:219
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::MetaData fCurrentMD
the metadata for the current event
bool IsNuESelected() const
Definition: Structs.cxx:225
bool IsNCSelected() const
Definition: Structs.cxx:231
double cmf::ShifterAndWeighter::BeamSystWeight ( std::string const &  wgtType,
cmf::DetType_t const &  det 
)
private

Definition at line 1414 of file ShifterAndWeighter.cxx.

References cmf::MetaData::BeamType(), cmf::BeamSyst::CalcBeamSystWeights(), CalcLinearInterpWgt(), CurrentParameterValue(), cmf::MetaData::detector, fBeamSyst2017, fCurrentEvent, fCurrentMD, cmf::kTrueE, cmf::kTruePDGOrig, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1416  {
1417  if(det != fCurrentMD.detector) return 1.;
1418 
1419  std::map<float, float> wgtBySigma;
1420 
1421  if(sysType.find("2017") != std::string::npos) {
1422  wgtBySigma = fBeamSyst2017.CalcBeamSystWeights(det,
1423  fCurrentMD.BeamType(),
1426  }
1427 
1428  return this->CalcLinearInterpWgt(this->CurrentParameterValue(sysType),
1429  wgtBySigma);
1430  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
cmf::DetType_t detector
Definition: Structs.h:114
std::map< float, float > CalcBeamSystWeights(cmf::DetType_t const &curDet, cmf::BeamType_t const &beamType, double energy, int pdgOrig)
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
cmf::BeamType_t BeamType() const
Definition: Structs.cxx:178
double cmf::ShifterAndWeighter::BirksNormWeight ( std::string const &  wgtType,
cmf::DetType_t const &  det 
)
private

Definition at line 1433 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::MetaData::detector, fCurrentMD, cmf::ParameterUtility::Instance(), cmf::ParameterUtility::ParameterInfo(), sigma(), and cmf::Parameter::Sigma().

Referenced by InitShiftsAndWeightsForDetector().

1435  {
1436  if(det != fCurrentMD.detector) return 1.;
1437 
1438  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo(wgtType).Sigma();
1439 
1440  return 1. + sigma * this->CurrentParameterValue(wgtType);
1441  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
cmf::DetType_t detector
Definition: Structs.h:114
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::MetaData fCurrentMD
the metadata for the current event
double cmf::ShifterAndWeighter::CalcLinearInterpWgt ( double  sigma,
std::map< float, float > const &  wgtsBySigma 
)
private

Definition at line 1192 of file ShifterAndWeighter.cxx.

References LOG_DEBUG, LOG_WARNING, and wgt.

Referenced by BeamSystWeight(), FluxPCAWeight(), GeniePCASystWeight(), GENIESystWeight(), MaCCQEReducedWeight(), RPACCQEshapeEnhWeight(), and RPACCQEshapeSuppWeight().

1194  {
1195  auto mapEnd = wgtsBySigma.end();
1196 
1197  // no way this is a valid number and is obviously stupid
1198  // not using a std::numeric_limits value to avoid rounding to 0
1199  double badVal = -99999999999999.;
1200  double minus2Val = (wgtsBySigma.find(-2.) != mapEnd) ? static_cast<double>(wgtsBySigma.find(-2.)->second) : badVal;
1201  double minus1Val = (wgtsBySigma.find(-1.) != mapEnd) ? static_cast<double>(wgtsBySigma.find(-1.)->second) : badVal;
1202  // double zeroVal = 1.;
1203  double zeroVal = (wgtsBySigma.find( 0.) != mapEnd) ? static_cast<double>(wgtsBySigma.find( 0.)->second) : 1.;
1204  double plus1Val = (wgtsBySigma.find( 1.) != mapEnd) ? static_cast<double>(wgtsBySigma.find( 1.)->second) : badVal;
1205  double plus2Val = (wgtsBySigma.find( 2.) != mapEnd) ? static_cast<double>(wgtsBySigma.find( 2.)->second) : badVal;
1206  double slope = 0.;
1207  double intercept = 0.;
1208 
1209  //Debugging RPA weights
1210  LOG_DEBUG("ShifterAndWeighter")
1211  << "\tCalcLinearInterpWgt: "
1212  << " -2:" << minus2Val
1213  << ", -1:" << minus1Val
1214  << ", 0:" << zeroVal
1215  << ", 1:" << plus1Val
1216  << ", 2:" << plus2Val;
1217 
1218  /*
1219  if(wgtsBySigma.find(-1.) != mapEnd)
1220  LOG_VERBATIM("ShifterAndWeighter")
1221  << "\t\t 0 val from "
1222  << wgtsBySigma.find(0.)->second;
1223  */
1224 
1225  // The following code assumes that at least the -1 sigma, +1 sigma
1226  // values are in the map. If they are not, we have a problem
1227  if(minus1Val == badVal ||
1228  plus1Val == badVal){
1229  LOG_WARNING("ShifterAndWeighterCalcLinearInterpWgt")
1230  << "No values associated with either -1 sigma or +1 sigma "
1231  << "so we cannot calculate a weight, return 1.";
1232  return 1.;
1233  }
1234 
1235  if(sigma <= -1){
1236  // It is possible there is no -2 sigma value from the map,
1237  // in that case just interpolate from 0 to -1 sigma
1238  if(minus2Val != badVal){
1239  slope = (minus1Val - minus2Val);
1240  intercept = minus2Val - slope * (-2.);
1241  }
1242  else{
1243  slope = (zeroVal - minus1Val);
1244  intercept = minus1Val - slope * (-1.);
1245  }
1246  }
1247  else if(sigma > -1. && sigma <= 0.){
1248  slope = (zeroVal - minus1Val);
1249  intercept = minus1Val - slope * (-1.);
1250  }
1251  else if(sigma > 0. && sigma <= 1.){
1252  slope = (plus1Val - zeroVal);
1253  intercept = plus1Val - slope * 1.;
1254  }
1255  else if(sigma > 1.){
1256  // It is possible there is no +2 sigma value from the map,
1257  // in that case just interpolate from 0 to +1 sigma
1258  if(plus2Val != badVal){
1259  slope = (plus2Val - plus1Val);
1260  intercept = plus2Val - slope * 2.;
1261  }
1262  else{
1263  slope = (plus1Val - zeroVal);
1264  intercept = plus1Val - slope * 1.;
1265  }
1266  }
1267 
1268  double wgt = sigma * slope + intercept;
1269 
1270  // Don't let weights be negative
1271  if(wgt < 0) wgt = 0.;
1272 
1273  return wgt;
1274  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
const ana::Var wgt
double sigma(TH1F *hist, double percentile)
#define LOG_WARNING(category)
double cmf::ShifterAndWeighter::CalibSystWeight ( std::string const &  wgtType)
private

Definition at line 1444 of file ShifterAndWeighter.cxx.

References cmf::CalibSyst::CalibSystRatio(), CurrentParameterValue(), cmf::Event::DataVals(), cmf::MetaData::detector, fCalibSyst, fCurrentEvent, fCurrentMD, cmf::kNEARDET, cmf::kNu_RecoE, and cmf::DataVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1445  {
1446  // The calibration shape weights are from the calib-shift-func files
1447 
1448  // The relative and absolute calibration weights are based off of the
1449  // calib-shift-xyview-neg(pos)-offset data sets
1450  // For the absolute calibration both ND and FD are shifted
1451  // according to the same underlying distribution, ie calib-shift-xyview-pos or -neg
1452  // For the relative calibration the ND is shifted according to one, but the FD is
1453  // shifted according to the other. The other wrinkle is that the relative
1454  // calibration only shifts by 1/2 sigma in each detector
1455 
1456  // need to butcher these wgtType string to get the weights by sigma
1457  double sigShift = this->CurrentParameterValue(wgtType);
1458 
1459  // first off, figure out if we are a relative or absolution calibration shift
1460  auto systDataSetName = wgtType.substr(0, wgtType.size() - 3);
1461 
1462  //calib-shift-xyview-neg-offsetWgt calib-shift-func
1463  if(systDataSetName == "RelativeCalibration"){
1464  sigShift *= 0.5;
1466  systDataSetName = (sigShift < 0.) ? "calib-shift-xyview-neg-offset" : "calib-shift-xyview-pos-offset";
1467  else
1468  systDataSetName = (sigShift < 0.) ? "calib-shift-xyview-pos-offset" : "calib-shift-xyview-neg-offset";
1469  }
1470  else if(systDataSetName == "AbsoluteCalibration"){
1471  if(sigShift < 0)
1472  systDataSetName = "calib-shift-xyview-neg-offset";
1473  else
1474  systDataSetName = "calib-shift-xyview-pos-offset";
1475  }
1476  else if(systDataSetName == "CalibrationShape"){
1477  systDataSetName = "calib-shift-func";
1478  }
1479  else if (systDataSetName == "Calibration2020")
1480  systDataSetName = "calibration";
1481 
1482  // now we can get the amount of a 1 sigma shift for the given
1483  // reconstructed energy
1484  auto oneSigmaWgt = fCalibSyst.CalibSystRatio(systDataSetName,
1485  fCurrentMD,
1487 
1488  // the calibration systematics are based on the ratio of 1sigma shifted histograms to the nominal
1489  // A value of oneSigmaWgt > 1 means (1 - oneSigmaWgt) < 0 and 1 - (1 - oneSigmaWgt) will give the
1490  // correct weighting of just oneSigmaWgt if sigShift = 1. If oneSigmaWgt < 1 then the returned
1491  // expression still does the correct thing.
1492 
1493  return 1. - (1. - oneSigmaWgt) * sigShift;
1494  }
cmf::DetType_t detector
Definition: Structs.h:114
float CalibSystRatio(std::string const &systName, cmf::MetaData const &currentMD, double energy)
DataVarVals const & DataVals() const
Definition: Event.h:79
double const CurrentParameterValue(std::string const &parName)
float val_at(uint8_t const &varkey, cmf::MetaData const &md) const
Definition: VarVals.cxx:173
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
double cmf::ShifterAndWeighter::COHScale2018Weight ( std::string const &  wgtType,
cmf::InteractionType_t const &  intType 
)
private

Definition at line 1497 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, fCurrentMD, cmf::ParameterUtility::Instance(), cmf::MetaData::interactionType, simb::kCCCOH, simb::kCoh, cmf::kNC, simb::kNCCOH, cmf::kTrueIntMode, LOG_DEBUG, cmf::Event::MCVals(), cmf::ParameterUtility::ParameterInfo(), sigma(), cmf::Parameter::Sigma(), cmf::MCVarVals::val_at(), and ana::weight.

Referenced by InitShiftsAndWeightsForDetector().

1499  {
1500  // if event isn't coherent return 1
1504 
1505  // check that we have the right interaction type for this weight
1506  if((wgtType.find("NC") == std::string::npos && fCurrentMD.interactionType == cmf::kNC) ||
1507  (wgtType.find("CC") != std::string::npos && fCurrentMD.interactionType == cmf::kNC) ) return 1.;
1508 
1509  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo(wgtType).Sigma();
1510 
1511  auto parVal = this->CurrentParameterValue(wgtType);
1512 
1513  double weight = 1. + sigma * parVal;
1514 
1515  LOG_DEBUG("COHCCScale")
1516  << wgtType
1517  << weight;
1518 
1519  if(weight >= 0.) return weight;
1520  else return 0.;
1521  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
cmf::Parameter const & ParameterInfo(std::string const &parName)
MCVarVals const & MCVals() const
Definition: Event.h:80
const Var weight
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
charged current coherent pion
Definition: MCNeutrino.h:139
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
cmf::InteractionType_t interactionType
Definition: Structs.h:117
double cmf::ShifterAndWeighter::CosmicMuNormWeight ( )
private

Definition at line 1524 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::MetaData::detector, fCurrentEvent, fCurrentMD, cmf::ParameterUtility::Instance(), cmf::kCosmicMuon, cmf::kNEARDET, cmf::kTrueIntType, cmf::Event::MCVals(), cmf::ParameterUtility::ParameterInfo(), sigma(), cmf::Parameter::Sigma(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1525  {
1526  // cosmic muon normalization is only for the far detector
1527  if(fCurrentMD.detector == cmf::kNEARDET) return 1.;
1528 
1529  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("CosmicMuNormWgt").Sigma();
1531  return 1. + sigma * this->CurrentParameterValue("CosmicMuNormWgt");
1532  }
1533 
1534  return 1.0;
1535  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
MCVarVals const & MCVals() const
Definition: Event.h:80
cmf::DetType_t detector
Definition: Structs.h:114
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::CosmicOverlayNormWeight ( )
private

Definition at line 1538 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::ParameterUtility::Instance(), cmf::kCosmicMuon, cmf::kTrueIntType, cmf::kUnknownInteraction, cmf::Event::MCVals(), cmf::ParameterUtility::ParameterInfo(), sigma(), cmf::Parameter::Sigma(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1539  {
1542  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("CosmicOverlayNormWgt").Sigma();
1543 
1544  return 1. + sigma * this->CurrentParameterValue("CosmicOverlayNormWgt");
1545  }
1546 
1547  return 1.0;
1548  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
MCVarVals const & MCVals() const
Definition: Event.h:80
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double const cmf::ShifterAndWeighter::CurrentParameterValue ( std::string const &  parName)
inlineprivate

Definition at line 237 of file ShifterAndWeighter.h.

References cmf::kNEARDET.

Referenced by AbsNormWeight(), BeamSystWeight(), BirksNormWeight(), CalibSystWeight(), COHScale2018Weight(), CosmicMuNormWeight(), CosmicOverlayNormWeight(), DISvnCC1piWeight(), FluxPCAWeight(), GeniePCASystWeight(), GENIESystWeight(), HornNormWeight(), MaCCQEReducedWeight(), MECEnuShapeWeight(), MECInitStateNPFracWeight(), MECNormWeight(), MECShapeWeight(), NCNormWeight(), NoiseFarNormWeight(), NueAcceptBkg2018Weight(), NueAcceptSignalKin2018Weight(), NueFDRockMuonWeight(), RadCorrNueBarWeight(), RadCorrNueWeight(), RelNormWeight(), RockNormOnFidWeight(), RPACCQEshapeEnhWeight(), RPACCQEshapeSuppWeight(), RPACCQEWeight(), RPARESWeight(), SecondClassCurrWeight(), SetCurrentEvent(), ShiftForParameter(), SumSmallXSec2017Weight(), and TauScaleSystWeight().

238 {
239  return (fCurrentMD.detector == cmf::kNEARDET) ? fCurrentLoc.NDLocation().find(parName)->second.Value() : fCurrentLoc.FDLocation().find(parName)->second.Value();
240 }
cmf::Location fCurrentLoc
the current point in parameter space
cmf::DetType_t detector
Definition: Structs.h:114
cmf::ParameterSpaceLoc const & NDLocation() const
Definition: Parameter.h:158
cmf::ParameterSpaceLoc const & FDLocation() const
Definition: Parameter.h:159
cmf::MetaData fCurrentMD
the metadata for the current event
double cmf::ShifterAndWeighter::DISvnCC1piWeight ( )
private

Definition at line 1551 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::kDISvnCC1pi_Weight, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1552  {
1553  auto parVal = this->CurrentParameterValue("DISvnCC1piWgt");
1554  if(parVal > 0) return 1. + parVal * (1 - fCurrentEvent->MCVals().val_at(cmf::kDISvnCC1pi_Weight));
1555 
1556  return 1.;
1557  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
void cmf::ShifterAndWeighter::FillShifterInfo ( std::string const &  name,
cmf::DetType_t const &  det 
)
private

Definition at line 805 of file ShifterAndWeighter.cxx.

References fShiftersToUseFD, fShiftersToUseND, cmf::kFARDET, cmf::kHad_RecoE, cmf::kLep_RecoE, cmf::kNEARDET, cmf::kNu_RecoE, and ParseFluxesFile::param.

Referenced by InitShiftsAndWeightsForDetector().

807  {
808  uint8_t param;
809  if (name.find("HadE") != std::string::npos) param = cmf::kHad_RecoE;
810  else if(name.find("LepE") != std::string::npos) param = cmf::kLep_RecoE;
811  else if(name.find("NuE" ) != std::string::npos) param = cmf::kNu_RecoE;
812 
813  if (det == cmf::kNEARDET) fShiftersToUseND.emplace(name, param);
814  else if(det == cmf::kFARDET ) fShiftersToUseFD.emplace(name, param);
815  }
const XML_Char * name
Definition: expat.h:151
std::map< std::string, uint8_t > fShiftersToUseFD
std::map< std::string, uint8_t > fShiftersToUseND
double cmf::ShifterAndWeighter::FluxPCAWeight ( size_t  index)
private

Definition at line 1560 of file ShifterAndWeighter.cxx.

References cmf::MetaData::BeamType(), CalcLinearInterpWgt(), CurrentParameterValue(), cmf::MetaData::detector, fCurrentEvent, fCurrentMD, genie::utils::style::Format(), fVecFluxPrincipals, allTimeWatchdog::index, cmf::kTrueE, cmf::kTruePDGOrig, LOG_DEBUG, cmf::Event::MCVals(), string, and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1561  {
1562  if(index > fVecFluxPrincipals.size() ) return 1;
1563 
1564  /*if(fCurrentMD.BeamType() == cmf::kUnknownBeam &&
1565  fCurrentEvent->eventId) {
1566  if(fCurrentEvent->eventId->run)
1567  LOG_VERBATIM("SJB") << "UNKNOWN BEAM!"
1568  << "Current run: "
1569  << fCurrentEvent->eventId->run;
1570  else
1571  LOG_VERBATIM("SJB") << "Can't find run information! What!";
1572 
1573  }*/
1574 
1575  auto wgtBySigma = fVecFluxPrincipals[index].CalcBeamSystWeights(fCurrentMD.detector,
1576  fCurrentMD.BeamType(),
1577  fCurrentEvent->MCVals().val_at(cmf::kTrueE), //True Energy
1579 
1580 
1581 // for(auto const& itr : wgtBySigma)
1582 // LOG_DEBUG("ShifterAndWeighter")
1583 // << "flux weights for PCA "
1584 // << index
1585 // << " "
1586 // << fCurrentEvent->MCVals().val_at(cmf::kTrueE)
1587 // << " "
1588 // << itr.first
1589 // << " : "
1590 // << itr.second;
1591 
1592  std::string systname;
1593  std::string PCIdxStr = TString::Format("%01d", (int)index).Data();
1594  systname="FluxPCA"+PCIdxStr+"Wgt";
1595 
1596  LOG_DEBUG("ShifterAndWeighter")
1597  << "flux PCA weight for "
1598  << systname
1599  << " and "
1600  << this->CurrentParameterValue(systname)
1601  << " sigma is "
1602  << this->CalcLinearInterpWgt(this->CurrentParameterValue(systname),
1603  wgtBySigma);
1604  return this->CalcLinearInterpWgt(this->CurrentParameterValue(systname),
1605  wgtBySigma);
1606  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
cmf::DetType_t detector
Definition: Structs.h:114
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
std::vector< BeamSyst > fVecFluxPrincipals
This is each of the Flux PCA weights.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
cmf::BeamType_t BeamType() const
Definition: Structs.cxx:178
enum BeamMode string
float cmf::ShifterAndWeighter::FractionalShift ( uint8_t const &  param)

Definition at line 927 of file ShifterAndWeighter.cxx.

References cmf::MetaData::detector, fCurrentLoc, fCurrentMD, cmf::Location::FDLocation(), fShiftersToUseFD, fShiftersToUseND, cmf::kNEARDET, cmf::Location::NDLocation(), ParseFluxesFile::param, and ShiftForParameter().

Referenced by cmf::FillSpectrumFromSingleList().

928  {
929  return (fCurrentMD.detector == cmf::kNEARDET) ?
931  }
cmf::Location fCurrentLoc
the current point in parameter space
float ShiftForParameter(std::map< std::string, uint8_t > const &shifterMap, cmf::ParameterSpaceLoc const &loc, uint8_t const &param)
cmf::DetType_t detector
Definition: Structs.h:114
std::map< std::string, uint8_t > fShiftersToUseFD
std::map< std::string, uint8_t > fShiftersToUseND
cmf::ParameterSpaceLoc const & NDLocation() const
Definition: Parameter.h:158
cmf::ParameterSpaceLoc const & FDLocation() const
Definition: Parameter.h:159
cmf::MetaData fCurrentMD
the metadata for the current event
double cmf::ShifterAndWeighter::GeniePCASystWeight ( size_t  index)
private

Definition at line 1609 of file ShifterAndWeighter.cxx.

References CalcLinearInterpWgt(), CurrentParameterValue(), cmf::Event::DataVals(), energy, fCurrentEvent, fCurrentMD, genie::utils::style::Format(), fVecGeniePCASysts, allTimeWatchdog::index, cmf::kNu_RecoE, cmf::kTrueIntMode, cmf::Event::MCVals(), submit_nova_art::mode, string, cmf::MCVarVals::val_at(), and cmf::DataVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1610  {
1613 
1614  auto wgtBySigma = fVecGeniePCASysts[index].CalcGeniePCASystWeights(fCurrentMD, mode, energy);
1615 
1616  std::string systName;
1617  std::string PCIdxStr = TString::Format("%01d", (int)index).Data();
1618  systName = "GeniePCA" + PCIdxStr + "Wgt";
1619 
1620  return this->CalcLinearInterpWgt(this->CurrentParameterValue(systName),
1621  wgtBySigma);
1622  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
DataVarVals const & DataVals() const
Definition: Event.h:79
double energy
Definition: plottest35.C:25
double const CurrentParameterValue(std::string const &parName)
float val_at(uint8_t const &varkey, cmf::MetaData const &md) const
Definition: VarVals.cxx:173
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
std::vector< GeniePCASyst > fVecGeniePCASysts
This is each of the Genie PCA weights.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
enum BeamMode string
double cmf::ShifterAndWeighter::GENIESystWeight ( std::string const &  systName)
private

Definition at line 1625 of file ShifterAndWeighter.cxx.

References CalcLinearInterpWgt(), CurrentParameterValue(), fCurrentEvent, fCurrentMD, cmf::MetaData::interactionType, cmf::kCosmicMuon, cmf::kNC, cmf::Event::MCVals(), cmf::MCVarVals::SystVarWgts(), and cmf::VarNameToKey().

Referenced by InitShiftsAndWeightsForDetector(), and SumSmallXSec2017Weight().

1626  {
1627  // return 1 if this is a cosmic muon
1628  if(fCurrentMD.interactionType == cmf::kCosmicMuon) return 1.;
1629 
1630  // if this weight has NC or CC in the name and this interaction type
1631  // is not that, return 1
1632  if((systName.find("CC") != std::string::npos && fCurrentMD.interactionType == cmf::kNC) ||
1633  (systName.find("NC") == std::string::npos && fCurrentMD.interactionType == cmf::kNC) ) return 1.;
1634 
1635  // may need to come up with default for cosmic muons, however I think the fact that
1636  // the default weights for every GENIE variable is a collection of 1's should
1637  // mean this is OK
1638  std::map<float, float> wgtBySigma = fCurrentEvent->MCVals().SystVarWgts(cmf::VarNameToKey(systName.substr(0, systName.size() - 3)));
1639 
1640  // for(auto itr : wgtBySigma)
1641  //LOG_VERBATIM("GENIESystWeight")
1642  //<< systName
1643  //<< " weights "
1644  //<< itr.first
1645  //<< " "
1646  //<< itr.second;
1647 
1648  return this->CalcLinearInterpWgt(this->CurrentParameterValue(systName),
1649  wgtBySigma);
1650  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
std::map< float, float > SystVarWgts(uint8_t const &varkey) const
Definition: VarVals.cxx:53
static uint8_t VarNameToKey(std::string const &name)
Definition: StaticFuncs.h:385
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
cmf::InteractionType_t interactionType
Definition: Structs.h:117
double cmf::ShifterAndWeighter::HornNormWeight ( std::string const &  wgtType,
cmf::BeamType_t const &  beam 
)
private

Definition at line 1724 of file ShifterAndWeighter.cxx.

References POTSpillRate::beam, cmf::MetaData::BeamType(), CurrentParameterValue(), fCurrentMD, cmf::ParameterUtility::Instance(), LOG_DEBUG, cmf::ParameterUtility::ParameterInfo(), sigma(), and cmf::Parameter::Sigma().

Referenced by InitShiftsAndWeightsForDetector().

1726  {
1727  // check the beam type is correct for the current event
1728  if(beam != fCurrentMD.BeamType() ) return 1.;
1729 
1730  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo(wgtType).Sigma();
1731 
1732  LOG_DEBUG("HornNormWeight")
1733  << " Sigma Value "
1734  << sigma
1735  << " beam type "
1736  << beam;
1737 
1738  return 1. + sigma * this->CurrentParameterValue(wgtType);
1739  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
cmf::Parameter const & ParameterInfo(std::string const &parName)
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::MetaData fCurrentMD
the metadata for the current event
cmf::BeamType_t BeamType() const
Definition: Structs.cxx:178
void cmf::ShifterAndWeighter::InitShiftsAndWeightsForDetector ( cmf::DetType_t const &  det,
cmf::ParameterSpaceLoc const &  detLoc,
std::string const &  calibFileName,
std::vector< WeighterInfo > &  weighters,
std::map< std::string, uint8_t > &  shifters 
)
private

Definition at line 549 of file ShifterAndWeighter.cxx.

References AbsNormWeight(), BeamSystWeight(), BirksNormWeight(), CalibSystWeight(), cmf::cDetType_Strings, COHScale2018Weight(), CosmicMuNormWeight(), CosmicOverlayNormWeight(), fillBadChanDBTables::det, runNovaSAM::detId, DISvnCC1piWeight(), FillShifterInfo(), FluxPCAWeight(), fWeightType, GeniePCASystWeight(), GENIESystWeight(), HornNormWeight(), cmf::kFARDET, cmf::kFHC, cmf::kNC, cmf::kNEARDET, cmf::kNuESelection, cmf::kNuMuCC, cmf::kNuMuSelection, cmf::kRHC, LoadBeamSystHists2017(), LoadCalibrationSystRatios(), LoadFluxBeamSystHists(), LoadGeniePCASystHists(), LOG_DEBUG, LOG_WARNING, MaCCQEReducedWeight(), MECEnuShapeWeight(), MECInitStateNPFracWeight(), MECNormWeight(), MECShapeWeight(), NCNormWeight(), NoiseFarNormWeight(), NueAcceptBkg2018Weight(), NueAcceptSignalKin2018Weight(), NueFDRockMuonWeight(), num, RadCorrNueBarWeight(), RadCorrNueWeight(), RelNormWeight(), RockNormOnFidWeight(), RPACCQEshapeEnhWeight(), RPACCQEshapeSuppWeight(), RPACCQEWeight(), RPARESWeight(), SecondClassCurrWeight(), string, SumSmallXSec2017Weight(), TauScaleSystWeight(), cmf::ShifterAndWeighter::WeighterInfo::wgtFn, cmf::ShifterAndWeighter::WeighterInfo::wgtName, and XSecCVPPFXWeight().

Referenced by InitShiftsAndWeightsToUse().

554  {
555  // loop over the systematic parameters from the input point and evaluate the
556  // name associated with each one, then add the appropriate function to the
557  // list.
558  weighters.clear();
559  shifters .clear();
560 
561  std::string systName;
562  WeighterInfo weighter;
563  for(auto const& itr : detLoc){
564  if(itr.second.IsOscPar()) continue;
565  systName = itr.first;
566 
567  if(systName.find("Wgt") != std::string::npos){
568  weighter.wgtName = systName;
569 
570  // check all the systematic parameter names and add the necessary functions
571  // for weighting if there is a function for that name.
572  if (systName.find("AbsNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::AbsNormWeight, this, systName, cmf::kNuMuSelection);
573  else if(systName.find("BirksNearSyst" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::BirksNormWeight, this, systName, cmf::kNEARDET);
574  else if(systName.find("BirksFarSyst" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::BirksNormWeight, this, systName, cmf::kFARDET );
575  else if(systName.find("CosmicMuNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::CosmicMuNormWeight, this);
576  else if(systName.find("CosmicOverlayNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::CosmicOverlayNormWeight, this);
577  else if(systName.find("CCQEPauliSupViaKF" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
578  else if(systName.find("COHCCScale2018" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::COHScale2018Weight, this, systName, cmf::kNuMuCC);
579  else if(systName.find("COHNCScale2018" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::COHScale2018Weight, this, systName, cmf::kNC);
580  else if(systName.find("DISvnCC1pi" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::DISvnCC1piWeight, this);
581  else if(systName.find("FHCNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::HornNormWeight, this, systName, cmf::kFHC );
582  else if(systName.find("FormZone" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
583  else if(systName.find("FrInel_pi" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
584  else if(systName.find("FrCEx_N" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
585  else if(systName.find("FrElas_N" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
586  else if(systName.find("FrAbs_N" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
587  else if(systName.find("MaCCQEReduced" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MaCCQEReducedWeight, this);
588  else if(systName.find("MaCCQE_shape" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
589  else if(systName.find("MaCCRES" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
590  else if(systName.find("MaNCRES" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
591  else if(systName.find("MaNCEL" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
592  else if(systName.find("MECShapeNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECShapeWeight, this, false);
593  else if(systName.find("MECShapeAntiNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECShapeWeight, this, true );
594  else if(systName.find("MECInitNPFracNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECInitStateNPFracWeight, this, false);
595  else if(systName.find("MECInitNPFracAntiNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECInitStateNPFracWeight, this, true );
596  else if(systName.find("MECEnuShapeNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECEnuShapeWeight, this, false);
597  else if(systName.find("MECEnuShapeAntiNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECEnuShapeWeight, this, true );
598  else if(systName.find("MECNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::MECNormWeight, this);
599  else if(systName.find("MFP_N" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
600  else if(systName.find("MvCCRES" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
601  else if(systName.find("MvNCRES" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
602  else if(systName.find("NCNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NCNormWeight, this);
603  else if(systName.find("NoiseFarSyst" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NoiseFarNormWeight, this);
604  else if(systName.find("NormCCQE" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
605  else if(systName.find("NueAbsNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::AbsNormWeight, this, systName, cmf::kNuESelection );
606  else if(systName.find("NueAcceptSignalKin2018FHC") != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NueAcceptSignalKin2018Weight, this, cmf::kFHC);
607  else if(systName.find("NueAcceptSignalKin2018RHC") != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NueAcceptSignalKin2018Weight, this, cmf::kRHC);
608  else if(systName.find("NueAcceptBkg2018FHC" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NueAcceptBkg2018Weight, this, cmf::kFHC);
609  else if(systName.find("NueAcceptBkg2018RHC" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NueAcceptBkg2018Weight, this, cmf::kRHC);
610  else if(systName.find("NueRelNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RelNormWeight, this, systName, cmf::kNuESelection );
611  else if(systName.find("NueFDRockMuon" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::NueFDRockMuonWeight, this);
612  else if(systName.find("OtherGENIE" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
613  else if(systName.find("RadCorrNue" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RadCorrNueWeight, this);
614  else if(systName.find("RadCorrNueBar" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RadCorrNueBarWeight, this);
615  else if(systName.find("RelNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RelNormWeight, this, systName, cmf::kNuMuSelection);
616  else if(systName.find("RHCNorm" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::HornNormWeight, this, systName, cmf::kRHC );
617  else if(systName.find("RockNormOnFid" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RockNormOnFidWeight, this);
618  else if(systName.find("RPACCQE" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RPACCQEWeight, this);
619  else if(systName.find("RPARES" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RPARESWeight, this);
620  else if(systName.find("RPACCQEshapeEnh" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RPACCQEshapeEnhWeight, this);
621  else if(systName.find("RPACCQEshapeSupp" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::RPACCQEshapeSuppWeight, this);
622  else if(systName.find("SecondClassCurr" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::SecondClassCurrWeight, this);
623  else if(systName.find("SumSmallXSecNumu2017" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::SumSmallXSec2017Weight, this, systName, cmf::kNuMuSelection);
624  else if(systName.find("SumSmallXSecNue2017" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::SumSmallXSec2017Weight, this, systName, cmf::kNuESelection);
625  else if(systName.find("XsecCV" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::XSecCVPPFXWeight, this);
626  else if(systName.find("TauScaleSyst" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::TauScaleSystWeight, this);
627  else if(systName.find("BeamSyst") != std::string::npos){
628  auto detId = (systName.find("Far") != std::string::npos) ? cmf::kFARDET : cmf::kNEARDET;
629  weighter.wgtFn = std::bind(&ShifterAndWeighter::BeamSystWeight, this, systName, detId);
630  if(systName.find("2017") != std::string::npos) this->LoadBeamSystHists2017();
631  }
632  else if(systName.find("Calibration") != std::string::npos ||
633  systName.find("lightmodel") != std::string::npos ||
634  systName.find("ckv") != std::string::npos ){
635  weighter.wgtFn = std::bind(&ShifterAndWeighter::CalibSystWeight, this, systName);
636  this->LoadCalibrationSystRatios(calibFileName);
637  }
638  else if(systName.find("FluxPCA") != std::string::npos){
639  auto num = std::stol(systName.substr(7,1).c_str(), nullptr, 0);
640  weighter.wgtFn = std::bind(&ShifterAndWeighter::FluxPCAWeight, this, num);
641  this->LoadFluxBeamSystHists();
642  }
643 #ifdef PRODUCTION5
644  // 2020
645  else if (systName.find("ZExpAxialFFSyst2020_eV1" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
646  else if (systName.find("ZExpAxialFFSyst2020_eV2" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
647  else if (systName.find("ZExpAxialFFSyst2020_eV3" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
648  else if (systName.find("ZExpAxialFFSyst2020_eV4" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
649  else if (systName.find("ZNormCCQE" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
650  else if (systName.find("RESLowQ2SuppSyst2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
651  else if (systName.find("DISvnCC1piWgt_2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
652  else if (systName.find("hNFSISyst2020_MFP" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
653  else if (systName.find("hNFSISyst2020_EV1" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
654  else if (systName.find("MECEnuShapeSyst2020Nu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
655  else if (systName.find("MECEnuShapeSyst2020AntiNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
656  else if (systName.find("MECShapeSyst2020Nu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
657  else if (systName.find("MECShapeSyst2020AntiNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
658  else if (systName.find("MECInitStateNPFracSyst2020Nu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
659  else if (systName.find("MECInitStateNPFracSyst2020AntiNu" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
660  else if (systName.find("RadCorrNue" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
661  else if (systName.find("RadCorrNuebar" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
662  else if (systName.find("2ndClassCurrs" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
663  else if (systName.find("GENIEPCA0" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
664  else if (systName.find("GENIEPCA1" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
665  else if (systName.find("GENIEPCA2" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
666  else if (systName.find("GENIEPCA3" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
667  else if (systName.find("GENIEPCA4" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
668  else if (systName.find("GENIEPCA5" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
669  else if (systName.find("GENIEPCA6" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
670  else if (systName.find("GENIEPCA7" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
671  else if (systName.find("GENIEPCA8" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
672  else if (systName.find("GENIEPCA9" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
673  else if (systName.find("GENIEPCA10" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
674  else if (systName.find("GENIEPCA11" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
675  else if (systName.find("UnCorrNDMuEScaleSyst2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
676  else if (systName.find("UnCorrMuCatMuESyst2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
677  else if (systName.find("PileupMuESyst2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
678  else if (systName.find("CorrMuEScaleSyst2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
679  else if (systName.find("NeutronVisEScalePrimariesSyst2018") != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
680  else if (systName.find("MichelTaggingSyst2020" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
681  else if (systName.find("Ana2020NormFHC" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
682  else if (systName.find("Ana2020NormRHC" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
683  else if (systName.find("TauScaleSyst" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
684  else if (systName.find("Norm_1Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
685  else if (systName.find("MeanQ0_1Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
686  else if (systName.find("MeanQ3_1Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
687  else if (systName.find("SigmaQ0_1Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
688  else if (systName.find("SigmaQ3_1Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
689  else if (systName.find("Corr_1Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
690  else if (systName.find("Norm_2Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
691  else if (systName.find("MeanQ0_2Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
692  else if (systName.find("MeanQ3_2Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
693  else if (systName.find("SigmaQ0_2Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
694  else if (systName.find("SigmaQ3_2Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
695  else if (systName.find("Corr_2Nux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
696  else if (systName.find("BaselineNux" ) != std::string::npos) weighter.wgtFn = std::bind(&ShifterAndWeighter::GENIESystWeight, this, systName);
697 
698 #else
699  else if(systName.find("GeniePCA") != std::string::npos){
700  auto num = std::stol(systName.substr(8,1).c_str(), nullptr, 0);
701  weighter.wgtFn = std::bind(&ShifterAndWeighter::GeniePCASystWeight, this, num);
702  this->LoadGeniePCASystHists();
703  }
704 #endif
705  else{
706  LOG_WARNING("ShifterAndWeighter")
707  << "Unable to determine weighting function for "
708  << systName;
709  continue;
710  }
711  LOG_DEBUG("ShifterAndWeighter")
712  << "Adding weighter "
713  << weighter.wgtName
714  << " to detector "
716  << "\nthe current weight type is"
717  << fWeightType;
718 
719  weighters.push_back(weighter);
720 
721  } // the parameter was for a weight
722  else if(systName.find("Shifter") != std::string::npos){
723 
724  LOG_DEBUG("ShifterAndWeighter")
725  << "Adding shifter for "
726  << systName
727  << " to detector "
728  << det;
729 
730  this->FillShifterInfo(systName,
731  det);
732  } // end if this is a shifter
733  } // end loop over systematic parameters
734 
735  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
cmf::WeightType_t fWeightType
which type of weights to use - oscillation, systematic or both
double GeniePCASystWeight(size_t index)
void FillShifterInfo(std::string const &name, cmf::DetType_t const &det)
double COHScale2018Weight(std::string const &wgtType, cmf::InteractionType_t const &intType)
double MECInitStateNPFracWeight(bool anti)
double MECEnuShapeWeight(bool anti)
double FluxPCAWeight(size_t index)
double NueAcceptSignalKin2018Weight(cmf::BeamType_t const &beamType)
double BirksNormWeight(std::string const &wgtType, cmf::DetType_t const &det)
double AbsNormWeight(std::string const &wgtType, cmf::SelectionType_t const &sel)
double RelNormWeight(std::string const &wgtType, cmf::SelectionType_t const &sel)
double BeamSystWeight(std::string const &wgtType, cmf::DetType_t const &det)
#define LOG_WARNING(category)
double SumSmallXSec2017Weight(std::string const &wgtType, cmf::SelectionType_t const &selType)
double HornNormWeight(std::string const &wgtType, cmf::BeamType_t const &beam)
int num
Definition: f2_nu.C:119
double MECShapeWeight(bool anti)
const std::string cDetType_Strings[5]
Definition: Constants.h:592
void LoadCalibrationSystRatios(const std::string &CalibFilename)
double CalibSystWeight(std::string const &wgtType)
double NueAcceptBkg2018Weight(cmf::BeamType_t const &beamType)
double GENIESystWeight(std::string const &systName)
enum BeamMode string
void cmf::ShifterAndWeighter::InitShiftsAndWeightsToUse ( cmf::Location const &  loc,
fhicl::ParameterSet const &  parset 
)

Definition at line 738 of file ShifterAndWeighter.cxx.

References cmf::Location::FDLocation(), fShiftersToUseFD, fShiftersToUseND, fTrueEOscillationWeight, fWeightersToUseFD, fWeightersToUseND, fWeightType, fhicl::ParameterSet::get(), InitShiftsAndWeightsForDetector(), cmf::kFARDET, cmf::kNEARDET, cmf::kNSI, cmf::kOscWgtOnly, cmf::kPMNS, cmf::kSterile, cmf::kSystAndOscWgt, cmf::kSystWgtOnly, LOG_DEBUG, cmf::Location::NDLocation(), OscillationCalculatorToUse(), SetCurrentVals(), and string.

Referenced by cmf::CMFDecorrelator::CMFDecorrelator(), cmf::CovarianceMatrixFitter::FillDataSpectrum(), cmf::SpectrumPredictionMaker::Initialize(), cmf::CovarianceFitHelper::InitializeShifterAndWeighter(), cmf::CMFSpectraMaker::reconfigure(), cmf::CovarianceMatrixMaker::reconfigure(), and cmf::RandomUniverses::writeResults().

740  {
741  // this method sets which systematics are to be used in calculating weights
742  // by creating a set of std::functions corresponding to the weighting functions
743  // that are to be turned on
744  // the code is a bit tedious, but it gets the job done
745 
746  auto calibFileName = parset.get<std::string>("CalibSystFile", "CovarianceMatrixFit/data/calibration/CalibrationSystematics2019.root");
747  auto calcString = parset.get<std::string>("OscCalculatorType", "PMNS");
748  fTrueEOscillationWeight = parset.get<bool >("TrueEOscCalc", true);
749 
751  auto weightString = parset.get<std::string>("WeightType", "OscWeightsOnly");
752  if (weightString == "SystAndOscWeights") fWeightType = cmf::kSystAndOscWgt;
753  else if(weightString == "SystWeightsOnly" ) fWeightType = cmf::kSystWgtOnly;
754 
755  cmf::CalcType_t calcType = cmf::kPMNS;
756  if (calcString == "PMNS_NSI" ) calcType = cmf::kNSI;
757  else if(calcString == "PMNS_Sterile") calcType = cmf::kSterile;
758 
759  // setup the oscillation calculator to use
760  this->OscillationCalculatorToUse(calcType);
761 
762  // go ahead and set the current values
763  this->SetCurrentVals(loc);
764 
766  loc.NDLocation(),
767  calibFileName,
771  loc.FDLocation(),
772  calibFileName,
775 
776 // for(auto const& itr : fShiftersToUseND){
777 // LOG_VERBATIM("ShifterAndWeighter")
778 // << "ND shifter param: "
779 // << itr.first;
780 // for(auto const& si : itr.second)
781 // LOG_VERBATIM("ShifterAndWeighter")
782 // << " associated shifter "
783 // << si.fShifterName
784 // << " "
785 // << si.fDetector;
786 // }
787 // for(auto const& itr : fShiftersToUseFD){
788 // LOG_VERBATIM("ShifterAndWeighter")
789 // << "FD shifter param: "
790 // << itr.first;
791 // for(auto const& si : itr.second)
792 // LOG_VERBATIM("ShifterAndWeighter")
793 // << " associated shifter "
794 // << si.fShifterName
795 // << " "
796 // << si.fDetector;
797 // }
798 
799  LOG_DEBUG("ShifterAndWeighter")
800  << "Done initialising shifters and weighters";
801 
802  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
void OscillationCalculatorToUse(cmf::CalcType_t calcType)
cmf::WeightType_t fWeightType
which type of weights to use - oscillation, systematic or both
void InitShiftsAndWeightsForDetector(cmf::DetType_t const &det, cmf::ParameterSpaceLoc const &detLoc, std::string const &calibFileName, std::vector< WeighterInfo > &weighters, std::map< std::string, uint8_t > &shifters)
std::map< std::string, uint8_t > fShiftersToUseFD
std::map< std::string, uint8_t > fShiftersToUseND
std::vector< WeighterInfo > fWeightersToUseND
std::vector< WeighterInfo > fWeightersToUseFD
bool fTrueEOscillationWeight
flag to calculate the oscillation weight at the true E_nu vs bin center
enum cmf::calc_type CalcType_t
void SetCurrentVals(cmf::Location const &loc)
enum BeamMode string
ShifterAndWeighter * cmf::ShifterAndWeighter::Instance ( )
static
void cmf::ShifterAndWeighter::LoadBeamSystHists2017 ( )
private

Definition at line 1277 of file ShifterAndWeighter.cxx.

References fBeamSyst2017, cmf::BeamSyst::fBeamSystHists, plotROC::fileName, cet::search_path::find_file(), cmf::BeamSyst::LoadBeamSystHists(), cmf::BeamSyst::SetFileAndHistNames(), galleryMaker::shortName, and string.

Referenced by InitShiftsAndWeightsForDetector().

1278  {
1279  // Someone already called us
1280  if(!fBeamSyst2017.fBeamSystHists.empty()) return;
1281 
1283 
1284  // TODO: make this a tunable parameter
1285  std::string shortName("enuMF_FHC_totErr");
1286 
1287  // constructor decides if initialized value is a path or an environment variable
1288  cet::search_path sp("FW_SEARCH_PATH");
1289  if ( !sp.find_file(std::string("CAFAna/data/beam/TABeamSyst.root"), fileName) ) {
1290  throw cet::exception("BeamSystFileError")
1291  << "cannot find Beam Systematics file CAFAna/data/beam/TABeamSyst.root "
1292  << fileName
1293  << " bail ungracefully\n"
1294  << "(RJN Guess: Did you run setup for this release?)\n"
1295  << __FILE__ << ":" << __LINE__;
1296  }
1297 
1300  }
fileName
Definition: plotROC.py:78
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::map< std::string, TH1D * > fBeamSystHists
void SetFileAndHistNames(std::string const &filename, std::string const &shortName)
string shortName
THUMBNAIL BLOCK: We need to make a thumbnail for each.
enum BeamMode string
void cmf::ShifterAndWeighter::LoadCalibrationSystRatios ( const std::string CalibFilename)
private

Definition at line 1366 of file ShifterAndWeighter.cxx.

References fCalibSyst, and cmf::CalibSyst::LoadCalibSystRatios().

Referenced by InitShiftsAndWeightsForDetector().

1367  {
1368  fCalibSyst.LoadCalibSystRatios(CalibFilename);
1369  }
void LoadCalibSystRatios(std::string const &CalibFilename)
void cmf::ShifterAndWeighter::LoadFluxBeamSystHists ( )
private

For now 5 is just an arbitrary number, should be configurable

Definition at line 1303 of file ShifterAndWeighter.cxx.

References cet::search_path::find_file(), genie::utils::style::Format(), fVecFluxPrincipals, allTimeWatchdog::index, LOG_DEBUG, and string.

Referenced by InitShiftsAndWeightsForDetector().

1304  {
1305  // Someone already called us
1306  if(!fVecFluxPrincipals.empty()) return;
1307 
1308  cet::search_path sp("FW_SEARCH_PATH");
1309 
1310  // the central value smooth PPFX weights appear to be no longer used
1311 // std::string fileNameCV;
1312 // std::string shortNameCV("ppfx_cv");
1313 //
1314 // // constructor decides if initialized value is a path or an environment variable
1315 // if ( !sp.find_file(std::string("CAFAna/data/beam/ppfx_smooth_multiverse_weights_2018.root"), fileNameCV) ) {
1316 // throw cet::exception("BeamSystFileError")
1317 // << "cannot find Beam Systematics file CAFAna/data/beam/ppfx_smooth_multiverse_weights_2018.root "
1318 // << fileNameCV
1319 // << " bail ungracefully\n"
1320 // << __FILE__ << ":" << __LINE__;
1321 // }
1322 //
1323 // fPPFXSmoothCVWgt.SetFileAndHistNames(fileNameCV,shortNameCV);
1324 // fPPFXSmoothCVWgt.LoadBeamSystHists();
1325 
1326  std::string fileNamePCA;
1327  std::string shortNamePCA;
1328  if ( !sp.find_file(std::string("CAFAna/data/beam/ppfx_hadp_beam_pc_shifts_fn_2018.root"), fileNamePCA) ) {
1329  throw cet::exception("BeamSystFileError")
1330  << "cannot find Beam Systematics file CAFAna/data/beam/ppfx_hadp_beam_pc_shifts_fn_2018.root "
1331  << fileNamePCA
1332  << " bail ungracefully\n"
1333  << __FILE__ << ":" << __LINE__;
1334  }
1335 
1336  for(int index = 0; index < 5; ++index){
1337  ///For now 5 is just an arbitrary number, should be configurable
1338  std::string PCIdxStr = TString::Format("%02d", index).Data();
1339  shortNamePCA="ppfx_hadp_beam_pc"+PCIdxStr;
1340 
1341  fVecFluxPrincipals.emplace_back(BeamSyst(fileNamePCA,shortNamePCA));
1342  fVecFluxPrincipals[index].LoadBeamSystHists();
1343 
1344  LOG_DEBUG("ShifterAndWeighter")
1345  << "setting up BeamSyst object for "
1346  << fileNamePCA
1347  << " "
1348  << shortNamePCA
1349  << " "
1350  << fVecFluxPrincipals.size();
1351  }
1352 
1353  //Can also add a similar loop for the univeses
1354  //will leave this commented out for now
1355  // std::string shortNameUniv;
1356  // for(int index=0;index<100;index++) {
1357  // std::string UniIdxStr = TString::Format("%02d", index).Data();
1358  // shortNameUniv="ppfx_univ"+UniIdxStr;
1359  // fVecPPFXUniverses.push_back(BeamSyst(fileNameCV,shortNameUniv));
1360  // }
1361 
1362 
1363  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::vector< BeamSyst > fVecFluxPrincipals
This is each of the Flux PCA weights.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
enum BeamMode string
void cmf::ShifterAndWeighter::LoadGeniePCASystHists ( )
private

Definition at line 1372 of file ShifterAndWeighter.cxx.

References genie::utils::style::Format(), fVecGeniePCASysts, allTimeWatchdog::index, galleryMaker::shortName, and string.

Referenced by InitShiftsAndWeightsForDetector().

1372  {
1373  // someone already called us
1374  if(!fVecGeniePCASysts.empty()) return;
1375 
1376  for(int index = 0; index < 5; ++index) {
1377  // 5 chosen arbitrarily, should probably make configurable at some point
1378  std::string PCIdxStr = TString::Format("%02d", index).Data();
1379  std::string shortName = "genie_small_pc"+PCIdxStr;
1380  fVecGeniePCASysts.emplace_back(GeniePCASyst());
1381 
1382  fVecGeniePCASysts[index].LoadGeniePCASystHists(shortName);
1383  }
1384 
1385  }
std::vector< GeniePCASyst > fVecGeniePCASysts
This is each of the Genie PCA weights.
string shortName
THUMBNAIL BLOCK: We need to make a thumbnail for each.
void Format(TGraph *gr, int lcol, int lsty, int lwid, int mcol, int msty, double msiz)
Definition: Style.cxx:154
enum BeamMode string
double cmf::ShifterAndWeighter::MaCCQEReducedWeight ( )
private

Definition at line 1742 of file ShifterAndWeighter.cxx.

References CalcLinearInterpWgt(), CurrentParameterValue(), fCurrentEvent, fCurrentMD, cmf::MetaData::interactionType, cmf::kCosmicMuon, cmf::kNC, cmf::Event::MCVals(), cmf::MCVarVals::SystVarWgts(), cmf::VarNameToKey(), and wgt.

Referenced by InitShiftsAndWeightsForDetector().

1743  {
1744  // it doesn't make sense to ask for a CC weight if the event is an NC
1745  // or cosmic muon
1748 
1749  auto parVal = this->CurrentParameterValue("MaCCQEReducedWgt");
1750  std::map<float, float> wgtBySigma = fCurrentEvent->MCVals().SystVarWgts(cmf::VarNameToKey("MaCCQE"));
1751 
1752  // mysterious 2018 correction factor (M_A^QE CV shift from 0.99 to 1.04)
1753  const double correctionInSigma = (1.04 - 0.99) / 0.25;
1754  double cv_weight = 1. + correctionInSigma * (wgtBySigma.at(1) - 1);
1755 
1756  double genie_sigma = (parVal > 0) ? parVal * (0.05 / 0.25) : parVal * (0.05 / 0.15);
1757 
1758  if( cv_weight > 0) {
1759  for(auto wgt : wgtBySigma) wgt.second /= cv_weight;
1760 
1761  double reduced_error = 0.05;
1762  double cv_ma = 1.04;
1763  double genie_ma = 0.99;
1764 
1765  double shifted_ma = cv_ma * ( 1 + parVal * reduced_error );
1766  double genie_frac_shift = ( shifted_ma - genie_ma ) / genie_ma;
1767  double genie_error = ( genie_frac_shift > 0 ) ? 0.25 : 0.15;
1768  genie_sigma = genie_frac_shift / genie_error;
1769  }
1770 
1771  return this->CalcLinearInterpWgt(genie_sigma, wgtBySigma);
1772  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
std::map< float, float > SystVarWgts(uint8_t const &varkey) const
Definition: VarVals.cxx:53
static uint8_t VarNameToKey(std::string const &name)
Definition: StaticFuncs.h:385
double const CurrentParameterValue(std::string const &parName)
const ana::Var wgt
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
cmf::InteractionType_t interactionType
Definition: Structs.h:117
double cmf::ShifterAndWeighter::MECEnuShapeWeight ( bool  anti)
private

Definition at line 1832 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::kEmpiricalMEC_Weight, cmf::kEmpiricalMECtoGENIEQE_Weight, cmf::kEmpiricalMECtoGENIERES_Weight, cmf::kTrueE, cmf::kTruePDG, LOG_DEBUG, cmf::Event::MCVals(), canMan::sign(), string, UseMECWeight(), cmf::MCVarVals::val_at(), and wgt.

Referenced by InitShiftsAndWeightsForDetector().

1833  {
1834  if( this->UseMECWeight(anti) ){
1835 
1836  LOG_DEBUG("ShifterAndWeighter")
1837  << "Found MEC event with "
1838  << " MEC weight " << fCurrentEvent->MCVals().val_at(cmf::kEmpiricalMEC_Weight)
1841  << " PDG " << fCurrentEvent->MCVals().val_at(cmf::kTruePDG);
1842 
1843  std::string sign;
1844  if(!anti) sign = "Nu";
1845  else sign = "AntiNu";
1846 
1847  auto parVal = this->CurrentParameterValue("MECEnuShape"+sign+"Wgt");
1848  double nuE = fCurrentEvent->MCVals().val_at(cmf::kTrueE);
1849  if(nuE < 0) return 1.0;
1850 
1851  // this function is the 1 sigma bound around central value weight 1
1852  static const TF1 rwgtFn("MECRwgtFn", "1/(2.5*x+1)");
1853  double wgt = 1 + parVal * rwgtFn.Eval(nuE);
1854 
1855  // no negative weights
1856  if(wgt < 0)
1857  wgt = 0;
1858 
1859  LOG_DEBUG("ShifterAndWeighter")
1860  << "\tMECEnuShapeWgt " << wgt
1861  << " (Enu = " << nuE
1862  << ", rwgtFn.Eval(nuE) = " << rwgtFn.Eval(nuE)
1863  << ", parval = " << parVal << ")";
1864  return wgt;
1865  }
1866 
1867  return 1.0;
1868  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
const ana::Var wgt
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
def sign(x)
Definition: canMan.py:197
enum BeamMode string
double cmf::ShifterAndWeighter::MECInitStateNPFracWeight ( bool  anti)
private

Definition at line 1871 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::kTrueHitNuc, LOG_DEBUG, cmf::Event::MCVals(), canMan::sign(), string, UseMECWeight(), cmf::MCVarVals::val_at(), and wgt.

Referenced by InitShiftsAndWeightsForDetector().

1872  {
1873  if( this->UseMECWeight(anti) ){
1874  std::string sign;
1875  if(!anti) sign = "Nu";
1876  else sign = "AntiNu";
1877 
1878  auto parVal = this->CurrentParameterValue("MECInitNPFrac"+sign+"Wgt");
1879  const double nominalNPfrac = 0.8; // see DocDB 18741
1880  double newNPfrac = nominalNPfrac + (0.1*parVal);
1881  double wgt;
1882 
1883  // only physical between 0 and 1
1884  if(newNPfrac > 1)
1885  newNPfrac = 1;
1886  else if(newNPfrac < 0)
1887  newNPfrac = 0;
1888 
1889  if(fCurrentEvent->MCVals().val_at(cmf::kTrueHitNuc) == 2000000201)
1890  wgt = newNPfrac / nominalNPfrac;
1891  else
1892  wgt = (1 - newNPfrac) / (1 - nominalNPfrac);
1893 
1894  LOG_DEBUG("ShifterAndWeighter")
1895  << "\tMECInitStateNPFracWgt " << wgt
1896  << " (nominalNPfrac = " << nominalNPfrac
1897  << ", newNPfrac = " << newNPfrac
1898  << ", parval = " << parVal << ")";
1899  return wgt;
1900  }
1901 
1902  return 1.0;
1903  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
const ana::Var wgt
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
def sign(x)
Definition: canMan.py:197
enum BeamMode string
double cmf::ShifterAndWeighter::MECNormWeight ( )
private

Definition at line 1906 of file ShifterAndWeighter.cxx.

References std::abs(), CurrentParameterValue(), fCurrentEvent, cmf::ParameterUtility::Instance(), cmf::kTrueIntType, cmf::Event::MCVals(), cmf::ParameterUtility::ParameterInfo(), sigma(), cmf::Parameter::Sigma(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1907  {
1908  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("MECNormWgt").Sigma();
1909 
1911  return 1. + sigma * this->CurrentParameterValue("MECNormWgt");
1912  }
1913 
1914  return 1.0;
1915  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
MCVarVals const & MCVals() const
Definition: Event.h:80
float abs(float number)
Definition: d0nt_math.hpp:39
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::MECShapeWeight ( bool  anti)
private

Definition at line 1785 of file ShifterAndWeighter.cxx.

References std::abs(), CurrentParameterValue(), fCurrentEvent, cmf::kEmpiricalMEC_Weight, cmf::kEmpiricalMECtoGENIEQE_Weight, cmf::kEmpiricalMECtoGENIERES_Weight, cmf::kTruePDG, LOG_DEBUG, cmf::Event::MCVals(), canMan::sign(), string, UseMECWeight(), cmf::MCVarVals::val_at(), and wgt.

Referenced by InitShiftsAndWeightsForDetector().

1786  {
1787  if( this->UseMECWeight(anti) ){
1788 
1789  std::string sign;
1790  if(!anti) sign = "Nu";
1791  else sign = "AntiNu";
1792 
1794  auto parVal = this->CurrentParameterValue("MECShape"+sign+"Wgt");
1795  double wgt = 1.;
1796 
1797  LOG_DEBUG("ShifterAndWeighter")
1798  << "Found MEC event with "
1799  << " \n-- EmpiricalMEC_Weight (nomWgt) : " << fCurrentEvent->MCVals().val_at(cmf::kEmpiricalMEC_Weight)
1800  << " \n-- EmpiricalMECtoGENIEQE_Weight : " << fCurrentEvent->MCVals().val_at(cmf::kEmpiricalMECtoGENIEQE_Weight)
1801  << " \n-- EmpiricalMECToGENIERES_Weight: " << fCurrentEvent->MCVals().val_at(cmf::kEmpiricalMECtoGENIERES_Weight)
1802  << " \n-- parVal for MECShape" << sign << "Wgt: " << parVal
1803  << " \n-- PDG : " << fCurrentEvent->MCVals().val_at(cmf::kTruePDG);
1804 
1805 
1806  auto wgtVar = (parVal < 0) ?
1809 
1810  if(nomWgt > 0)
1811  wgt = 1 + std::abs(parVal) * (wgtVar / nomWgt - 1);
1812 
1813  LOG_DEBUG("ShifterAndWeighter")
1814  << "wgt: " << wgt << " parVal: " << std::abs(parVal) << " wgtVar: " << wgtVar << " nomWgt: " << nomWgt;
1815 
1816  // don't allow negative weights
1817  if(wgt < 0)
1818  wgt = 0;
1819 
1820  // don't allow crazy weights
1821  if(wgt > 10)
1822  wgt = 10;
1823 
1824 
1825  return wgt;
1826  }
1827 
1828  return 1.0;
1829  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
float abs(float number)
Definition: d0nt_math.hpp:39
double const CurrentParameterValue(std::string const &parName)
const ana::Var wgt
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
def sign(x)
Definition: canMan.py:197
enum BeamMode string
double cmf::ShifterAndWeighter::NCNormWeight ( )
private

Definition at line 1918 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::ParameterUtility::Instance(), simb::kNC, cmf::kTrueCCNC, cmf::Event::MCVals(), cmf::ParameterUtility::ParameterInfo(), sigma(), cmf::Parameter::Sigma(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1919  {
1920  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("NCNormWgt").Sigma();
1922  return 1. + sigma * this->CurrentParameterValue("NCNormWgt");
1923 
1924  return 1.0;
1925  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
MCVarVals const & MCVals() const
Definition: Event.h:80
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::NoiseFarNormWeight ( )
private

Definition at line 1928 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::MetaData::detector, fCurrentMD, cmf::ParameterUtility::Instance(), cmf::kNEARDET, cmf::ParameterUtility::ParameterInfo(), sigma(), and cmf::Parameter::Sigma().

Referenced by InitShiftsAndWeightsForDetector().

1929  {
1930  // this one only applies to the far detector
1931  if(fCurrentMD.detector == cmf::kNEARDET) return 1.;
1932 
1933  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("NoiseFarSystWgt").Sigma();
1934 
1935  return 1. + sigma * this->CurrentParameterValue("NoiseFarSystWgt");
1936  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
cmf::DetType_t detector
Definition: Structs.h:114
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::MetaData fCurrentMD
the metadata for the current event
double cmf::ShifterAndWeighter::NueAcceptBkg2018Weight ( cmf::BeamType_t const &  beamType)
private

Definition at line 2047 of file ShifterAndWeighter.cxx.

References std::abs(), cmf::MetaData::BeamType(), CurrentParameterValue(), cmf::MetaData::detector, fCurrentEvent, fCurrentMD, simb::kCC, cmf::kFHC, cmf::kNEARDET, cmf::kNuESelection, cmf::kNuESelectionPeripheral, cmf::kTrueCCNC, cmf::kTruePDG, cmf::kTruePDGOrig, cmf::Event::MCVals(), cmf::MetaData::selectionType, and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2048  {
2049 
2050  //Only apply weight to FD, nue selected events
2054 
2055  //If this is the FHC systematic, only apply to FHC, and vice versa
2056  if(beamType != fCurrentMD.BeamType())
2057  return 1.;
2058 
2059  double FDBkgCorr = (beamType == cmf::kFHC) ? 0.015 : 0.041;
2061  FDBkgCorr = (beamType == cmf::kFHC) ? 0.012 : 0.023;
2062 
2063  //TODO: Check that it contains a true neutrino (CAF version is if(sr->mc.nnu return; )
2064 
2065  //Check if neutrino, but not numu->nue signal, otherwise left unaltered
2071  return 1;
2072 
2073  //Find number of sigma to shift by
2074  double parVal = 0;
2075  if(beamType == cmf::kFHC)
2076  parVal = this->CurrentParameterValue("NueAcceptBkg2018FHCWgt");
2077  else
2078  parVal = this->CurrentParameterValue("NueAcceptBkg2018RHCWgt");
2079 
2080  return 1 + FDBkgCorr * parVal;
2081 
2082  }
MCVarVals const & MCVals() const
Definition: Event.h:80
cmf::DetType_t detector
Definition: Structs.h:114
float abs(float number)
Definition: d0nt_math.hpp:39
cmf::SelectionType_t selectionType
Definition: Structs.h:116
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
cmf::BeamType_t BeamType() const
Definition: Structs.cxx:178
double cmf::ShifterAndWeighter::NueAcceptSignalKin2018Weight ( cmf::BeamType_t const &  beamType)
private

Definition at line 1940 of file ShifterAndWeighter.cxx.

References std::abs(), cmf::MetaData::BeamType(), cmf::cBeamType_Strings, plot_validation_datamc::Clone(), CurrentParameterValue(), cmf::Event::DataVals(), cmf::MetaData::detector, fCurrentEvent, fCurrentMD, plotROC::fileName, fin, cet::search_path::find_file(), fNueAcceptSignalKin2018FHCWgtHist, fNueAcceptSignalKin2018RHCWgtHist, cmf::MetaData::IsNuESelected(), simb::kCC, cmf::kFHC, cmf::kNEARDET, cmf::kNu_RecoE, cmf::kNuESelectionHighPID, cmf::kNuESelectionLowPID, cmf::kNuESelectionPeripheral, cmf::kRHC, cmf::kTrueCCNC, cmf::kTruePDG, cmf::kTruePDGOrig, LOG_DEBUG, LOG_WARNING, cmf::Event::MCVals(), cmf::MetaData::selectionType, galleryMaker::shortName, string, cmf::MCVarVals::val_at(), and cmf::DataVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

1941  {
1942  //Only apply weight to FD, nue selected events
1944  !fCurrentMD.IsNuESelected() ) return 1.;
1945 
1946  //If this is the FHC systematic, only apply to FHC, and vice versa
1947  if(beamType != fCurrentMD.BeamType())
1948  return 1.;
1949 
1950  // LOG_VERBATIM("ShifterAndWeighter")
1951  // << "NueAcceptSignalKin2018Weight time!";
1952 
1953  //TODO: Check that it contains a true neutrino (CAF version is if(sr->mc.nnu return; )
1954 
1955  //Check flavors and that it's CC
1959  return 1;
1960 
1961  // Grab the relevant histogram (if you haven't already): code stolen from LoadSABeamSystHists function,
1962  // I hope that's still a valid way to get histograms
1963  if((beamType == cmf::kFHC && !fNueAcceptSignalKin2018FHCWgtHist) ||
1964  (beamType == cmf::kRHC && !fNueAcceptSignalKin2018RHCWgtHist)){
1966  std::string shortName("Cos_FD_KinematicsCorrection_" + cmf::cBeamType_Strings[beamType]);
1967 
1968  // constructor decides if initialized value is a path or an environment variable
1969  cet::search_path sp("FW_SEARCH_PATH");
1970  if ( !sp.find_file(std::string("CAFAna/nue/Ana2018/AcceptSysts/FD_KinematicsCorrection_" + cmf::cBeamType_Strings[beamType] + ".root"), fileName) ) {
1971  throw cet::exception("NueExtrapSystFileError")
1972  << "cannot find Nue Extrap Systematics file CAFAna/nue/Ana2018/AcceptSysts/FD_KinematicsCorrection_"
1973  << cmf::cBeamType_Strings[beamType]
1974  << ".root "
1975  << fileName
1976  << " bail ungracefully\n"
1977  << "(RJN Guess: Did you run setup for this release?)\n"
1978  << __FILE__ << ":" << __LINE__;
1979  }
1980 
1981  TFile fin(fileName.c_str(), "read");
1982  if(fin.IsZombie()) {
1983  LOG_WARNING("ShifterAndWeighter")
1984  << "Warning: couldn't open nue extrapolation systematic file "
1985  << fileName;
1986  }
1987 
1988  if(beamType == cmf::kFHC){
1989  fNueAcceptSignalKin2018FHCWgtHist = (TH1*)fin.Get(shortName.c_str())->Clone();
1990  fNueAcceptSignalKin2018FHCWgtHist->SetDirectory(nullptr);
1991  }
1992  else{
1993  fNueAcceptSignalKin2018RHCWgtHist = (TH1*)fin.Get(shortName.c_str())->Clone();
1994  fNueAcceptSignalKin2018RHCWgtHist->SetDirectory(nullptr);
1995  }
1996 
1997  fin.Close();
1998  }
1999 
2000  // use the selection to find an offset to the energy to get value from the
2001  // histogram
2002  double selEOffset;
2004  selEOffset = 21.;
2006  selEOffset = 2.;
2008  selEOffset = 20.;
2009  else{
2010  selEOffset = -5;
2011  LOG_DEBUG("ShifterAndWeighter")
2012  << "Could not find selection type: " << fCurrentMD.selectionType;
2013  }
2014 
2015  // There are 6 energy bins for each selection type, each energy bin is 0.5 GeV wide, range
2016  // is 1 - 4 GeV in the FD
2018  LOG_DEBUG("ShifterAndWeighter")
2019  << "selBin = "
2020  << selEOffset
2021  << ", anaBin = "
2022  << anaBin;
2023 
2024  double FDSignalWeight = 1;
2025  if(beamType == cmf::kFHC && fNueAcceptSignalKin2018FHCWgtHist->GetBinContent(anaBin) != 0)
2026  FDSignalWeight = fNueAcceptSignalKin2018FHCWgtHist->GetBinContent(anaBin);
2027  else if(beamType == cmf::kRHC && fNueAcceptSignalKin2018RHCWgtHist->GetBinContent(anaBin) != 0)
2028  FDSignalWeight = fNueAcceptSignalKin2018RHCWgtHist->GetBinContent(anaBin);
2029 
2030  //Find number of sigma to shift by
2031  double parVal = 0;
2032  if(beamType == cmf::kFHC)
2033  parVal = this->CurrentParameterValue("NueAcceptSignalKin2018FHCWgt");
2034  else
2035  parVal = this->CurrentParameterValue("NueAcceptSignalKin2018RHCWgt");
2036 
2037  LOG_DEBUG("ShifterAndWeighter")
2038  << "return weight "
2039  << 1 + (FDSignalWeight - 1) * parVal;
2040 
2041  return 1 + (FDSignalWeight - 1) * parVal;
2042 
2043  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
TString fin
Definition: Style.C:24
MCVarVals const & MCVals() const
Definition: Event.h:80
fileName
Definition: plotROC.py:78
cmf::DetType_t detector
Definition: Structs.h:114
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
float abs(float number)
Definition: d0nt_math.hpp:39
cmf::SelectionType_t selectionType
Definition: Structs.h:116
DataVarVals const & DataVals() const
Definition: Event.h:79
double const CurrentParameterValue(std::string const &parName)
float val_at(uint8_t const &varkey, cmf::MetaData const &md) const
Definition: VarVals.cxx:173
#define LOG_WARNING(category)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
string shortName
THUMBNAIL BLOCK: We need to make a thumbnail for each.
cmf::BeamType_t BeamType() const
Definition: Structs.cxx:178
const std::string cBeamType_Strings[4]
Definition: Constants.h:35
bool IsNuESelected() const
Definition: Structs.cxx:225
enum BeamMode string
double cmf::ShifterAndWeighter::NueFDRockMuonWeight ( )
private

Definition at line 2087 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::MetaData::detector, fCurrentMD, cmf::MetaData::fileType, cmf::kFARDET, cmf::kRockFluxSwap, and cmf::kRockNonSwap.

Referenced by InitShiftsAndWeightsForDetector().

2088  {
2091  fCurrentMD.fileType != cmf::kRockFluxSwap )) return 1.;
2092 
2093  double parVal = this->CurrentParameterValue("NueFDRockMuonWgt");
2094 
2095  // the maximum effect is a 100% uncertainty - we can't go below
2096  // a weight of 0, but we could go above a weight of 2
2097  if(parVal < -1.) parVal = -1.;
2098 
2099  return 1. + parVal;
2100  }
cmf::DetType_t detector
Definition: Structs.h:114
double const CurrentParameterValue(std::string const &parName)
cmf::FileType_t fileType
Definition: Structs.h:115
cmf::MetaData fCurrentMD
the metadata for the current event
void cmf::ShifterAndWeighter::OscillationCalculatorToUse ( cmf::CalcType_t  calcType)

Definition at line 1085 of file ShifterAndWeighter.cxx.

References fCalcType, fOscCalc, cmf::kNSI, cmf::kPMNS, cmf::kSterile, and LOG_WARNING.

Referenced by InitShiftsAndWeightsToUse().

1086  {
1087  // nothing to change
1088  if(fOscCalc != nullptr && fCalcType == calcType) return;
1089  else{
1090  LOG_WARNING("ShifterAndWeighter")
1091  << "resetting oscillation calculator to type "
1092  << calcType
1093  << " from "
1094  << fCalcType
1095  << " are you sure you meant to change types in this job?";
1096 
1097  delete fOscCalc;
1098  fOscCalc = nullptr;
1099  }
1100 
1101  fCalcType = calcType;
1102 
1104  else if(fCalcType == cmf::kNSI ) fOscCalc = new osc::OscCalcPMNS_NSI();
1105  else if(fCalcType == cmf::kSterile){
1106  fOscCalc = new osc::OscCalcSterile();
1107  dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetNFlavors(4);
1108  }
1109  }
Optimized version of OscCalcPMNS.
Adapt the PMNS_Sterile calculator to standard interface.
A re-optimized version of OscCalcPMNSOpt.
#define LOG_WARNING(category)
cmf::CalcType_t fCalcType
type of oscillation calculator
osc::IOscCalcAdjustable * fOscCalc
the oscillation calculator
double cmf::ShifterAndWeighter::OscillationWeight ( )
private

Definition at line 1112 of file ShifterAndWeighter.cxx.

References cmf::MetaData::detector, fCalcType, fCurrentMD, fTrueEOscillationWeight, cmf::kNEARDET, cmf::kPMNS, OscillationWeightBinCenter(), and OscillationWeightTrueE().

Referenced by Weight().

1113  {
1114  // don't bother doing anything if we are looking at the near detector
1115  // and standard oscillations, it is just a waste of time.
1116  if(fCalcType == cmf::kPMNS &&
1117  fCurrentMD.detector == cmf::kNEARDET) return 1.;
1118 
1120 
1121  return this->OscillationWeightBinCenter();
1122  }
cmf::DetType_t detector
Definition: Structs.h:114
cmf::CalcType_t fCalcType
type of oscillation calculator
cmf::MetaData fCurrentMD
the metadata for the current event
bool fTrueEOscillationWeight
flag to calculate the oscillation weight at the true E_nu vs bin center
double cmf::ShifterAndWeighter::OscillationWeightBinCenter ( )
private

Definition at line 1140 of file ShifterAndWeighter.cxx.

References genie::units::A, std::abs(), E, fCurrentEvent, fOscCalc, fTrueEnergyBins, MECModelEnuComparisons::i, cmf::kTrueE, cmf::kTruePDG, cmf::kTruePDGOrig, LOG_DEBUG, cmf::Event::MCVals(), osc::_IOscCalc< T >::P(), make_root_from_grid_output::pdg, and cmf::MCVarVals::val_at().

Referenced by OscillationWeight().

1141  {
1142  if(fTrueEnergyBins.empty()){
1143  const int numTrueEnergyBins = 100;
1144 
1145  // How many edges to generate. Allow room for 0-Emin bin
1146  const double N = numTrueEnergyBins-1;
1147  const double A = N * 0.5; // 500 MeV: there's really no events below there
1148 
1149  fTrueEnergyBins.insert(0);
1150  for(int i = 1; i < N - 1; ++i) fTrueEnergyBins.insert(A/i);
1151  fTrueEnergyBins.insert(120.);
1152  }
1153 
1154  double E = fCurrentEvent->MCVals().val_at(cmf::kTrueE);
1156  int pdgOrig = fCurrentEvent->MCVals().val_at(cmf::kTruePDGOrig);
1157 
1158  // get the relevant bin for the current neutrino, then get the
1159  // energy at the center of that bin
1160  double eUpper = *(fTrueEnergyBins.rbegin());
1161  double eLower = *(fTrueEnergyBins.begin());
1162 
1163  // find the bin edge that goes after the value of E
1164  auto itr = fTrueEnergyBins.upper_bound(E);
1165  if(itr != fTrueEnergyBins.end()) eUpper = *itr;
1166  else --itr;
1167 
1168  // now find the edge before by just decrementing the iterator
1169  --itr;
1170  if(itr != fTrueEnergyBins.end()) eLower = *itr;
1171 
1172  // get the midpoint between the upper and lower values,
1173  // ie take their mean
1174  E = 0.5 * (eUpper + eLower);
1175 
1176  LOG_DEBUG("ShifterAndWeighter")
1177  << "true energy: "
1179  << " central bin energy "
1180  << E;
1181 
1182  // only attempt to weight neutrinos for oscillations
1183  if(std::abs(pdg) != 12 &&
1184  std::abs(pdg) != 14 &&
1185  std::abs(pdg) != 16) return 1.;
1186 
1187  return fOscCalc->P(pdgOrig, pdg, E);
1188 
1189  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
std::set< double > fTrueEnergyBins
the true energy binning used by CAF
float abs(float number)
Definition: d0nt_math.hpp:39
Float_t E
Definition: plot.C:20
virtual T P(int flavBefore, int flavAfter, double E)=0
E in GeV; flavors as PDG codes (so, neg==>antinu)
cmf::Event * fCurrentEvent
the current event to weight/shift
static const double A
Definition: Units.h:82
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
osc::IOscCalcAdjustable * fOscCalc
the oscillation calculator
double cmf::ShifterAndWeighter::OscillationWeightTrueE ( )
private

Definition at line 1124 of file ShifterAndWeighter.cxx.

References std::abs(), E, fCurrentEvent, fOscCalc, cmf::kTrueE, cmf::kTruePDG, cmf::kTruePDGOrig, cmf::Event::MCVals(), osc::_IOscCalc< T >::P(), make_root_from_grid_output::pdg, and cmf::MCVarVals::val_at().

Referenced by OscillationWeight().

1125  {
1126  double E = fCurrentEvent->MCVals().val_at(cmf::kTrueE);
1128  int pdgOrig = fCurrentEvent->MCVals().val_at(cmf::kTruePDGOrig);
1129 
1130  // only attempt to weight neutrinos for oscillations
1131  if(std::abs(pdg) != 12 &&
1132  std::abs(pdg) != 14 &&
1133  std::abs(pdg) != 16) return 1.;
1134 
1135  return fOscCalc->P(pdgOrig, pdg, E);
1136 
1137  }
MCVarVals const & MCVals() const
Definition: Event.h:80
float abs(float number)
Definition: d0nt_math.hpp:39
Float_t E
Definition: plot.C:20
virtual T P(int flavBefore, int flavAfter, double E)=0
E in GeV; flavors as PDG codes (so, neg==>antinu)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
osc::IOscCalcAdjustable * fOscCalc
the oscillation calculator
double cmf::ShifterAndWeighter::RadCorrNueBarWeight ( )
private

Definition at line 2114 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, simb::kCC, cmf::kTrueCCNC, cmf::kTruePDG, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2115  {
2116  double parVal = this->CurrentParameterValue("RadCorrNueBarWgt");
2117 
2120  return 1.0 + 0.02 * parVal;
2121  else return 1.0;
2122  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::RadCorrNueWeight ( )
private

Definition at line 2103 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, simb::kCC, cmf::kTrueCCNC, cmf::kTruePDG, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2104  {
2105  double parVal = this->CurrentParameterValue("RadCorrNueWgt");
2106 
2109  return 1.0 + 0.02 * parVal;
2110  else return 1.0;
2111  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::RelNormWeight ( std::string const &  wgtType,
cmf::SelectionType_t const &  sel 
)
private

Definition at line 2125 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::MetaData::detector, fCurrentMD, cmf::ParameterUtility::Instance(), cmf::MetaData::IsNCSelected(), cmf::MetaData::IsNuESelected(), cmf::MetaData::IsNuMuSelected(), cmf::kNCSelection, cmf::kNEARDET, cmf::kNuESelection, cmf::kNuMuSelection, cmf::ParameterUtility::ParameterInfo(), sigma(), and cmf::Parameter::Sigma().

Referenced by InitShiftsAndWeightsForDetector().

2127  {
2128  // relative normalization is only for the far detector
2129  if(fCurrentMD.detector == cmf::kNEARDET) return 1.;
2130 
2131  // sel is one of the generic selection types, kNCSelection, kNuMuSelection or kNuESelection
2132  bool wantNue = (sel == cmf::kNuESelection ) && (wgtType.find("Nue") != std::string::npos);
2133  bool wantNumu = (sel == cmf::kNuMuSelection) && (wgtType.find("NuMu") != std::string::npos);
2134  bool wantNC = (sel == cmf::kNCSelection) && (wgtType.find("NC") != std::string::npos);
2135 
2136  // check for the correct selection for the current event with this function
2137  // return 1 if we have a numu selected event but want the nue relative normalization
2138  // or if we have a nue selected event but want the numu relative normalization
2139  if (fCurrentMD.IsNuMuSelected() && !wantNumu) return 1.;
2140  else if(fCurrentMD.IsNuESelected() && !wantNue ) return 1.;
2141  else if(fCurrentMD.IsNCSelected() && !wantNC ) return 1.;
2142 
2143  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo(wgtType).Sigma();
2144 
2145  return 1. + sigma * this->CurrentParameterValue(wgtType);
2146  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
cmf::DetType_t detector
Definition: Structs.h:114
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
bool IsNuMuSelected() const
Definition: Structs.cxx:219
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::MetaData fCurrentMD
the metadata for the current event
bool IsNuESelected() const
Definition: Structs.cxx:225
bool IsNCSelected() const
Definition: Structs.cxx:231
void cmf::ShifterAndWeighter::ReportCurrentVals ( )

Definition at line 818 of file ShifterAndWeighter.cxx.

References fCurrentLoc, and LOG_VERBATIM.

Referenced by cmf::CMFSpectraMaker::endJob().

819  {
820  LOG_VERBATIM("ShifterAndWeighter")
821  << "Current shifter/weighter point:\n"
822  << fCurrentLoc;
823  }
cmf::Location fCurrentLoc
the current point in parameter space
#define LOG_VERBATIM(category)
double cmf::ShifterAndWeighter::RockNormOnFidWeight ( )
private

Definition at line 2221 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::MetaData::detector, fCurrentMD, cmf::ParameterUtility::Instance(), cmf::kFARDET, cmf::ParameterUtility::ParameterInfo(), sigma(), and cmf::Parameter::Sigma().

Referenced by InitShiftsAndWeightsForDetector().

2222  {
2223  // rock muon normalization is only for the near detector
2224  if(fCurrentMD.detector == cmf::kFARDET) return 1.;
2225 
2226  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("RockNormOnFidWgt").Sigma();
2227 
2228  return 1. + sigma * this->CurrentParameterValue("RockNormOnFidWgt");
2229  }
cmf::Parameter const & ParameterInfo(std::string const &parName)
cmf::DetType_t detector
Definition: Structs.h:114
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::MetaData fCurrentMD
the metadata for the current event
double cmf::ShifterAndWeighter::RPACCQEshapeEnhWeight ( )
private

Definition at line 2158 of file ShifterAndWeighter.cxx.

References CalcLinearInterpWgt(), CurrentParameterValue(), fCurrentEvent, fCurrentMD, cmf::MetaData::interactionType, cmf::kCosmicMuon, cmf::kNC, cmf::kRPACCQE_Weight, cmf::Event::MCVals(), cmf::MCVarVals::SystVarWgts(), cmf::MCVarVals::val_at(), and cmf::VarNameToKey().

Referenced by InitShiftsAndWeightsForDetector().

2159  {
2162 
2163  std::map<float, float> wgtBySigma = fCurrentEvent->MCVals().SystVarWgts(cmf::VarNameToKey("RPACCQEshapeEnh"));
2164 
2165 
2166  auto initWgt = this->CalcLinearInterpWgt(this->CurrentParameterValue("RPACCQEshapeEnhWgt"),
2167  wgtBySigma);
2168  // if(initWgt < 0.01){
2169  // std::string wgtStr("Check initial RPACCQEshapeEnhMap ");
2170  // for(auto const& itr : wgtBySigma) wgtStr += std::to_string(itr.first) + " " + std::to_string(itr.second) + " ";
2171 
2172  // LOG_VERBATIM("SAWRPACCQEshapeEnhWeight")
2173  // << wgtStr;
2174 
2175  // wgtStr = "SAWRPACCQEshapeEnhWeight " + std::to_string(this->CurrentParameterValue("RPACCQEshapeEnhWgt"));
2176  // wgtStr += " " + std::to_string(initWgt) + " ";
2177  // for(auto const& itr : wgtBySigma) wgtStr += std::to_string(itr.first) + " " + std::to_string(itr.second) + " ";
2178 
2179  // LOG_VERBATIM("SAWRPACCQEshapeEnhWeight")
2180  // << wgtStr;
2181  // }
2182 
2183  // problem: for the SA, it was safe to assume that a 0sigma shift meant a weight of 1
2184  // BUT in A2017, the central value for RPACCQESupp/EnhWeights is the value of RPACCQEWeight
2185  return initWgt * fCurrentEvent->MCVals().val_at(cmf::kRPACCQE_Weight);
2186  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
std::map< float, float > SystVarWgts(uint8_t const &varkey) const
Definition: VarVals.cxx:53
static uint8_t VarNameToKey(std::string const &name)
Definition: StaticFuncs.h:385
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
cmf::InteractionType_t interactionType
Definition: Structs.h:117
double cmf::ShifterAndWeighter::RPACCQEshapeSuppWeight ( )
private

Definition at line 2198 of file ShifterAndWeighter.cxx.

References CalcLinearInterpWgt(), CurrentParameterValue(), fCurrentEvent, fCurrentMD, cmf::MetaData::interactionType, cmf::kCosmicMuon, cmf::kNC, cmf::kRPACCQE_Weight, cmf::Event::MCVals(), cmf::MCVarVals::SystVarWgts(), cmf::MCVarVals::val_at(), cmf::VarNameToKey(), and wgt.

Referenced by InitShiftsAndWeightsForDetector().

2199  {
2202 
2203  std::map<float, float> wgtBySigma = fCurrentEvent->MCVals().SystVarWgts(cmf::VarNameToKey("RPACCQEshapeSupp"));
2204 
2205  double wgt = this->CalcLinearInterpWgt(this->CurrentParameterValue("RPACCQEshapeSuppWgt"),
2206  wgtBySigma);
2207 
2208  //See comment in RPACCQEshapeEnhWeight()
2210 
2211  // LOG_VERBATIM("ShifterAndWeighter")
2212  // << "RPACCQEshapeSuppWeight = " << wgt
2213  // << ", from (" << wgtBySigma.at(-1.)
2214  // << ", " << wgtBySigma.at( 0.)
2215  // << ", " << wgtBySigma.at( 1.)
2216  // << ")";
2217  return wgt;
2218  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double CalcLinearInterpWgt(double sigma, std::map< float, float > const &wgtsBySigma)
std::map< float, float > SystVarWgts(uint8_t const &varkey) const
Definition: VarVals.cxx:53
static uint8_t VarNameToKey(std::string const &name)
Definition: StaticFuncs.h:385
double const CurrentParameterValue(std::string const &parName)
const ana::Var wgt
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
cmf::InteractionType_t interactionType
Definition: Structs.h:117
double cmf::ShifterAndWeighter::RPACCQEWeight ( )
private

Definition at line 2189 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::kRPACCQE_Weight, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2190  {
2191  auto parVal = this->CurrentParameterValue("RPACCQEWgt");
2192  if(parVal > 0) return 1. + parVal * (1 - fCurrentEvent->MCVals().val_at(cmf::kRPACCQE_Weight));
2193 
2194  return 1.;
2195  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::RPARESWeight ( )
private

Definition at line 2149 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, cmf::kRPARES_Weight, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2150  {
2151  auto parVal = this->CurrentParameterValue("RPARESWgt");
2152  if(parVal > 0) return 1. + parVal * (1 - fCurrentEvent->MCVals().val_at(cmf::kRPARES_Weight));
2153 
2154  return 1.;
2155  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::SecondClassCurrWeight ( )
private

Definition at line 2256 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), fCurrentEvent, simb::kCC, cmf::kTrueCCNC, cmf::kTruePDG, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2257  {
2258  double parVal = this->CurrentParameterValue("SecondClassCurrWgt");
2259 
2262  return 1.0 + 0.02 * parVal;
2263  else if(fCurrentEvent->MCVals().val_at(cmf::kTrueCCNC) == 1. * simb::kCC &&
2265  return 1.0 - 0.02 * parVal;
2266  else return 1.0;
2267  }
MCVarVals const & MCVals() const
Definition: Event.h:80
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
void cmf::ShifterAndWeighter::SetCurrentEvent ( cmf::EventPtr const &  curEvent,
cmf::MetaData const &  md 
)
private

Definition at line 900 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::Event::DataValsFilled(), fCurrentEvent, fCurrentMD, fOscCalc, cmf::MetaData::isMC, LOG_DEBUG, cmf::Event::MCValsFilled(), fetch_tb_beamline_files::md, osc::_IOscCalcAdjustable< T >::SetL(), and cmf::MetaData::ToString().

Referenced by Weight().

902  {
903  fCurrentEvent = curEvent.get();
904  fCurrentMD = md;
905 
906  LOG_DEBUG("SetCurrentEvent")
907  << " Metadata is "
908  << md.ToString();
909 
910  // check the validity of the mcVals before trying to get weights, if it is
911  // a nullptr, we have a problem.
912  if( !fCurrentEvent->MCValsFilled() && md.isMC)
913  throw cet::exception("ShifterAndWeighter")
914  << "Event does not have a valid MCVarVals unique_ptr, bail";
915 
916  // the data values better always be valid
917  if( !fCurrentEvent->DataValsFilled() )
918  throw cet::exception("ShifterAndWeighter")
919  << "Event does not have a valid DataVarVals unique_ptr, bail";
920 
921  // reset the oscillation baseline based on the detector
922  fOscCalc->SetL(this->CurrentParameterValue("L"));
923 
924  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
virtual void SetL(double L)=0
bool MCValsFilled() const
Definition: Event.h:73
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
double const CurrentParameterValue(std::string const &parName)
bool DataValsFilled() const
Definition: Event.h:72
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
osc::IOscCalcAdjustable * fOscCalc
the oscillation calculator
void cmf::ShifterAndWeighter::SetCurrentVals ( cmf::Location const &  loc)
void cmf::ShifterAndWeighter::SetCurrentVals ( std::vector< std::string > const &  pars,
const double *  vals 
)

Definition at line 841 of file ShifterAndWeighter.cxx.

References fCurrentLoc, cmf::kFARDET, cmf::kNEARDET, SetOscillationVals(), and cmf::Location::SetParameterValue().

843  {
844 
845  for(size_t pv = 0; pv < pars.size(); ++pv){
848  }
849  //this->ReportCurrentVals();
850 
851  this->SetOscillationVals();
852  }
cmf::Location fCurrentLoc
the current point in parameter space
std::string pars("Th23Dmsq32")
void SetParameterValue(std::string const &parName, double const &value, cmf::DetType_t const &det)
Definition: Parameter.cxx:220
void cmf::ShifterAndWeighter::SetOscillationVals ( )

Definition at line 855 of file ShifterAndWeighter.cxx.

References fCalcType, fCurrentLoc, cmf::Location::FDLocation(), fOscCalc, cmf::kNSI, cmf::kPMNS, cmf::kSterile, osc::_IOscCalcAdjustable< T >::SetdCP(), osc::_IOscCalcAdjustable< T >::SetDmsq21(), osc::_IOscCalcAdjustable< T >::SetDmsq32(), osc::_IOscCalcAdjustable< T >::SetL(), osc::_IOscCalcAdjustable< T >::SetRho(), novaddt::SetRho(), osc::_IOscCalcAdjustable< T >::SetTh12(), osc::_IOscCalcAdjustable< T >::SetTh13(), and osc::_IOscCalcAdjustable< T >::SetTh23().

Referenced by SetCurrentVals().

856  {
857  // get the oscillation parameters from the current point, we haven't set
858  // the detector yet, but the only thing that changes is the
859  // baseline which we change with the SetCurrentEvent method
860  for(auto const& itr : fCurrentLoc.FDLocation()){
861 
863  if (itr.first == "L" ) fOscCalc->SetL (itr.second.Value());
864  else if(itr.first == "Rho" ) fOscCalc->SetRho (itr.second.Value());
865  else if(itr.first == "Dmsq21") fOscCalc->SetDmsq21(itr.second.Value());
866  else if(itr.first == "Dmsq32") fOscCalc->SetDmsq32(itr.second.Value());
867  else if(itr.first == "Th12" ) fOscCalc->SetTh12 (itr.second.Value());
868  else if(itr.first == "Th13" ) fOscCalc->SetTh13 (itr.second.Value());
869  else if(itr.first == "Th23" ) fOscCalc->SetTh23 (itr.second.Value());
870  else if(itr.first == "dCP" ) fOscCalc->SetdCP (itr.second.Value());
871  if(fCalcType == cmf::kNSI){
872  //Eps = NSI epsilon parameters
873  if (itr.first == "Eps_ee" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetEps_ee (itr.second.Value());
874  else if(itr.first == "Eps_emu" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetEps_emu (itr.second.Value());
875  else if(itr.first == "Eps_etau" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetEps_etau (itr.second.Value());
876  else if(itr.first == "Eps_mumu" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetEps_mumu (itr.second.Value());
877  else if(itr.first == "Eps_mutau" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetEps_mutau (itr.second.Value());
878  else if(itr.first == "Eps_tautau" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetEps_tautau (itr.second.Value());
879  else if(itr.first == "Delta_emu" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetDelta_emu (itr.second.Value());
880  else if(itr.first == "Delta_etau" ) dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetDelta_etau (itr.second.Value());
881  else if(itr.first == "Delta_mutau") dynamic_cast<osc::OscCalcPMNS_NSI*>(fOscCalc)->SetDelta_mutau(itr.second.Value());
882  } // end if NSI oscillations
883  } // end if PMNS or NSI oscillations
884  else if(fCalcType == cmf::kSterile){
885  if (itr.first == "Th12" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetAngle(1, 2, itr.second.Value());
886  else if(itr.first == "Th23" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetAngle(2, 3, itr.second.Value());
887  else if(itr.first == "Th24" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetAngle(2, 4, itr.second.Value());
888  else if(itr.first == "Th34" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetAngle(3, 4, itr.second.Value());
889  else if(itr.first == "dCP" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetDelta(1, 3, itr.second.Value());
890  else if(itr.first == "Dmsq21") dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetDm (2, itr.second.Value());
891  else if(itr.first == "Dmsq32") dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetDm (3, itr.second.Value());
892  else if(itr.first == "Dmsq41") dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetDm (4, itr.second.Value());
893  else if(itr.first == "L" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetL ( itr.second.Value());
894  else if(itr.first == "Rho" ) dynamic_cast<osc::OscCalcSterile*>(fOscCalc)->SetRho ( itr.second.Value());
895  } // end if sterile oscillations
896  } // end loop over FD location
897  }
Optimized version of OscCalcPMNS.
virtual void SetL(double L)=0
cmf::Location fCurrentLoc
the current point in parameter space
virtual void SetDmsq21(const T &dmsq21)=0
virtual void SetTh13(const T &th13)=0
Adapt the PMNS_Sterile calculator to standard interface.
virtual void SetDmsq32(const T &dmsq32)=0
cmf::ParameterSpaceLoc const & FDLocation() const
Definition: Parameter.h:159
void SetRho(const float &r)
Definition: HoughPeak.h:94
virtual void SetRho(double rho)=0
cmf::CalcType_t fCalcType
type of oscillation calculator
virtual void SetTh23(const T &th23)=0
osc::IOscCalcAdjustable * fOscCalc
the oscillation calculator
virtual void SetTh12(const T &th12)=0
virtual void SetdCP(const T &dCP)=0
float cmf::ShifterAndWeighter::ShiftForParameter ( std::map< std::string, uint8_t > const &  shifterMap,
cmf::ParameterSpaceLoc const &  loc,
uint8_t const &  param 
)
private

Definition at line 934 of file ShifterAndWeighter.cxx.

References CurrentParameterValue(), cmf::Event::DataVals(), cmf::MetaData::detector, fCurrentEvent, fCurrentMD, fNDMuonCatcherEShiftMinus, fNDMuonCatcherEShiftPlus, cmf::kLep_RecoE, cmf::kLep_RecoE_MCFrac, cmf::kNEARDET, sigma(), and cmf::DataVarVals::val_at().

Referenced by FractionalShift().

937  {
938 
939  float totalShift = 1.;
940  float shiftScale;
941  float curShift;
942 
943  for(auto const& itr : shifterMap){
944 
945  if(itr.second != param) continue;
946 
947  auto const& sigma = loc.find(itr.first)->second.Sigma();
948 
949  curShift = this->CurrentParameterValue(itr.first);
950 
951  if(itr.first.find("MuonCatcherEShifter") != std::string::npos &&
953  // The plan is to determine how much of the energy is contained in the
954  // ND muon catcher and then scale that amount by the product of the
955  // number of sigma and the shift in the scale due to a 10.5 cm shift in
956  // the muon catcher pathlength The shift in pathlength is accounted as a
957  // shift in muon catcher energy from range.
958  // find the sigma for the muon catcher from the TF1s first, then multiply that
959  // by the fraction of the total energy that is in the muon catcher
960  //
961  // For the near detector if we are using relative energy shifts
962  // we want to shift things down by 1/2 sigma
964  shiftScale *= curShift;
965  shiftScale *= (curShift > 0.) ? fNDMuonCatcherEShiftPlus->Eval(fCurrentEvent->DataVals().val_at(cmf::kLep_RecoE, fCurrentMD))
967  shiftScale += 1.;
968  }
969  else if(itr.first.find("RelRecoLepEShifter") != std::string::npos){
970  // if this shifter is the relative leptonic one, set the scale
971  // to be 0.5 in the FD and -0.5 in the ND, ie the FD is shifted up by
972  // 1/2 sigma and the ND is shifted down by 1/2 sigma
973  shiftScale = sigma * curShift;
974  shiftScale *= (fCurrentMD.detector == cmf::kNEARDET) ? -0.5 : 0.5;
975  shiftScale += 1.;
976  }
977  else
978  shiftScale = 1. + sigma * curShift;
979 
980  // LOG_VERBATIM("ShifterAndWeighterTotalShift")
981  // << " associated shifter "
982  // << infoItr.fShifterName
983  // << " "
984  // << infoItr.fDetector
985  // << " "
986  // << fCurrentMD.detector
987  // << " "
988  // << sigma
989  // << " "
990  // << this->CurrentParameterValue(infoItr.fShifterName)
991  // << " "
992  // << totalShift;
993  totalShift *= shiftScale;
994  }
995 
996  return totalShift;
997  }
cmf::DetType_t detector
Definition: Structs.h:114
std::unique_ptr< TF1 > fNDMuonCatcherEShiftMinus
negative shift in the muon catcher energy
DataVarVals const & DataVals() const
Definition: Event.h:79
double const CurrentParameterValue(std::string const &parName)
float val_at(uint8_t const &varkey, cmf::MetaData const &md) const
Definition: VarVals.cxx:173
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
std::unique_ptr< TF1 > fNDMuonCatcherEShiftPlus
positive shift in the muon catcher energy
double cmf::ShifterAndWeighter::SumSmallXSec2017Weight ( std::string const &  wgtType,
cmf::SelectionType_t const &  selType 
)
private

Definition at line 2270 of file ShifterAndWeighter.cxx.

References abs(), CurrentParameterValue(), fCurrentEvent, GENIESystWeight(), simb::kCC, cmf::kNuMuSelection, cmf::kOtherDIS_Weight, cmf::kTrueCCNC, cmf::kTruePDG, LOG_DEBUG, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2272  {
2273  //This should ALWAYS be correlated with:
2274  // RPACCQEshapeSuppWeight
2275  // MECInitStateNPFrac
2276  // MECEnuShape
2277 
2278  double tempwgt = 1.;
2279  double parVal = this->CurrentParameterValue(wgtType);
2280 
2281  //All the GENIE style wgts
2282  tempwgt *= this->GENIESystWeight(wgtType);
2283  LOG_DEBUG("ShifterAndWeighter")
2284  << "SumSmallXSec: with GENIE wgts "
2285  << tempwgt;
2286 
2287  //DIS
2288  tempwgt *= 1. + parVal * (1 - fCurrentEvent->MCVals().val_at(cmf::kOtherDIS_Weight));
2289 
2290  // if(fCurrentEvent->MCVals().val_at(cmf::kOtherDIS_Weight) != 1.)
2291  // LOG_VERBATIM("ShifterAndWeighter")
2292  // << "\twith OtherDIS wgts "
2293  // << tempwgt;
2294 
2295  if(selType == cmf::kNuMuSelection){
2296  //RadCorrNue and RadCorrNueBar
2297  //There should be a NuE version of this weight WITHOUT these systematics.
2298  //For joint analyses, USE THE NUE VERSION OF THE SUMSMALLXSEC WEIGHT
2301  tempwgt *= 1 + 0.02 * parVal;
2302  //SimpleSecondClassCurrentsSecSyst
2303  if(fCurrentEvent->MCVals().val_at(cmf::kTruePDG) == 12) tempwgt *= 1 + 0.02 * parVal;
2304  if(fCurrentEvent->MCVals().val_at(cmf::kTruePDG) == -12) tempwgt *= 1 - 0.02 * parVal;
2305  LOG_DEBUG("ShifterAndWeighter")
2306  << "\twith RadCorr wgts "
2307  << tempwgt;
2308  }
2309  } // end if numu selection
2310 
2311  return tempwgt;
2312  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
void abs(TH1 *hist)
double const CurrentParameterValue(std::string const &parName)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double GENIESystWeight(std::string const &systName)
double cmf::ShifterAndWeighter::TauScaleSystWeight ( )
private

Definition at line 2232 of file ShifterAndWeighter.cxx.

References std::abs(), CurrentParameterValue(), fCurrentEvent, cmf::ParameterUtility::Instance(), simb::kCC, cmf::kTrueCCNC, cmf::kTruePDG, std::max(), cmf::Event::MCVals(), cmf::ParameterUtility::ParameterInfo(), sigma(), cmf::Parameter::Sigma(), cmf::MCVarVals::val_at(), and ana::weight.

Referenced by InitShiftsAndWeightsForDetector().

2233  {
2234  auto const& sigma = cmf::ParameterUtility::Instance()->ParameterInfo("TauScaleSystWgt").Sigma();
2235 
2238 
2239  double weight = 1. + sigma * this->CurrentParameterValue("TauScaleSystWgt");
2240 
2241  return std::max(0., weight);
2242  }
2243 
2244  return 1.0;
2245  }
T max(const caf::Proxy< T > &a, T b)
cmf::Parameter const & ParameterInfo(std::string const &parName)
MCVarVals const & MCVals() const
Definition: Event.h:80
const Var weight
float abs(float number)
Definition: d0nt_math.hpp:39
static ParameterUtility * Instance()
float const & Sigma() const
Definition: Parameter.h:105
double const CurrentParameterValue(std::string const &parName)
double sigma(TH1F *hist, double percentile)
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::TotalWeightFromWeighters ( )
private

Definition at line 1062 of file ShifterAndWeighter.cxx.

References cmf::MetaData::detector, fCurrentMD, fWeightersToUseFD, fWeightersToUseND, cmf::kNEARDET, and wgt.

Referenced by Weight().

1063  {
1064  double wgt = 1.;
1065 
1067 
1068  //std::string ss;
1069  for(auto itr : weighters){
1070  // ss += "\t" + itr.wgtName +
1071  // " " + std::to_string(itr.wgtFn()) +
1072  // " " + std::to_string(wgt) +
1073  // " " + std::to_string(wgt * itr.wgtFn()) +
1074  // "\n";
1075 
1076  wgt *= itr.wgtFn();
1077  }
1078  // LOG_VERBATIM("SAWWeighterInfo")
1079  // << ss;
1080 
1081  return wgt;
1082  }
cmf::DetType_t detector
Definition: Structs.h:114
std::vector< WeighterInfo > fWeightersToUseND
const ana::Var wgt
cmf::MetaData fCurrentMD
the metadata for the current event
std::vector< WeighterInfo > fWeightersToUseFD
bool cmf::ShifterAndWeighter::UseMECWeight ( bool  anti)
private
double cmf::ShifterAndWeighter::Weight ( cmf::EventPtr const &  curEvent,
cmf::MetaData const &  md 
)

Definition at line 1000 of file ShifterAndWeighter.cxx.

References cmf::MetaData::detector, fCurrentEvent, fCurrentMD, fWeightType, cmf::MetaData::IsCosmicMuon(), cmf::MetaData::isMC, cmf::kFake_Weight, cmf::kOscWgtOnly, cmf::kSystWgtOnly, cmf::kTrueE, cmf::kTruePDG, cmf::kTruePDGOrig, LOG_DEBUG, cmf::Event::MCVals(), OscillationWeight(), SetCurrentEvent(), TotalWeightFromWeighters(), cmf::MCVarVals::val_at(), and wgt.

Referenced by cmf::FillSpectrumFromSingleList(), and cmf::CovarianceFitHelper::Make1DSpectra().

1002  {
1003  // get ready to use the passed in event
1004  this->SetCurrentEvent(curEvent, md);
1005 
1006  // set the weight to be the fake weight value, which is 1 for
1007  // data.
1008  double wgt = curEvent->DataVals().val_at(cmf::kFake_Weight, md);
1009 
1010 
1011  // if the mcVals is null or the metadata claims it isn't MC,
1012  // return the fake weight for the event. If the event is data
1013  // then the value is always 1, if it is fake data, then the
1014  // value is the proper weighting
1015  if(!curEvent->MCValsFilled() ||
1016  !md.isMC ||
1017  md.IsCosmicMuon() )
1018  return wgt;
1019 
1020  // if(md.selectionType == cmf::kNuESelectionPeripheral)
1021  // LOG_VERBATIM("ShifterAndWeighter")
1022  // << "weight from systematics is "
1023  // << wgt;
1024 
1025  // check if we only want weights from the systematic parameters or only
1026  // from the oscillation parameters
1028  wgt *= this->TotalWeightFromWeighters();
1029  }
1030  else if(fWeightType == cmf::kOscWgtOnly){
1031  wgt *= this->OscillationWeight();
1032  }
1033  else
1034  wgt *= this->OscillationWeight() * this->TotalWeightFromWeighters();
1035 
1036  // if(md.selectionType == cmf::kNuESelectionPeripheral)
1037  // LOG_VERBATIM("ShifterAndWeighter")
1038  // << "weight from oscillations is "
1039  // << this->OscillationWeight();
1040 
1041  LOG_DEBUG("ShifterAndWeighter")
1042  << "Oscillation weight is "
1043  << wgt
1044  << " energy: "
1046  << " pdg: "
1048  << " orig pdg: "
1050  << " detector: "
1051  << fCurrentMD.detector;
1052 
1053  // if(md.selectionType == cmf::kNuESelectionPeripheral)
1054  // LOG_VERBATIM("ShifterAndWeighter")
1055  // << "total weight is "
1056  // << wgt;
1057 
1058  return wgt;
1059  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
MCVarVals const & MCVals() const
Definition: Event.h:80
cmf::DetType_t detector
Definition: Structs.h:114
cmf::WeightType_t fWeightType
which type of weights to use - oscillation, systematic or both
void SetCurrentEvent(cmf::EventPtr const &curEvent, cmf::MetaData const &md)
const ana::Var wgt
cmf::Event * fCurrentEvent
the current event to weight/shift
cmf::MetaData fCurrentMD
the metadata for the current event
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18
double cmf::ShifterAndWeighter::XSecCVPPFXWeight ( )
private

Definition at line 2315 of file ShifterAndWeighter.cxx.

References fCurrentEvent, cmf::kXSecCVPPFX_Weight, cmf::Event::MCVals(), and cmf::MCVarVals::val_at().

Referenced by InitShiftsAndWeightsForDetector().

2316  {
2318  }
MCVarVals const & MCVals() const
Definition: Event.h:80
cmf::Event * fCurrentEvent
the current event to weight/shift
float val_at(uint8_t const &varkey) const
Access a Var by name.
Definition: VarVals.cxx:18

Member Data Documentation

BeamSyst cmf::ShifterAndWeighter::fBeamSyst2017
private

Definition at line 212 of file ShifterAndWeighter.h.

Referenced by BeamSystWeight(), and LoadBeamSystHists2017().

cmf::CalcType_t cmf::ShifterAndWeighter::fCalcType
private

type of oscillation calculator

Definition at line 117 of file ShifterAndWeighter.h.

Referenced by OscillationCalculatorToUse(), OscillationWeight(), and SetOscillationVals().

CalibSyst cmf::ShifterAndWeighter::fCalibSyst
private

Definition at line 227 of file ShifterAndWeighter.h.

Referenced by CalibSystWeight(), and LoadCalibrationSystRatios().

cmf::Event* cmf::ShifterAndWeighter::fCurrentEvent
private
cmf::Location cmf::ShifterAndWeighter::fCurrentLoc
private

the current point in parameter space

Definition at line 115 of file ShifterAndWeighter.h.

Referenced by FractionalShift(), ReportCurrentVals(), SetCurrentVals(), and SetOscillationVals().

cmf::MetaData cmf::ShifterAndWeighter::fCurrentMD
private
std::unique_ptr<TF1> cmf::ShifterAndWeighter::fNDMuonCatcherEShiftMinus
private

negative shift in the muon catcher energy

Definition at line 123 of file ShifterAndWeighter.h.

Referenced by ShifterAndWeighter(), and ShiftForParameter().

std::unique_ptr<TF1> cmf::ShifterAndWeighter::fNDMuonCatcherEShiftPlus
private

positive shift in the muon catcher energy

Definition at line 122 of file ShifterAndWeighter.h.

Referenced by ShifterAndWeighter(), and ShiftForParameter().

std::unique_ptr<TGraph> cmf::ShifterAndWeighter::fNDMuonCatcherMinusGr
private

Graph for the negative shift in the muon catcher.

Definition at line 121 of file ShifterAndWeighter.h.

Referenced by ShifterAndWeighter().

std::unique_ptr<TGraph> cmf::ShifterAndWeighter::fNDMuonCatcherPlusGr
private

Graph for the positive shift in the muon catcher.

Definition at line 120 of file ShifterAndWeighter.h.

Referenced by ShifterAndWeighter().

TH1* cmf::ShifterAndWeighter::fNueAcceptSignalKin2018FHCWgtHist
mutableprivate

Definition at line 197 of file ShifterAndWeighter.h.

Referenced by NueAcceptSignalKin2018Weight().

TH1* cmf::ShifterAndWeighter::fNueAcceptSignalKin2018RHCWgtHist
mutableprivate

Definition at line 198 of file ShifterAndWeighter.h.

Referenced by NueAcceptSignalKin2018Weight().

osc::IOscCalcAdjustable* cmf::ShifterAndWeighter::fOscCalc
private
std::map<std::string, uint8_t> cmf::ShifterAndWeighter::fShiftersToUseFD
private
std::map<std::string, uint8_t> cmf::ShifterAndWeighter::fShiftersToUseND
private
std::set<double> cmf::ShifterAndWeighter::fTrueEnergyBins
private

the true energy binning used by CAF

Definition at line 124 of file ShifterAndWeighter.h.

Referenced by OscillationWeightBinCenter().

bool cmf::ShifterAndWeighter::fTrueEOscillationWeight
private

flag to calculate the oscillation weight at the true E_nu vs bin center

Definition at line 119 of file ShifterAndWeighter.h.

Referenced by InitShiftsAndWeightsToUse(), and OscillationWeight().

std::vector<BeamSyst> cmf::ShifterAndWeighter::fVecFluxPrincipals
private

This is each of the Flux PCA weights.

Definition at line 222 of file ShifterAndWeighter.h.

Referenced by FluxPCAWeight(), and LoadFluxBeamSystHists().

std::vector< GeniePCASyst > cmf::ShifterAndWeighter::fVecGeniePCASysts
private

This is each of the Genie PCA weights.

Definition at line 232 of file ShifterAndWeighter.h.

Referenced by GeniePCASystWeight(), and LoadGeniePCASystHists().

std::vector<WeighterInfo> cmf::ShifterAndWeighter::fWeightersToUseFD
private

Definition at line 136 of file ShifterAndWeighter.h.

Referenced by InitShiftsAndWeightsToUse(), and TotalWeightFromWeighters().

std::vector<WeighterInfo> cmf::ShifterAndWeighter::fWeightersToUseND
private

Definition at line 137 of file ShifterAndWeighter.h.

Referenced by InitShiftsAndWeightsToUse(), and TotalWeightFromWeighters().

cmf::WeightType_t cmf::ShifterAndWeighter::fWeightType
private

which type of weights to use - oscillation, systematic or both

Definition at line 118 of file ShifterAndWeighter.h.

Referenced by InitShiftsAndWeightsForDetector(), InitShiftsAndWeightsToUse(), and Weight().


The documentation for this class was generated from the following files: