Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
fnex::DataVarVals Class Reference

Base container for the MC related Vars that constitute an event. More...

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

Public Member Functions

 DataVarVals ()=default
 
 DataVarVals (fnex::DataVars const &dv)
 
float val_at (unsigned char const &varkey, fnex::MetaData const &md) const
 
float val_at (std::string const &varkey, fnex::MetaData const &md) const
 
void set_val_at (std::string const &varkey, float const &val)
 
void set_val_at (unsigned char const &varkey, float const &val)
 
fnex::DataVars const & DataVars () const
 

Private Member Functions

float NuRecoEVal (fnex::MetaData const &md) const
 
float NuRecoEVal2017 (fnex::MetaData const &md) const
 
float NuRecoEVal2018 (fnex::MetaData const &md) const
 

Private Attributes

fnex::DataVars fDataVars
 

Friends

std::ostream & operator<< (std::ostream &o, fnex::DataVarVals const &dvv)
 

Detailed Description

Base container for the MC related Vars that constitute an event.

Definition at line 930 of file VarVals.h.

Constructor & Destructor Documentation

fnex::DataVarVals::DataVarVals ( )
default
fnex::DataVarVals::DataVarVals ( fnex::DataVars const &  dv)
inline

Definition at line 943 of file VarVals.h.

References msf_helper::o, fnex::operator<<(), string, and febshutoff_auto::val.

944  : fDataVars(dv)
945  {}
fnex::DataVars fDataVars
Definition: VarVals.h:938

Member Function Documentation

fnex::DataVars const& fnex::DataVarVals::DataVars ( ) const
inline

Definition at line 962 of file VarVals.h.

962 { return fDataVars; }
fnex::DataVars fDataVars
Definition: VarVals.h:938
float fnex::DataVarVals::NuRecoEVal ( fnex::MetaData const &  md) const
inlineprivate

Definition at line 555 of file VarVals.cxx.

References fnex::ShifterAndWeighter::Instance(), fnex::MetaData::isMC, fnex::MetaData::IsNuESelected(), fnex::MetaData::IsNuMuSelected(), fnex::kHad_RecoE, fnex::kLep_RecoE, min(), fnex::MetaData::selectionType, and fnex::ShifterAndWeighter::ShiftAmount().

556  {
557  // get the amount of shift in the leptonic and hadronic energy
558  // from the ShifterAndWeighter
559  double lepEShift = 1.;
560  double hadEShift = 1.;
561 
562  // only apply shifts to the MC, the data should not be shifted as we are
563  // trying to get the MC to fit the data
564  if(md.isMC){
567  }
568 
569  if(md.IsNuMuSelected()){
570  return lepEShift * (fDataVars.fLep_RecoE - 0.1056583668) + 0.1056583668 + fDataVars.fHad_RecoE * hadEShift;
571  }
572  else if(md.IsNuESelected()){
573  // now here's a bizarre one - the nue group has decided that a quadratic
574  // function is the best way to estimate the total neutrino energy.
575  // See docdb 15174. I don't knowwhat the physics motivation for it is,
576  // but the function is
577  // (E_had)^2 * -0.140 + (E_EM)^2 * 0.248 + (E_had * E_EM) * 0.543 + E_had * 1.211 + E_EM * 0.702 + 0.687
578 
579  return ((-0.140 * fDataVars.fHad_RecoE * fDataVars.fHad_RecoE * hadEShift * hadEShift) +
580  ( 0.248 * fDataVars.fLep_RecoE * fDataVars.fLep_RecoE * lepEShift * lepEShift) +
581  ( 0.543 * fDataVars.fLep_RecoE * fDataVars.fHad_RecoE * lepEShift * hadEShift) +
582  ( 1.211 * fDataVars.fHad_RecoE * hadEShift) +
583  ( 0.702 * fDataVars.fLep_RecoE * lepEShift) +
584  0.687);
585  }
586  else
587  throw cet::exception("DataVarVals")
588  << "Unknown selection type "
589  << md.selectionType
590  << " requested to be used in calculating reconstructed energy";
591 
592 
594  }
float fLep_RecoE
Definition: VarVals.h:732
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
static ShifterAndWeighter * Instance()
fnex::DataVars fDataVars
Definition: VarVals.h:938
float fHad_RecoE
Definition: VarVals.h:731
double ShiftAmount(unsigned char const &param)
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
float fnex::DataVarVals::NuRecoEVal2017 ( fnex::MetaData const &  md) const
inlineprivate

Definition at line 598 of file VarVals.cxx.

References fnex::ShifterAndWeighter::Instance(), fnex::MetaData::isMC, fnex::MetaData::IsNuESelected(), fnex::MetaData::IsNuMuSelected(), fnex::kHad_RecoE, fnex::kLep_RecoE, min(), fnex::MetaData::selectionType, and fnex::ShifterAndWeighter::ShiftAmount().

599  {
600  // get the amount of shift in the leptonic and hadronic energy
601  // from the ShifterAndWeighter
602  double lepEShift = 1.;
603  double hadEShift = 1.;
604 
605  // only apply shifts to the MC, the data should not be shifted as we are
606  // trying to get the MC to fit the data
607  if(md.isMC){
610  }
611 
612  if(md.IsNuMuSelected()){
613  return lepEShift * (fDataVars.fLep_RecoE - 0.1056583668) + 0.1056583668 + fDataVars.fHad_RecoE * hadEShift;
614  }
615  else if(md.IsNuESelected()){
616 
617  // now here's a bizarre one - the nue group has decided that a quadratic
618  // function is the best way to estimate the total neutrino energy.
619  // See docdb 15174. I don't knowwhat the physics motivation for it is,
620  // but the SA function is
621  // (E_had)^2 * -0.140 + (E_EM)^2 * 0.248 + (E_had * E_EM) * 0.543 + E_had * 1.211 + E_EM * 0.702 + 0.687
622  // Third Analysis function has been updated to:
623  // 1/(1+0.057) * ( (E_had)^2 * 0.504 + (E_EM)^2 * 0.025 + (E_had * E_EM) * 0.000 + E_had * 0.869 + E_EM * 0.996 + 0.000 )
624 
625  return 1.0/(1.0+0.057) *(( 0.504 * fDataVars.fHad_RecoE * fDataVars.fHad_RecoE * hadEShift * hadEShift) +
626  ( 0.025 * fDataVars.fLep_RecoE * fDataVars.fLep_RecoE * lepEShift * lepEShift) +
627  ( 0.000 * fDataVars.fLep_RecoE * fDataVars.fHad_RecoE * lepEShift * hadEShift) +
628  ( 0.869 * fDataVars.fHad_RecoE * hadEShift) +
629  ( 0.996 * fDataVars.fLep_RecoE * lepEShift) +
630  0.000);
631  }
632  else
633  throw cet::exception("DataVarVals")
634  << "Unknown selection type "
635  << md.selectionType
636  << " requested to be used in calculating reconstructed energy";
637 
638 
640  }
float fLep_RecoE
Definition: VarVals.h:732
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
static ShifterAndWeighter * Instance()
fnex::DataVars fDataVars
Definition: VarVals.h:938
float fHad_RecoE
Definition: VarVals.h:731
double ShiftAmount(unsigned char const &param)
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
float fnex::DataVarVals::NuRecoEVal2018 ( fnex::MetaData const &  md) const
inlineprivate

Definition at line 645 of file VarVals.cxx.

References fnex::MetaData::BeamType(), fnex::ShifterAndWeighter::Instance(), fnex::MetaData::isMC, fnex::MetaData::IsNuESelected(), fnex::MetaData::IsNuMuSelected(), fnex::kFHC, fnex::kHad_RecoE, fnex::kLep_RecoE, fnex::kRHC, LOG_DEBUG, min(), PandAna.Demos.pi0_spectra::p0, plot_validation_datamc::p1, plot_validation_datamc::p2, make_associated_cosmic_defs::p3, make_associated_cosmic_defs::p4, make_associated_cosmic_defs::p5, fnex::MetaData::selectionType, and fnex::ShifterAndWeighter::ShiftAmount().

646  {
647  // get the amount of shift in the leptonic and hadronic energy
648  // from the ShifterAndWeighter
649  double lepEShift = 1.;
650  double hadEShift = 1.;
651 
652  // only apply shifts to the MC, the data should not be shifted as we are
653  // trying to get the MC to fit the data
654  if(md.isMC){
657  }
658 
659  if(md.IsNuMuSelected()){
660  return lepEShift * (fDataVars.fLep_RecoE - 0.1056583668) + 0.1056583668 + fDataVars.fHad_RecoE * hadEShift;
661  }
662  else if(md.IsNuESelected()){
663 
664 
665  double p0 = -5.0;
666  double p1 = -5.0;
667  double p2 = -5.0;
668  double p3 = -5.0;
669  double p4 = -5.0;
670  double p5 = -5.0;
671  double fr = -5.0;
672 
673  if(md.BeamType() == kFHC){
674 
675  p0 = 0.0;
676  p1 = 1.00756;
677  p2 = 1.07093;
678  p3 = 0.0;
679  p4 = 1.28608e-02;
680  p5 = 2.27129e-01;
681  fr = 1./(1+0.0501206);
682 
683  }else if(md.BeamType() == kRHC){
684 
685  p0 = 0.0;
686  p1 = 0.980479;
687  p2 = 1.45170;
688  p3 = 0.0;
689  p4 = -5.82609e-03;
690  p5 = -2.27599e-01;
691  fr = 1./(1+0.001766);
692 
693  } else {
694  LOG_DEBUG("DataVarVals")
695  << "Unknown beam type "
696  << md.BeamType()
697  << " use 2017 NueEnergy Estimator";
698 
699  p0 = 0.000;
700  p1 = 0.996;
701  p2 = 0.869;
702  p3 = 0.000;
703  p4 = 0.025;
704  p5 = 0.504;
705  fr = 1.0/(1.0+0.057);
706  }
707 
708  return fr *(( p5 * fDataVars.fHad_RecoE * fDataVars.fHad_RecoE * hadEShift * hadEShift) +
709  ( p4 * fDataVars.fLep_RecoE * fDataVars.fLep_RecoE * lepEShift * lepEShift) +
710  ( p3 * fDataVars.fLep_RecoE * fDataVars.fHad_RecoE * lepEShift * hadEShift) +
711  ( p2 * fDataVars.fHad_RecoE * hadEShift) +
712  ( p1 * fDataVars.fLep_RecoE * lepEShift) +
713  p0 );
714 
715  }
716  else
717  throw cet::exception("DataVarVals")
718  << "Unknown selection type "
719  << md.selectionType
720  << " requested to be used in calculating reconstructed energy";
721 
722 
724  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
float fLep_RecoE
Definition: VarVals.h:732
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
static ShifterAndWeighter * Instance()
fnex::DataVars fDataVars
Definition: VarVals.h:938
float fHad_RecoE
Definition: VarVals.h:731
double ShiftAmount(unsigned char const &param)
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
void fnex::DataVarVals::set_val_at ( std::string const &  varkey,
float const &  val 
)
void fnex::DataVarVals::set_val_at ( unsigned char const &  varkey,
float const &  val 
)

Definition at line 533 of file VarVals.cxx.

References fnex::KeyToVarName(), fnex::kFake_Weight, fnex::kHad_RecoE, fnex::kLep_RecoE, fnex::kLep_RecoE_MCFrac, fnex::kNuE_CVN, fnex::kNuE_NumMichel, fnex::kRecoQ2, LOG_DEBUG, and febshutoff_auto::val.

535  {
536 // if(varkey == kNuE_LID ) fDataVars.NuE_LID = val;
537 // else if(varkey == kNuE_LEM ) fDataVars.NuE_LEM = val;
538  if(varkey == kNuE_CVN ) fDataVars.fNuE_CVN = val;
539  else if(varkey == kNuE_NumMichel ) fDataVars.fNuE_NumMichel = val;
540  else if(varkey == kHad_RecoE ) fDataVars.fHad_RecoE = val;
541  else if(varkey == kLep_RecoE ) fDataVars.fLep_RecoE = val;
542  else if(varkey == kLep_RecoE_MCFrac ) fDataVars.fLep_RecoE_MCFrac = val;
543  else if(varkey == kRecoQ2 ) fDataVars.fRecoQ2 = val;
544  else if(varkey == kFake_Weight ) fDataVars.fFake_Weight = val;
545  else
546  LOG_DEBUG("DataVarVals")
547  << "unable to set Data var "
548  << fnex::KeyToVarName(varkey)
549  << " because the key is unknown";
550 
551  return;
552  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
static const unsigned char kNuE_CVN
Definition: VarVals.h:32
float fNuE_CVN
Definition: VarVals.h:729
float fLep_RecoE
Definition: VarVals.h:732
static const unsigned char kRecoQ2
Definition: VarVals.h:38
static const unsigned char kFake_Weight
Definition: VarVals.h:39
float fNuE_NumMichel
Definition: VarVals.h:730
float fLep_RecoE_MCFrac
fraction of leptonic energy in muon catcher
Definition: VarVals.h:733
fnex::DataVars fDataVars
Definition: VarVals.h:938
float fRecoQ2
reconstructed Q^2
Definition: VarVals.h:734
float fHad_RecoE
Definition: VarVals.h:731
static const unsigned char kLep_RecoE_MCFrac
Definition: VarVals.h:37
static const unsigned char kNuE_NumMichel
Definition: VarVals.h:33
float fFake_Weight
Weight for fake data events.
Definition: VarVals.h:735
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
std::string KeyToVarName(unsigned char const &key)
Definition: VarVals.h:445
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
float fnex::DataVarVals::val_at ( unsigned char const &  varkey,
fnex::MetaData const &  md 
) const

Access a Var by name. Throws if the var doesn't exist

Definition at line 499 of file VarVals.cxx.

References fnex::kFake_Weight, fnex::kHad_RecoE, fnex::kLep_RecoE, fnex::kLep_RecoE_MCFrac, fnex::kNu_RecoE, fnex::kNuE_CVN, fnex::kNuE_NumMichel, fnex::kRecoQ2, and min().

Referenced by fnex::EventListMaker::CheckNueFDPID(), fnex::NuMuAnalysisSetup::FillRecoVars(), fnex::NuMuAnalysisSetup::FillVars(), fnex::NuEAnalysisSetup::FillVars(), fnex::operator<<(), fnex::ReadCAFMakeEventList::ReadCAFTree(), and fnex::ReadCAFMakeEventList::Serialize().

501  {
502 // if(varkey == kNuE_LID ) return fDataVars.NuE_LID;
503 // else if(varkey == kNuE_LEM ) return fDataVars.NuE_LEM;
504  if(varkey == kNuE_CVN ) return fDataVars.fNuE_CVN;
505  else if(varkey == kNuE_NumMichel ) return fDataVars.fNuE_NumMichel;
506  else if(varkey == kHad_RecoE ) return fDataVars.fHad_RecoE;
507  else if(varkey == kLep_RecoE ) return fDataVars.fLep_RecoE;
508  else if(varkey == kLep_RecoE_MCFrac) return fDataVars.fLep_RecoE_MCFrac;
509  else if(varkey == kRecoQ2 ) return fDataVars.fRecoQ2;
510  else if(varkey == kFake_Weight ) return fDataVars.fFake_Weight;
511  else if(varkey == kNu_RecoE ) return this->NuRecoEVal2018(md);
512 
514  }
static const unsigned char kNu_RecoE
Definition: VarVals.h:36
static const unsigned char kNuE_CVN
Definition: VarVals.h:32
float fNuE_CVN
Definition: VarVals.h:729
float fLep_RecoE
Definition: VarVals.h:732
static const unsigned char kRecoQ2
Definition: VarVals.h:38
static const unsigned char kFake_Weight
Definition: VarVals.h:39
float NuRecoEVal2018(fnex::MetaData const &md) const
Definition: VarVals.cxx:645
float fNuE_NumMichel
Definition: VarVals.h:730
float fLep_RecoE_MCFrac
fraction of leptonic energy in muon catcher
Definition: VarVals.h:733
fnex::DataVars fDataVars
Definition: VarVals.h:938
float fRecoQ2
reconstructed Q^2
Definition: VarVals.h:734
float fHad_RecoE
Definition: VarVals.h:731
static const unsigned char kLep_RecoE_MCFrac
Definition: VarVals.h:37
static const unsigned char kNuE_NumMichel
Definition: VarVals.h:33
float fFake_Weight
Weight for fake data events.
Definition: VarVals.h:735
static float min(const float a, const float b, const float c)
Definition: absgeo.cxx:45
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
static const unsigned char kLep_RecoE
Definition: VarVals.h:35
float fnex::DataVarVals::val_at ( std::string const &  varkey,
fnex::MetaData const &  md 
) const

Definition at line 517 of file VarVals.cxx.

References fnex::VarNameToKey().

519  {
520  return this->val_at(fnex::VarNameToKey(varkey),
521  md);
522  }
unsigned char VarNameToKey(std::string const &name)
Definition: VarVals.h:279
float val_at(unsigned char const &varkey, fnex::MetaData const &md) const
Definition: VarVals.cxx:499

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
fnex::DataVarVals const &  dvv 
)
friend

Definition at line 728 of file VarVals.cxx.

729  {
730  fnex::MetaData numumd;
731  fnex::MetaData nuemd;
732 
733  numumd.isMC = false;
734  nuemd .isMC = false;
737 
738  o << "Event MC related variables are: "
739  << "\n\t" << fnex::KeyToVarName(fnex::kNuE_CVN) << " " << dvv.val_at(fnex::kNuE_CVN, nuemd )
740  << "\n\t" << fnex::KeyToVarName(fnex::kNuE_NumMichel) << " " << dvv.val_at(fnex::kNuE_NumMichel, nuemd )
741  << "\n\t" << fnex::KeyToVarName(fnex::kHad_RecoE) << " " << dvv.val_at(fnex::kHad_RecoE, nuemd )
742  << "\n\t" << fnex::KeyToVarName(fnex::kLep_RecoE) << " " << dvv.val_at(fnex::kLep_RecoE, nuemd )
743  << "\n\t" << fnex::KeyToVarName(fnex::kLep_RecoE_MCFrac) << " " << dvv.val_at(fnex::kLep_RecoE_MCFrac, numumd)
744  << "\n\t" << fnex::KeyToVarName(fnex::kNu_RecoE ) << " nue " << dvv.val_at(fnex::kNu_RecoE, nuemd )
745  << "\n\t" << fnex::KeyToVarName(fnex::kNu_RecoE ) << " numu " << dvv.val_at(fnex::kNu_RecoE, numumd)
746  << "\n\t" << fnex::KeyToVarName(fnex::kFake_Weight) << " " << dvv.val_at(fnex::kFake_Weight, nuemd )
747  << std::endl;
748 
749  return o;
750  }
static const unsigned char kNu_RecoE
Definition: VarVals.h:36
static const unsigned char kNuE_CVN
Definition: VarVals.h:32
static const unsigned char kFake_Weight
Definition: VarVals.h:39
static const unsigned char kLep_RecoE_MCFrac
Definition: VarVals.h:37
static const unsigned char kNuE_NumMichel
Definition: VarVals.h:33
fnex::SelectionType_t selectionType
Definition: Structs.h:52
static const unsigned char kHad_RecoE
Definition: VarVals.h:34
std::string KeyToVarName(unsigned char const &key)
Definition: VarVals.h:445
static const unsigned char kLep_RecoE
Definition: VarVals.h:35

Member Data Documentation

fnex::DataVars fnex::DataVarVals::fDataVars
private

Definition at line 938 of file VarVals.h.


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