NuZBeamReweight Class Reference

#include <NuZBeamReweight.h>

List of all members.

Public Member Functions

 NuZBeamReweight ()
 ~NuZBeamReweight ()
void ExtractZBeamReweight (NuEvent &nu, bool useCustom=false) const
void ExtractZBeamReweight (NuMCEvent &numc, bool useCustom=false) const
void ExtractZBeamReweightCustom (NuEvent &nu) const
void ExtractZBeamReweightCustom (NuMCEvent &numc) const
void ExtractZBeamReweight (const NtpStRecord &ntp, const NtpSREvent &evt, NuEvent &nu) const
void ExtractZBeamReweight (const NtpStRecord &ntp, NuEvent &nu) const
void GetBeamWeightsOnly (NuEvent &nu) const
void CalcGeneratorReweight (const NtpStRecord &ntp, const NtpSREvent &evt, NuEvent &nu) const
void CalcGeneratorReweight (NuEvent &nu) const
double GetWeightHelium (NuEvent &nu) const
SKZPWeightCalculatorGetSKZPWeightCalculator (const NuEvent &nu) const
SKZPWeightCalculatorGetSKZPWeightCalculatorCustom () const
SKZPWeightCalculatorGetSKZPWeightCalculator2018 (const NuEvent &nu, TString bfilename, TString hfilename="hadron_parameters_2018.root", TString dir="") const
const Char_t * AsString (SKZPWeightCalculator::SKZPConfig_t c) const

Private Member Functions

bool EventPreCheck (NuEvent &nu) const
void GetWeights (NuEvent &nu, SKZPWeightCalculator &wc, bool beamOnly=false) const
void GetWeights (NuEvent &nu, SKZPWeightCalculator &wc, SKZPWeightCalculator::RunPeriod_t rp, bool beamOnly=false) const
void GetRFWeights (NuEvent &nu, SKZPWeightCalculator &wc) const
void AddNeugenWeightCalculator () const
void CompareMCEventInfo (const MCEventInfo &ei, const MCEventInfo &ei2) const
RegistryCreateNeugenRegistry (const NuEvent &nu) const
void MCEventInfoFilla (MCEventInfo *ei, const NuEvent &nu) const
std::vector< double > ReadParameters (TString filename) const

Detailed Description

Definition at line 19 of file NuZBeamReweight.h.


Constructor & Destructor Documentation

NuZBeamReweight::NuZBeamReweight (  ) 

Definition at line 39 of file NuZBeamReweight.cxx.

References Msg::kDebug, and MSG.

00040 {
00041   MSG("NuZBeamReweight",Msg::kDebug)
00042     <<"Running NuZBeamReweight Constructor..."<<endl;
00043 
00044 
00045   MSG("NuZBeamReweight",Msg::kDebug)
00046     <<"Finished NuZBeamReweight Constructor"<<endl;
00047 }

NuZBeamReweight::~NuZBeamReweight (  ) 

Definition at line 51 of file NuZBeamReweight.cxx.

References Msg::kDebug, and MSG.

00052 {
00053   MSG("NuZBeamReweight",Msg::kDebug)
00054     <<"Running NuZBeamReweight Destructor..."<<endl;
00055 
00056 
00057   MSG("NuZBeamReweight",Msg::kDebug)
00058     <<"Finished NuZBeamReweight Destructor"<<endl;
00059 }


Member Function Documentation

void NuZBeamReweight::AddNeugenWeightCalculator (  )  const [private]

make a WeightCalculator and add it to the MCReweight singleton

Definition at line 935 of file NuZBeamReweight.cxx.

References MCReweight::AddWeightCalculator(), MCReweight::Instance(), Msg::kInfo, MAXMSG, and n.

Referenced by CalcGeneratorReweight().

00936 {
00938   Bool_t firstTime=true;
00939   if (firstTime) {
00940     firstTime=false;
00941     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00942       <<"Adding NeugenWeightCalculator to MCReweight singleton"<<endl;
00943     static NeugenWeightCalculator *n=new NeugenWeightCalculator();
00944     MCReweight* mcr=&MCReweight::Instance();
00945     mcr->AddWeightCalculator(n);
00946   }
00947 }

const Char_t * NuZBeamReweight::AsString ( SKZPWeightCalculator::SKZPConfig_t  c  )  const

Definition at line 1057 of file NuZBeamReweight.cxx.

References SKZPWeightCalculator::kBoston, SKZPWeightCalculator::kDetXs, SKZPWeightCalculator::kDogwood1_Daikon07, SKZPWeightCalculator::kDogwood1_Daikon07_v2, SKZPWeightCalculator::kDogwood5_Daikon07_2012, SKZPWeightCalculator::kMINOSplus_2014, SKZPWeightCalculator::kMINOSplus_2014_v2, SKZPWeightCalculator::kMINOSplus_2018, SKZPWeightCalculator::kPiMinus, SKZPWeightCalculator::kPRL, and SKZPWeightCalculator::kUnknown.

Referenced by GetSKZPWeightCalculator(), and GetSKZPWeightCalculator2018().

01058 {
01059   // return char string in cannonical offline form
01060   switch (c) {
01061   case SKZPWeightCalculator::kPRL:     return "PRL";
01062   case SKZPWeightCalculator::kBoston:  return "Boston";
01063   case SKZPWeightCalculator::kPiMinus: return "PiMinus_CedarDaikon";
01064   case SKZPWeightCalculator::kDetXs:   return "DetXs";
01065   case SKZPWeightCalculator::kDogwood1_Daikon07: return "Dogwood1_Daikon07";
01066   case SKZPWeightCalculator::kDogwood1_Daikon07_v2: return "Dogwood1_Daikon07_v2";
01067   case SKZPWeightCalculator::kDogwood5_Daikon07_2012: return "Dogwood5_Daikon07_2012";
01068   case SKZPWeightCalculator::kMINOSplus_2014: return "MINOSplus_2014";
01069   case SKZPWeightCalculator::kMINOSplus_2014_v2: return "MINOSplus_2014_v2";
01070   case SKZPWeightCalculator::kMINOSplus_2018: return "MINOSplus_2018";
01071   case SKZPWeightCalculator::kUnknown: return "Unknown"; break;
01072   default:         return "!?Bad Value Passed?!"; break;
01073   }
01074 }

void NuZBeamReweight::CalcGeneratorReweight ( NuEvent nu  )  const

Definition at line 595 of file NuZBeamReweight.cxx.

References AddNeugenWeightCalculator(), MCReweight::ComputeWeight(), CreateNeugenRegistry(), NuEvent::generatorConfigNo, NuEvent::generatorWeight, MCReweight::Instance(), ReleaseType::IsDaikon(), Msg::kInfo, MAXMSG, MCEventInfoFilla(), NuEvent::releaseType, NuEvent::sGeneratorConfigName, NuEvent::useGeneratorReweight, and MCEventInfo::UseStoredXSec().

00596 {
00597   if (!nu.useGeneratorReweight) {
00598     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00599       <<"CalcGeneratorReweight(nu): not calculating Generator reweight"
00600       <<" since nu.useGeneratorReweight="<<nu.useGeneratorReweight
00601       <<endl;
00602     return;
00603   }
00604 
00605   if (ReleaseType::IsDaikon(nu.releaseType)) {
00606     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00607       <<"Not doing CalcGeneratorReweight(nu) for Daikon, not required"
00608       <<endl;
00609     return;
00610   }
00611 
00612   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00613     <<"CalcGeneratorReweight(nu):"<<endl
00614     <<"  generator:config_name="<<nu.sGeneratorConfigName
00615     <<"  generator:config_no="<<nu.generatorConfigNo
00616     <<endl;
00617 
00618   //declare the registry and create it only once
00619   static Registry* rwtconfig=this->CreateNeugenRegistry(nu);
00620 
00621   //make a WeightCalculator and add it to the MCReweight singleton
00622   this->AddNeugenWeightCalculator();
00623 
00624   //fill MCEventInfo
00625   MCEventInfo ei;
00626   ei.UseStoredXSec(true);
00627   //ReweightHelpers::MCEventInfoFilla(&ei,st,thidx);
00628   this->MCEventInfoFilla(&ei,nu);
00629 
00630   //Compute the MODBYRS3 weight
00631   Double_t generatorweight=1.;
00632   NuParent* np=0;
00633   if (nu.useGeneratorReweight){
00634     MCReweight* mcr=&MCReweight::Instance();
00635     generatorweight=mcr->ComputeWeight(&ei,np,rwtconfig);
00636   }
00637 
00638   //set the output of the function
00639   nu.generatorWeight=generatorweight;
00640 }

void NuZBeamReweight::CalcGeneratorReweight ( const NtpStRecord ntp,
const NtpSREvent evt,
NuEvent nu 
) const

Compute the generator weight (e.g. MODBYRS) this method does a sanity check so keep for now plan to kill off all dependence on NtpS* in the longer term

Definition at line 517 of file NuZBeamReweight.cxx.

References AddNeugenWeightCalculator(), CompareMCEventInfo(), MCReweight::ComputeWeight(), CreateNeugenRegistry(), NuEvent::generatorConfigNo, NuEvent::generatorWeight, NtpSREvent::index, MCReweight::Instance(), ReleaseType::IsDaikon(), Msg::kDebug, Msg::kInfo, SimFlag::kMC, MAXMSG, MCEventInfoFilla(), NtpTHEvent::neumc, NuEvent::releaseType, NuEvent::sGeneratorConfigName, NuEvent::simFlag, NtpStRecord::thevt, NuEvent::useGeneratorReweight, and MCEventInfo::UseStoredXSec().

Referenced by NuAnalysis::ExtractPIDsAndWeights().

00520 {
00524 
00525   //return if not MC
00526   if (nu.simFlag!=SimFlag::kMC) {
00527     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00528       <<"Not doing CalcGeneratorReweight"
00529       <<"for simFlag="<<nu.simFlag<<endl;
00530 
00531     //set the weights to 1 that would otherwise be set below
00532     nu.generatorWeight=1;//no reweighting
00533     return;
00534   }
00535 
00536   if (!nu.useGeneratorReweight) {
00537     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00538       <<"CalcGeneratorReweight: not calculating Generator reweight"
00539       <<" since nu.useGeneratorReweight="<<nu.useGeneratorReweight
00540       <<endl;
00541     return;
00542   }
00543 
00544   if (ReleaseType::IsDaikon(nu.releaseType)) {
00545     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00546       <<"Not calculating Generator weight for Daikon, not required"
00547       <<endl;
00548     return;
00549   }
00550 
00551   MAXMSG("NuZBeamReweight",Msg::kDebug,100)
00552     <<"CalcGeneratorReweight:"<<endl
00553     <<"  generator:config_name="<<nu.sGeneratorConfigName
00554     <<"  generator:config_no="<<nu.generatorConfigNo
00555     <<endl;
00556 
00557   //declare the registry and create it only once
00558   static Registry* rwtconfig=this->CreateNeugenRegistry(nu);
00559 
00560   //make a WeightCalculator and add it to the MCReweight singleton
00561   this->AddNeugenWeightCalculator();
00562 
00563   //get the MC info from the ntp
00564   TClonesArray& thevtTca=*ntp.thevt;
00565   const NtpTHEvent* the=
00566     dynamic_cast<NtpTHEvent*>(thevtTca[evt.index]);
00567   Int_t thidx=the->neumc;
00568 
00569   //fill MCEventInfo to do MODBYRS3;
00570   MCEventInfo ei;
00571   ei.UseStoredXSec(true);
00572   NtpStRecord* st=const_cast<NtpStRecord*>(&ntp);//nasty!
00573   ReweightHelpers::MCEventInfoFilla(&ei,st,thidx);
00574 
00575   //a second one for a sanity check on the values in the NuEvent
00576   MCEventInfo ei2;
00577   ei2.UseStoredXSec(true);
00578   this->MCEventInfoFilla(&ei2,nu);
00579   this->CompareMCEventInfo(ei,ei2);
00580 
00581   //Compute the MODBYRS3 weight
00582   Double_t generatorweight=1.;
00583   NuParent* np=0;
00584   if (nu.useGeneratorReweight){
00585     MCReweight* mcr=&MCReweight::Instance();
00586     generatorweight=mcr->ComputeWeight(&ei,np,rwtconfig);
00587   }
00588 
00589   //set the output of the function
00590   nu.generatorWeight=generatorweight;
00591 }

void NuZBeamReweight::CompareMCEventInfo ( const MCEventInfo ei,
const MCEventInfo ei2 
) const [private]

Definition at line 973 of file NuZBeamReweight.cxx.

References MCEventInfo::had_fs, MCEventInfo::initial_state, Msg::kError, MAXMSG, and MCEventInfo::nucleus.

Referenced by CalcGeneratorReweight().

00975 {
00976   if (ei.initial_state!=ei2.initial_state ||
00977       ei.nucleus!=ei2.nucleus ||
00978       ei.had_fs!=ei2.had_fs){
00979     MAXMSG("NuZBeamReweight",Msg::kError,300)
00980       <<"Ahhh, CompareMCEventInfo difference found:"<<endl
00981       <<"1st: initial_state="<<ei.initial_state
00982       <<", nucleus="<<ei.nucleus
00983       <<", had_fs="<<ei.had_fs
00984       <<endl
00985       <<"2nd: initial_state="<<ei2.initial_state
00986       <<", nucleus="<<ei2.nucleus
00987       <<", had_fs="<<ei2.had_fs
00988       <<endl
00989       <<"NOTE: This discrepancy has to be understood if we"
00990       <<" are to trust the generator reweighting"
00991       <<endl;
00992   }
00993 }

Registry * NuZBeamReweight::CreateNeugenRegistry ( const NuEvent nu  )  const [private]

Definition at line 951 of file NuZBeamReweight.cxx.

References Registry::Clear(), NuEvent::generatorConfigNo, Registry::LockKeys(), Registry::LockValues(), Registry::Set(), NuEvent::sGeneratorConfigName, Registry::UnLockKeys(), and Registry::UnLockValues().

Referenced by CalcGeneratorReweight().

00952 {
00953   static Registry* rwtconfig=0;
00954 
00955   //create it the first time
00956   if (rwtconfig==0){
00957 
00958     //fill the registry to tell MCReweight to do MODBYRS3
00959     rwtconfig=new Registry();
00960     rwtconfig->UnLockValues();
00961     rwtconfig->UnLockKeys();
00962     rwtconfig->Clear();
00963     rwtconfig->Set("neugen:config_name",nu.sGeneratorConfigName.c_str());
00964     rwtconfig->Set("neugen:config_no",nu.generatorConfigNo);
00965     rwtconfig->LockValues();
00966     rwtconfig->LockKeys();
00967   }
00968   return rwtconfig;
00969 }

bool NuZBeamReweight::EventPreCheck ( NuEvent nu  )  const [private]

Definition at line 681 of file NuZBeamReweight.cxx.

References NuEvent::beamType, NuEvent::beamWeight, NuEvent::detectorWeightNM, NuEvent::detectorWeightNMB, Msg::kInfo, BeamType::kM000z200i_nova, BeamType::kM000z200i_nova_rev, SimFlag::kMC, SKZPWeightCalculator::kUnknown, MAXMSG, NuEvent::reweightVersion, NuEvent::runPeriod, NuEvent::shwEnWeight, NuEvent::simFlag, and NuEvent::trkEnWeight.

Referenced by ExtractZBeamReweight(), and GetBeamWeightsOnly().

00682 {
00683   bool eventGood = true;
00684   
00685   if (nu.runPeriod == 0 && BeamType::kM000z200i_nova != nu.beamType ) {
00686     if (//BeamType::kM000z200i_nova == nu.beamType ||
00687         BeamType::kM000z200i_nova_rev == nu.beamType){
00688       MAXMSG("NuZBeamReweight",Msg::kInfo,10)
00689         << "Not extracting SKZP weights for NOvA beam" << endl;
00690       eventGood = false;
00691     }
00692     else{
00693       MAXMSG("NuZBeamReweight",Msg::kInfo,100)
00694         << "Daikon04-era weights for nu.runPeriod="<< nu.runPeriod
00695         << " are no longer supported.  Now you need a valid (>1) "
00696         << "run period to get SKZP weights.  No weights obtained." << endl;
00697       eventGood = false;
00698     }
00699   }
00700   
00701   if (nu.simFlag != SimFlag::kMC) {
00702     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00703     << "Not doing ExtractZBeamReweight for Data (nu.simFlag = "
00704     << nu.simFlag << ")" << endl;
00705     eventGood = false;
00706   }
00707   
00708   
00709   if (nu.reweightVersion==SKZPWeightCalculator::kUnknown) {
00710     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00711     <<"Not doing ExtractZBeamReweight for kUnknown reweightVersion="
00712     << nu.reweightVersion << endl;
00713         
00714     eventGood = false;
00715   }
00716     
00717   if (nu.runPeriod == -1) {
00718     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00719     << "Not doing ExtractZBeamReweight by user choice (nu.runPeriod = " 
00720     << nu.runPeriod << ")" << endl;
00721     eventGood = false;
00722   }
00723   
00724   if (!eventGood) {
00725     //set the weights to 1 that would otherwise come from SKZPWeightCalculator
00726     nu.trkEnWeight=1;//no reweighting
00727     nu.shwEnWeight=1;//no reweighting
00728     nu.beamWeight=1;//no reweighting
00729     nu.detectorWeightNMB=1;//no reweighting
00730     nu.detectorWeightNM=1;//no reweighting
00731         
00732     return false;
00733   }
00734 
00735   return true;
00736 }

void NuZBeamReweight::ExtractZBeamReweight ( const NtpStRecord ntp,
NuEvent nu 
) const

Definition at line 164 of file NuZBeamReweight.cxx.

References ExtractZBeamReweight(), Msg::kError, and MAXMSG.

00166 {
00167   MAXMSG("NuZBeamReweight",Msg::kError,2000)
00168     <<"NuZBeamReweight::ExtractZBeamReweight(const NtpStRecord& ntp,NuEvent& nu) const"
00169     <<" is deprecated, passing off to ExtractZBeamReweight(NuEvent& nu)!"<<endl;
00170   this->ExtractZBeamReweight(nu);
00171 }

void NuZBeamReweight::ExtractZBeamReweight ( const NtpStRecord ntp,
const NtpSREvent evt,
NuEvent nu 
) const

Definition at line 154 of file NuZBeamReweight.cxx.

References ExtractZBeamReweight().

00157 {
00158   //get the weights
00159   this->ExtractZBeamReweight(nu);
00160 }

void NuZBeamReweight::ExtractZBeamReweight ( NuMCEvent numc,
bool  useCustom = false 
) const

Definition at line 101 of file NuZBeamReweight.cxx.

References NuReco::ApplyReweights(), NuMCEvent::beamWeight, NuEvent::beamWeight, NuMCEvent::detectorWeight, NuEvent::detectorWeight, NuMCEvent::detectorWeightNM, NuEvent::detectorWeightNM, NuEvent::detectorWeightNMB, NuMCEvent::detectorWeightNMB, NuLibrary::ext, ExtractZBeamReweight(), NuMCEvent::fluxErr, NuEvent::fluxErr, NuEvent::generatorWeight, NuMCEvent::generatorWeight, NuLibrary::Instance(), Msg::kInfo, MAXMSG, NuExtraction::NuEventFromNuMCEvent(), NuLibrary::reco, NuEvent::reweightVersion, NuMCEvent::rw, NuEvent::rw, NuEvent::rwActual, NuMCEvent::rwActual, NuMCEvent::shwEnWeight, NuEvent::shwEnWeight, NuMCEvent::trkEnWeight, and NuEvent::trkEnWeight.

00102 {
00103   if (!useCustom) {
00104     MAXMSG("NuZBeamReweight",Msg::kInfo,1) << "Extracting beam weights for a NuMCEvent." << endl
00105     << "  Be aware that unless you have previously extracted weights for a NuEvent" << endl
00106     << "  NuZBeamReweight does not know what reweightVersion to use because that" << endl
00107     << "  information is not stored in NuMCEvent.  If you have previously gotten" << endl
00108     << "  weights for a NuEvent the same reweightVersion *should* be used.  If not" << endl
00109     << "  the reweightVersion defaults to 7 (kDogwood5_Daikon07_2012).  Check the" << endl
00110     << "  logs carefully.  The *correct* solution here is to add reweightVersion" << endl
00111     << "  to NuMCEvent -- but not at this late stage." << endl;
00112   }
00113 
00114   const NuLibrary& lib=NuLibrary::Instance();
00115 
00116   NuEvent nu;
00117   lib.ext.NuEventFromNuMCEvent(numc, nu);
00118   nu.reweightVersion = 7; // Forcing to kDogwood5_Daikon07_2012
00119   ExtractZBeamReweight(nu);
00120   lib.reco.ApplyReweights(nu);
00121 
00122   //copy the weights
00123   numc.rw=nu.rw;
00124   numc.fluxErr=nu.fluxErr;
00125   numc.rwActual=nu.rwActual;
00126   numc.generatorWeight=nu.generatorWeight;
00127   numc.detectorWeight=nu.detectorWeight;
00128 
00129   numc.trkEnWeight=nu.trkEnWeight;
00130   numc.shwEnWeight=nu.shwEnWeight;
00131   numc.beamWeight=nu.beamWeight;
00132   numc.detectorWeightNMB=nu.detectorWeightNMB;
00133   numc.detectorWeightNM=nu.detectorWeightNM;
00134 }

void NuZBeamReweight::ExtractZBeamReweight ( NuEvent nu,
bool  useCustom = false 
) const

Definition at line 63 of file NuZBeamReweight.cxx.

References EventPreCheck(), GetSKZPWeightCalculator(), GetSKZPWeightCalculatorCustom(), GetWeights(), Msg::kInfo, and MAXMSG.

Referenced by NuAnalysis::ExtractPIDsAndWeights(), ExtractZBeamReweight(), ExtractZBeamReweightCustom(), NuAnalysis::LIRejectionTest(), NuAnalysis::LoopOverTruthInfo(), NuDSTAna::MakeMicroDst2010(), NuDSTAna::MakeMicroDst2014(), NuDSTAna::MakeMicroDstHe(), NuDSTAna::MakeMicroDstNC2012(), NuDSTAna::NDQPRB(), NuDSTAna::QPStudy(), and NuDSTAna::RHCTest().

00064 {
00065 
00066   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00067     <<"Running ExtractZBeamReweight..."<<endl;
00068 
00069   // Protect people's gDirectory from being unexpectedly stomped on
00070   TDirectory* restore = gDirectory;
00071 
00072   if (!this->EventPreCheck(nu)) return;
00073 
00074 //  // Use NA49 NuMu-only weights for RHC
00075 //  if (nu.hornIsReverse ||
00076 //      nu.runPeriod == 4 ||
00077 //      nu.beamType == BeamType::kL010z185i_rev) {
00078 //    MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00079 //    <<"Using numu-only weights for RHC"<<endl;
00080 //    useCustom = true;
00081 //  }
00082 
00083   //get a reference
00084   SKZPWeightCalculator* wc;
00085 
00086   if (useCustom) {
00087     wc = this->GetSKZPWeightCalculatorCustom();
00088   }
00089   else {
00090     wc = this->GetSKZPWeightCalculator(nu);
00091   }
00092 
00093   GetWeights(nu, *wc);
00094   
00095   // Protect people's gDirectory from being unexpectedly stomped on
00096   restore->cd();
00097 }

void NuZBeamReweight::ExtractZBeamReweightCustom ( NuMCEvent numc  )  const

Definition at line 146 of file NuZBeamReweight.cxx.

References ExtractZBeamReweight().

00147 {
00148   this->ExtractZBeamReweight(numc, true);
00149 }

void NuZBeamReweight::ExtractZBeamReweightCustom ( NuEvent nu  )  const

Definition at line 138 of file NuZBeamReweight.cxx.

References ExtractZBeamReweight().

00139 {
00140   this->ExtractZBeamReweight(nu, true);
00141 }

void NuZBeamReweight::GetBeamWeightsOnly ( NuEvent nu  )  const

Definition at line 176 of file NuZBeamReweight.cxx.

References EventPreCheck(), GetSKZPWeightCalculator(), GetSKZPWeightCalculator2018(), GetWeights(), Msg::kInfo, SKZPWeightCalculator::kMINOSplus_2018, MAXMSG, NuEvent::reweightVersion, and NuEvent::runPeriod.

Referenced by NuFluxHelper::FillMMHelpers(), and NuFluxHelper::FillNonMMHelpers().

00177 {
00178 
00179   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00180   <<"Running GetZBeamReweight..."<<endl;
00181 
00182   if (!this->EventPreCheck(nu)) return;
00183   // Protect people's gDirectory from being unexpectedly stomped on
00184   TDirectory* restore = gDirectory;
00185   //get a reference
00186   SKZPWeightCalculator* wc;
00187   if ( nu.reweightVersion == SKZPWeightCalculator::kMINOSplus_2018){
00188 
00189     if (nu.runPeriod == 11 || nu.runPeriod == 12){
00190       wc = this->GetSKZPWeightCalculator2018(nu,"run11_beam_parameters.root");
00191     }
00192     else if (nu.runPeriod == 13){
00193       wc = this->GetSKZPWeightCalculator2018(nu,"run13_beam_parameters.root");
00194     }
00195   }
00196   else {
00197     wc=this->GetSKZPWeightCalculator(nu);
00198   }
00199   
00200   GetWeights(nu, *wc, true);
00201   // Protect people's gDirectory from being unexpectedly stomped on
00202   restore->cd();
00203 }

void NuZBeamReweight::GetRFWeights ( NuEvent nu,
SKZPWeightCalculator wc 
) const [private]

Definition at line 917 of file NuZBeamReweight.cxx.

References NuEvent::beamWeight, NuEvent::detectorWeightNM, NuEvent::detectorWeightNMB, NuEvent::fluxErr, Msg::kInfo, MSG, NuEvent::shwEnWeight, and NuEvent::trkEnWeight.

00918 {
00919   MSG("NuZBeamReweight",Msg::kInfo) << "Older run faction weights are no longer "
00920   << "supported, not getting any weights." << endl;
00921   
00922   nu.trkEnWeight       = 1;
00923   nu.shwEnWeight       = 1;
00924   nu.beamWeight        = 1;
00925   nu.fluxErr           = 1;
00926   nu.detectorWeightNMB = 1;
00927   nu.detectorWeightNM  = 1;
00928 }

SKZPWeightCalculator * NuZBeamReweight::GetSKZPWeightCalculator ( const NuEvent nu  )  const

Definition at line 208 of file NuZBeamReweight.cxx.

References AsString(), NuEvent::beamType, Msg::kDebug, Msg::kInfo, BeamType::kL010z185i, BeamType::kL010z185i_rev, SKZPWeightCalculator::kRunI, SKZPWeightCalculator::kRunII, MAXMSG, MSG, SKZPWeightCalculator::PrintReweightConfig(), NuEvent::reweightVersion, SKZPWeightCalculator::SetRunFrac(), and BeamType::ToZarko().

Referenced by ExtractZBeamReweight(), and GetBeamWeightsOnly().

00209 {
00210 
00211   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00212   <<"Loading normal weights"<<endl;
00213 
00214   //make a weight calculator, defining the skzp version to use
00215   static SKZPWeightCalculator* pwc=0;
00216 
00217   //create the weight calculator on the first call
00218   if (pwc==0) {
00219     //get a string of the reweightVersion
00220     string sReweightVersion=this->AsString
00221       (static_cast<SKZPWeightCalculator::SKZPConfig_t>
00222        (nu.reweightVersion));
00223     MSG("NuZBeamReweight",Msg::kInfo)
00224       <<"To access database, using the string="<<sReweightVersion<<endl;
00225 
00226     TDirectory* tmpd = gDirectory;
00227     MSG("NuZBeamReweight",Msg::kDebug)
00228       <<"TDirectory before Reweight is:"<<endl;
00229     tmpd->Print();
00230 
00231     //create the weight calculator
00232     //read constants from DB
00233     pwc=new SKZPWeightCalculator(sReweightVersion,true);
00234 
00235     // Can always do this since it will only be accessed when getting RFWeights
00236     //define and set the numbers of POTs in each run period
00237     //numbers from Andy Blakes minos-doc-3727
00238     Float_t potRunI=1.269e20;
00239     //runIIa=1.229
00240     //runIIb=0.721
00241     Float_t potRunII=1.950e20;
00242     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00243     <<"ExtractZBeamReweight: SetRunFrac w/ potRunI="<<potRunI
00244     <<", potRunII="<<potRunII<<endl;
00245 
00246     Int_t Ibeam;
00247     if (nu.beamType == BeamType::kL010z185i_rev) {
00248       MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00249       << "Changing beamtype from kL010z185i_rev to kL010z185i for SKZP weighting" << endl;
00250       Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(BeamType::kL010z185i));
00251     }
00252     else {
00253       Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(nu.beamType));
00254     }
00255 
00256 
00257     pwc->SetRunFrac(Ibeam,SKZPWeightCalculator::kRunI,potRunI);
00258     pwc->SetRunFrac(Ibeam,SKZPWeightCalculator::kRunII,potRunII);
00259 
00260     //print the config
00261     pwc->PrintReweightConfig(cout);
00262 
00263     MSG("NuZBeamReweight",Msg::kDebug)
00264       <<"TDirectory after building Zbeam and Zflux is:"<<endl;
00265     //gDirectory->Print();
00266     MSG("NuZBeamReweight",Msg::kDebug)
00267       <<"After reseting gDirectory its location is:"<<endl;
00268     gDirectory=tmpd;
00269     //gDirectory->Print();
00270   }
00271 
00272   return pwc;
00273 }

SKZPWeightCalculator * NuZBeamReweight::GetSKZPWeightCalculator2018 ( const NuEvent nu,
TString  bfilename,
TString  hfilename = "hadron_parameters_2018.root",
TString  dir = "" 
) const

Definition at line 396 of file NuZBeamReweight.cxx.

References AsString(), base, NuEvent::beamType, SKZPWeightCalculator::ChangeParameters(), SKZPWeightCalculator::GetZbeam(), gSystem(), Msg::kDebug, Msg::kFatal, Msg::kInfo, BeamType::kL010z185i, BeamType::kL010z185i_rev, SKZPWeightCalculator::kRunI, SKZPWeightCalculator::kRunII, MAXMSG, MSG, SKZPWeightCalculator::PrintReweightConfig(), ReadParameters(), NuEvent::reweightVersion, Zbeam::SetReweightConfig(), SKZPWeightCalculator::SetRunFrac(), and BeamType::ToZarko().

Referenced by GetBeamWeightsOnly().

00397 {
00398 
00399     // Protect people's gDirectory from being unexpectedly stomped on
00400     TDirectory* restore = gDirectory;
00401 
00402   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00403   <<"Loading normal weights"<<endl;
00404 
00405 
00406   //make a weight calculator, defining the skzp version to use
00407   static SKZPWeightCalculator* pwc=0;
00408 
00409   //create the weight calculator on the first call
00410   if (pwc==0) {
00411     //get a string of the reweightVersion
00412     string sReweightVersion=this->AsString
00413       (static_cast<SKZPWeightCalculator::SKZPConfig_t>
00414        (nu.reweightVersion));
00415     MSG("NuZBeamReweight",Msg::kInfo)
00416       <<"Reweight, using the string="<<sReweightVersion<<endl;
00417 
00418     TDirectory* tmpd = gDirectory;
00419     MSG("NuZBeamReweight",Msg::kDebug)
00420       <<"TDirectory before Reweight is:"<<endl;
00421     //tmpd->Print();
00422 
00423 
00424     //create the weight calculator
00425     //read constants from DB
00426     pwc=new SKZPWeightCalculator(sReweightVersion,false);
00427 
00428     std::vector<double> beam_pars;
00429     std::vector<double> had_pars;
00430     std::vector<double> det_pars;
00431 
00432 
00433 
00434     // fTopDir is where the beamsys_XYZ.root file is located.
00435     std::string fTopDir=dir.Data(); // user may set location of input data
00436     if(fTopDir=="") { // by default, this code looks in a standard place
00437       fTopDir="MCReweight/data";
00438       std::string base="";
00439       base=getenv("SRT_PRIVATE_CONTEXT");
00440       if (base!="" && base!=".")
00441         {
00442           // check if directory exists in SRT_PRIVATE_CONTEXT
00443           std::string path = base + "/" + fTopDir;
00444           void *dir_ptr = gSystem->OpenDirectory(path.c_str());
00445           if(!dir_ptr) base=getenv("SRT_PUBLIC_CONTEXT"); // if it doesn't exist then use SRT_PUBLIC_CONTEXT
00446         }
00447       else base=getenv("SRT_PUBLIC_CONTEXT");
00448 
00449       if(base=="") {
00450         MSG("NuZBeamReweight",Msg::kFatal)<<"No SRT_PUBLIC_CONTEXT set."<<std::endl;
00451         assert(false);
00452       }
00453       fTopDir = base+ "/" + fTopDir;
00454     }
00455     MSG("NuZBeamReweight",Msg::kDebug) << " Getting SKZP Parameters from: "
00456                                             << fTopDir << " directory." << endl;
00457 
00458     TString hfilepath; 
00459     hfilepath.Form("%s/%s",fTopDir.c_str(),hfilename.Data());
00460 
00461     TString bfilepath; 
00462     bfilepath.Form("%s/%s",fTopDir.c_str(),bfilename.Data());    
00463 
00464     beam_pars = ReadParameters(bfilepath);
00465 
00466     had_pars = ReadParameters(hfilepath);
00467     
00468     pwc->ChangeParameters(&beam_pars,&had_pars,&det_pars);
00469     
00470     pwc->GetZbeam()->SetReweightConfig(sReweightVersion);
00471 
00472     // Can always do this since it will only be accessed when getting RFWeights
00473     //define and set the numbers of POTs in each run period
00474     //numbers from Andy Blakes minos-doc-3727
00475     Float_t potRunI=1.269e20;
00476     //runIIa=1.229
00477     //runIIb=0.721
00478     Float_t potRunII=1.950e20;
00479     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00480     <<"ExtractZBeamReweight: SetRunFrac w/ potRunI="<<potRunI
00481     <<", potRunII="<<potRunII<<endl;
00482 
00483     Int_t Ibeam;
00484     if (nu.beamType == BeamType::kL010z185i_rev) {
00485       MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00486       << "Changing beamtype from kL010z185i_rev to kL010z185i for SKZP weighting" << endl;
00487       Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(BeamType::kL010z185i));
00488     }
00489     else {
00490       Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(nu.beamType));
00491     }
00492 
00493 
00494     pwc->SetRunFrac(Ibeam,SKZPWeightCalculator::kRunI,potRunI);
00495     pwc->SetRunFrac(Ibeam,SKZPWeightCalculator::kRunII,potRunII);
00496 
00497     //print the config
00498     pwc->PrintReweightConfig(cout);
00499 
00500     MSG("NuZBeamReweight",Msg::kDebug)
00501       <<"TDirectory after building Zbeam and Zflux is:"<<endl;
00502     //gDirectory->Print();
00503     MSG("NuZBeamReweight",Msg::kDebug)
00504       <<"After reseting gDirectory its location is:"<<endl;
00505     gDirectory=tmpd;
00506     //gDirectory->Print();
00507   }
00508 
00509   // Protect people's gDirectory from being unexpectedly stomped on
00510   restore->cd();
00511 
00512   return pwc;
00513 }

SKZPWeightCalculator * NuZBeamReweight::GetSKZPWeightCalculatorCustom (  )  const

Definition at line 278 of file NuZBeamReweight.cxx.

References SKZPWeightCalculator::ChangeParameters(), det, Msg::kDebug, Msg::kInfo, BeamType::kL010z185i, SKZPWeightCalculator::kRunI, SKZPWeightCalculator::kRunII, MAXMSG, MSG, SKZPWeightCalculator::PrintReweightConfig(), SKZPWeightCalculator::SetRunFrac(), and BeamType::ToZarko().

Referenced by ExtractZBeamReweight(), and GetWeightHelium().

00279 {
00280   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00281   <<"Loading numu-only weights"<<endl;
00282 
00283   //make a weight calculator, defining the skzp version to use
00284   static SKZPWeightCalculator* pwc=0;
00285 
00286   //create the weight calculator on the first call
00287   if (pwc==0) {
00288 
00289     TDirectory* tmpd = gDirectory;
00290     MSG("NuZBeamReweight",Msg::kDebug) <<"TDirectory before Reweight is:"<<endl;
00291 
00292     //create the weight calculator
00293     //read constants from DB
00294     pwc=new SKZPWeightCalculator("DetXs",true);
00295 
00296     pwc->PrintReweightConfig(cout);
00297 
00298     std::vector<double> beam;
00299     std::vector<double> fluk;
00300     std::vector<double> det;
00301 
00302     MSG("NuZBeamReweight",Msg::kInfo) << std::endl;
00303     MSG("NuZBeamReweight",Msg::kInfo) << "Setting new target positions." << std::endl;
00304 
00305     // target positions
00306     beam.push_back(1.52410);
00307     beam.push_back(-3.34533);
00308     beam.push_back(-3.68550);
00309     beam.push_back(0.177135);
00310     beam.push_back(-1.73917);
00311     beam.push_back(-0.0842292);
00312 
00313     MSG("NuZBeamReweight",Msg::kInfo) << std::endl;
00314     MSG("NuZBeamReweight",Msg::kInfo) << "Setting new hadron production parameters." << std::endl;
00315 
00316     // pi+
00317     fluk.push_back(0.53363);
00318     fluk.push_back(-4.09962);
00319     fluk.push_back(0.959969);
00320     fluk.push_back(0.464735);
00321     fluk.push_back(0.948545);
00322     fluk.push_back(1.22209);
00323 
00324     // K+
00325     fluk.push_back(5.69124);
00326     fluk.push_back(17.4408);
00327     fluk.push_back(1.49750);
00328     fluk.push_back(0.972495);
00329     fluk.push_back(0.968975);
00330     fluk.push_back(2.19318);
00331 
00332     // pi-
00333     fluk.push_back(1.05039);
00334     fluk.push_back(-0.867787);
00335 
00336     // K-
00337     fluk.push_back(0.842913);
00338     fluk.push_back(0.0595505);
00339 
00340     MSG("NuZBeamReweight",Msg::kInfo) << std::endl;
00341     MSG("NuZBeamReweight",Msg::kInfo) << "Setting new detector parameters." << std::endl;
00342 
00343     // detector parameters
00344     det.push_back(-0.0183836);
00345     det.push_back(-0.244669);
00346     det.push_back(0.0); // numubar NC at nominal
00347     det.push_back(1.0); // numubar CC xsec at nominal
00348     det.push_back(0.342342);
00349     det.push_back(0.00517944);
00350     det.push_back(0.389318);
00351     det.push_back(-0.136436);
00352 
00353     MSG("NuZBeamReweight",Msg::kInfo) << std::endl;
00354     MSG("NuZBeamReweight",Msg::kInfo) << "Calling change parameters." << std::endl;
00355 
00356     pwc->ChangeParameters(&beam,&fluk,&det);
00357 
00358     MSG("NuZBeamReweight",Msg::kInfo) << std::endl;
00359     MSG("NuZBeamReweight",Msg::kInfo) << "Changed parameters, new configuration:" << std::endl;
00360     MSG("NuZBeamReweight",Msg::kInfo) << std::endl;
00361 
00362 
00363     // Can always do this since iy will only be accessed when getting RFWeights
00364     //define and set the numbers of POTs in each run period
00365     //numbers from Andy Blakes minos-doc-3727
00366     Float_t potRunI=1.269e20;
00367     //runIIa=1.229
00368     //runIIb=0.721
00369     Float_t potRunII=1.950e20;
00370     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00371     <<"ExtractZBeamReweight: SetRunFrac w/ potRunI="<<potRunI
00372     <<", potRunII="<<potRunII<<endl;
00373     const Int_t Ibeam=BeamType::ToZarko(BeamType::kL010z185i);
00374     pwc->SetRunFrac(Ibeam,SKZPWeightCalculator::kRunI,potRunI);
00375     pwc->SetRunFrac(Ibeam,SKZPWeightCalculator::kRunII,potRunII);
00376 
00377 
00378     //print the config
00379     pwc->PrintReweightConfig(cout);
00380 
00381     MSG("NuZBeamReweight",Msg::kDebug)
00382     <<"TDirectory after building Zbeam and Zflux is:"<<endl;
00383     //gDirectory->Print();
00384     MSG("NuZBeamReweight",Msg::kDebug)
00385     <<"After reseting gDirectory its location is:"<<endl;
00386     gDirectory=tmpd;
00387     //gDirectory->Print();
00388   }
00389 
00390   return pwc;
00391 }

double NuZBeamReweight::GetWeightHelium ( NuEvent nu  )  const

Definition at line 645 of file NuZBeamReweight.cxx.

References NuEvent::beamType, det, NuEvent::detector, SKZPWeightCalculator::GetHeliumWeight(), ReleaseType::GetMCSubVersion(), GetSKZPWeightCalculatorCustom(), NuEvent::inu, ReleaseType::IsDaikon(), Msg::kInfo, BeamType::kL010z185i, BeamType::kL010z185i_rev, Msg::kWarning, MAXMSG, NuEvent::neuEnMC, NuUtilities::PrintRelease(), NuEvent::releaseType, and BeamType::ToZarko().

Referenced by NuDSTAna::MakeMicroDstHe(), and NuDSTAna::RHCTest().

00646 {
00647   if (ReleaseType::IsDaikon(nu.releaseType) &&
00648       ReleaseType::GetMCSubVersion(nu.releaseType) > 4) {
00649     MAXMSG("NuZBeamReweight",Msg::kWarning, 10)
00650     << "Asking for He weights for releaseType = "
00651     << NuUtilities::PrintRelease(nu.releaseType)
00652     << " -- He should already be accounted for.  Returning 1." << endl;
00653     return 1;
00654   }
00655 
00656   // It doesn't matter which weight calculator we get
00657   SKZPWeightCalculator *wc = this->GetSKZPWeightCalculatorCustom();
00658 
00659   int inu = nu.inu;
00660   double E = nu.neuEnMC;
00661   int det = nu.detector;
00662   int Ibeam;
00663   if (nu.beamType == BeamType::kL010z185i_rev) {
00664     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00665     << "Changing beamtype from kL010z185i_rev to kL010z185i for SKZP weighting" << endl;
00666     Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(BeamType::kL010z185i));
00667     inu *= -1;
00668   }
00669   else {
00670     Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(nu.beamType));
00671   }
00672 
00673 
00674   return wc->GetHeliumWeight(det, Ibeam, inu, E);
00675 }

void NuZBeamReweight::GetWeights ( NuEvent nu,
SKZPWeightCalculator wc,
SKZPWeightCalculator::RunPeriod_t  rp,
bool  beamOnly = false 
) const [private]

int ccnc, double true_enu,int inu,

Definition at line 776 of file NuZBeamReweight.cxx.

References NuEvent::beamType, NuEvent::beamWeight, NuEvent::detector, NuEvent::detectorWeightNM, NuEvent::detectorWeightNMB, NuEvent::fluxErr, SKZPWeightCalculator::GetBeamWeight(), SKZPWeightCalculator::GetFluxError(), SKZPWeightCalculator::GetWeight(), NuEvent::iaction, NuEvent::inu, Msg::kDebug, Msg::kInfo, BeamType::kL010z185i, BeamType::kL010z185i_rev, SKZPWeightCalculator::kMINOSplus_2018, MAXMSG, MCEventInfoFilla(), NuEvent::neuEnMC, NuEvent::ppdxdz, NuEvent::ppdydz, NuEvent::pppz, NuEvent::ptype, NuEvent::reweightVersion, SKZPWeightCalculator::SetSampleSelection(), NuEvent::shwEn, NuEvent::shwEnMC, NuEvent::shwEnWeight, BeamType::ToZarko(), NuEvent::tptype, NuEvent::tpx, NuEvent::tpy, NuEvent::tpz, NuEvent::trkEn, NuEvent::trkEnWeight, and MCEventInfo::UseStoredXSec().

00779 {
00780   //fill MCEventInfo
00781   MCEventInfo ei;
00782   if (!beamOnly) {
00783     ei.UseStoredXSec(true);
00784     this->MCEventInfoFilla(&ei,nu);
00785   }
00786 
00787   //convert the std BeamType into Zarko's convention
00788   //was 2=le010z185i (Zbeam.h)
00789   Int_t Ibeam;
00790   if (nu.beamType == BeamType::kL010z185i_rev) {
00791     MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00792     << "Changing beamtype from kL010z185i_rev to kL010z185i for SKZP weighting" << endl;
00793     Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(BeamType::kL010z185i));
00794   }
00795   else {
00796     Ibeam = BeamType::ToZarko(static_cast<BeamType::BeamType_t>(nu.beamType));
00797   }
00798 
00799   //copied from SKZPWeightCalculator
00800   Int_t ccnc=nu.iaction;
00801   Double_t true_enu=nu.neuEnMC;//p4neu[3]
00802   Double_t true_eshw=nu.shwEnMC;//p4shw[3]
00803   Int_t inu=nu.inu;
00804   Float_t nsigma=1;
00805   //FUTURE VERSIONS may use this:
00806   //parenttype = fi->ptype;
00807   //parentpz = 1.*fi->pppz;
00808   //parentpy = 1.*fi->ppdydz*parentpz;
00809   //parentpx = 1.*fi->ppdxdz*parentpz;
00810   Int_t parenttype = nu.tptype;
00811   Double_t parentpz = nu.tpz;
00812   Double_t parentpy = nu.tpy;
00813   Double_t parentpx = nu.tpx;
00814   Double_t pt = sqrt(parentpy*parentpy+parentpx*parentpx);
00815 
00816   //create variables that are passed by reference to function to fill
00817   Double_t new_reco_emu=0;
00818   Double_t new_reco_eshw=0;
00819   Double_t beamweight=0;
00820   Double_t detweightNMB=0;
00821   Double_t detweightNM=0;
00822   Float_t trkEnWeight=1;
00823   Float_t shwEnWeight=1;
00824 
00825   if (beamOnly) {
00826     // Get only the beam weights
00827     if(nu.reweightVersion == SKZPWeightCalculator::kMINOSplus_2018 && (parenttype==2212 || parenttype==14)){
00828       parenttype = nu.ptype;
00829       parentpz = nu.pppz;
00830       parentpy = nu.ppdydz*nu.pppz;
00831       parentpx = nu.ppdxdz*nu.pppz;
00832       pt = sqrt(nu.ppdydz*nu.ppdydz+nu.ppdxdz*nu.ppdxdz)*parentpz;//how it is calculated in the beam fit
00833     }
00834     beamweight = wc.GetBeamWeight(nu.detector, Ibeam, parenttype, pt,
00835                                   parentpz, true_enu, inu, rp);
00836   }
00837   else {
00838     // Get the skzp weights (beam and detector)
00839     wc.SetSampleSelection("NuMuBar");
00840     wc.GetWeight(nu.detector,Ibeam,
00841                  parenttype,pt,parentpz,ccnc,true_enu,inu,
00842                  nu.trkEn,nu.shwEn,new_reco_emu,new_reco_eshw,
00843                  beamweight,detweightNMB,rp,true_eshw,&ei);
00844 
00845 
00846 
00847     MAXMSG("NuZBeamReweight",Msg::kDebug,200)
00848     <<endl<<"iaction="<<nu.iaction
00849     <<", nu.trkEn="<<nu.trkEn<<", nu.shwEn="<<nu.shwEn<<endl;
00850 
00851     MAXMSG("NuZBeamReweight",Msg::kDebug,200)
00852     <<"NMB: newEmu="<<new_reco_emu
00853     <<", newEShw="<<new_reco_eshw
00854     <<", detNMB="<<detweightNMB
00855     <<", beamW="<<beamweight<<endl;
00856 
00857     //get the skzp weights (beam and detector)
00858     wc.SetSampleSelection("NuMu");
00859     wc.GetWeight(nu.detector,Ibeam,
00860                  parenttype,pt,parentpz,ccnc,true_enu,inu,
00861                  nu.trkEn,nu.shwEn,new_reco_emu,new_reco_eshw,
00862                  beamweight,detweightNM,rp,true_eshw,&ei);
00863 
00864     MAXMSG("NuZBeamReweight",Msg::kDebug,200)
00865     <<"NM:  newEmu="<<new_reco_emu
00866     <<", newEshw="<<new_reco_eshw
00867     <<",  detNM="<<detweightNM
00868     <<", beamW="<<beamweight<<endl;
00869 
00870     //new for kDetXs
00871     //double GetWeight(int det, int Ibeam,
00872     //     int tptype, double pt, double pz,
00874     //     double reco_emu, double reco_eshw,
00875     //     double &new_reco_emu, double &new_reco_eshw,
00876     //     double &beamweight, double &detweight,
00877     //     RunPeriod_t rp=kRunI,double true_eshw=-1,MCEventInfo *ei=0);
00878 
00879     if (nu.trkEn) trkEnWeight=new_reco_emu/nu.trkEn;
00880     if (nu.shwEn) shwEnWeight=new_reco_eshw/nu.shwEn;
00881   }
00882 
00883   //get the flux errors
00884   Float_t fluxErr = wc.GetFluxError(nu.detector,Ibeam,inu,true_enu, rp, nsigma);  
00885   
00886   
00887   MAXMSG("NuZBeamReweight",Msg::kDebug,300)
00888   << "Wgts for run " << (int)rp
00889   << ", b="   << beamweight
00890   << ", dNMB="<< detweightNMB
00891   << ", dNM=" << detweightNM
00892   << ", trk=" << trkEnWeight
00893   << ", shw=" << shwEnWeight
00894   << endl
00895   << "energyMC="  << nu.neuEnMC
00896   << ", iaction=" << nu.iaction
00897   << ", inu="     << nu.inu
00898   << endl
00899   << "fluxErr=" << fluxErr << endl
00900   << endl;  
00901   
00902   nu.beamWeight = beamweight;
00903   nu.fluxErr    = fluxErr;
00904   
00905   if (!beamOnly) {
00906     nu.trkEnWeight                = trkEnWeight;
00907     nu.shwEnWeight                = shwEnWeight;
00908     nu.detectorWeightNMB          = detweightNMB;
00909     nu.detectorWeightNM           = detweightNM;
00910   }
00911 
00912 }

void NuZBeamReweight::GetWeights ( NuEvent nu,
SKZPWeightCalculator wc,
bool  beamOnly = false 
) const [private]

Definition at line 741 of file NuZBeamReweight.cxx.

References Msg::kError, Msg::kInfo, SKZPWeightCalculator::kNone, SKZPWeightCalculator::kRunI, SKZPWeightCalculator::kRunII, SKZPWeightCalculator::kRunIII, SKZPWeightCalculator::kRunIV, SKZPWeightCalculator::kRunIX, SKZPWeightCalculator::kRunV, SKZPWeightCalculator::kRunVI, SKZPWeightCalculator::kRunVII, SKZPWeightCalculator::kRunVIII, SKZPWeightCalculator::kRunX, SKZPWeightCalculator::kRunXI, SKZPWeightCalculator::kRunXII, SKZPWeightCalculator::kRunXIII, Msg::kWarning, MAXMSG, MSG, and NuEvent::runPeriod.

Referenced by ExtractZBeamReweight(), and GetBeamWeightsOnly().

00742 {
00743   if (nu.runPeriod <= 0) {
00744     MSG("NuZBeamReweight",Msg::kError) << "Run period not specified in NuEvent -- GetWeights failing." << endl;
00745     return;
00746   }
00747   MAXMSG("NuZBeamReweight",Msg::kInfo,1)
00748   <<"Getting Daikon07+ era weights for nu.runPeriod="<< nu.runPeriod <<endl;
00749   
00750   SKZPWeightCalculator::RunPeriod_t rp = SKZPWeightCalculator::kNone;
00751   if (nu.runPeriod == 1) rp = SKZPWeightCalculator::kRunI;
00752   else if (nu.runPeriod == 2) rp = SKZPWeightCalculator::kRunII;
00753   else if (nu.runPeriod == 3) rp = SKZPWeightCalculator::kRunIII;
00754   else if (nu.runPeriod == 4) rp = SKZPWeightCalculator::kRunIV;
00755   else if (nu.runPeriod == 5) rp = SKZPWeightCalculator::kRunV;
00756   else if (nu.runPeriod == 6) rp = SKZPWeightCalculator::kRunVI;
00757   else if (nu.runPeriod == 7) rp = SKZPWeightCalculator::kRunVII;
00758   else if (nu.runPeriod == 8) rp = SKZPWeightCalculator::kRunVIII;
00759   else if (nu.runPeriod == 9) rp = SKZPWeightCalculator::kRunIX;
00760   else if (nu.runPeriod == 10) rp = SKZPWeightCalculator::kRunX;
00761   else if (nu.runPeriod == 11) rp = SKZPWeightCalculator::kRunXI;
00762   else if (nu.runPeriod == 12) rp = SKZPWeightCalculator::kRunXII;
00763   else if (nu.runPeriod == 13) rp = SKZPWeightCalculator::kRunXIII;
00764   else{
00765     MSG("NuZBeamReweight", Msg::kWarning)
00766       << "Unrecognised run period for SKZP weighting. Asserting here."
00767       << endl;
00768     assert(false);
00769   }
00770 
00771   this->GetWeights(nu, wc, rp, beamOnly);
00772 }

void NuZBeamReweight::MCEventInfoFilla ( MCEventInfo ei,
const NuEvent nu 
) const [private]

this is basically ripped from ReweightHelpers::MCEventInfoFilla it relies on initialState, nucleus and hfs determined in NuReco

Definition at line 997 of file NuZBeamReweight.cxx.

References MCEventInfo::had_fs, NuEvent::hadronicFinalStateMC, NuEvent::iaction, MCEventInfo::iaction, MCEventInfo::initial_state, NuEvent::initialStateMC, NuEvent::inu, MCEventInfo::inu, NuEvent::iresonance, MCEventInfo::iresonance, Msg::kDebug, MAXMSG, NuEvent::neuEnMC, NuEvent::neuPxMC, NuEvent::neuPyMC, NuEvent::neuPzMC, MCEventInfo::nucleus, NuEvent::nucleusMC, MCEventInfo::nuE, MCEventInfo::nuPx, MCEventInfo::nuPy, MCEventInfo::nuPz, MCEventInfo::q2, NuEvent::q2MC, MCEventInfo::tarE, MCEventInfo::tarPx, MCEventInfo::tarPy, MCEventInfo::tarPz, NuEvent::tgtEnMC, NuEvent::tgtPxMC, NuEvent::tgtPyMC, NuEvent::tgtPzMC, MCEventInfo::w2, NuEvent::w2MC, MCEventInfo::x, NuEvent::xMC, MCEventInfo::y, and NuEvent::yMC.

Referenced by CalcGeneratorReweight(), and GetWeights().

00999 {
01002 
01003   ei->nuE=nu.neuEnMC;
01004   ei->nuPx=nu.neuPxMC;
01005   ei->nuPy=nu.neuPyMC;
01006   ei->nuPz=nu.neuPzMC;
01007 
01008   ei->tarE=nu.tgtEnMC;
01009   ei->tarPx=nu.tgtPxMC;
01010   ei->tarPy=nu.tgtPyMC;
01011   ei->tarPz=nu.tgtPzMC;
01012 
01013   ei->y=nu.yMC;
01014   ei->x=nu.xMC;
01015   ei->q2=nu.q2MC;
01016   ei->w2=nu.w2MC;
01017 
01018   ei->iaction=nu.iaction;
01019   ei->inu=nu.inu;
01020   ei->iresonance=nu.iresonance;
01021   ei->initial_state=nu.initialStateMC;
01022 
01023   ei->nucleus=nu.nucleusMC;
01024 
01025   ei->had_fs=nu.hadronicFinalStateMC;
01026 
01027 
01028   MAXMSG("NuZBeamReweight",Msg::kDebug,100)
01029     <<endl<<endl
01030     <<", ei->nuE="<<ei->nuE
01031     <<", ei->nuPx="<<ei->nuPx
01032     <<", ei->nuPy="<<ei->nuPy
01033     <<", ei->nuPz="<<ei->nuPz
01034     <<endl
01035     <<", ei->tarE="<<ei->tarE
01036     <<", ei->tarPx="<<ei->tarPx
01037     <<", ei->tarPy="<<ei->tarPy
01038     <<", ei->tarPz="<<ei->tarPz
01039     <<endl
01040     <<", ei->y="<<ei->y<<endl
01041     <<", ei->x="<<ei->x<<endl
01042     <<", ei->q2="<<ei->q2<<endl
01043     <<", ei->w2="<<ei->w2<<endl
01044     <<endl
01045     <<", ei->iaction="<<ei->iaction<<endl
01046     <<", ei->inu="<<ei->inu<<endl
01047     <<", ei->iresonance="<<ei->iresonance<<endl
01048     <<", ei->initial_state="<<ei->initial_state<<endl
01049     <<", ei->nucleus="<<ei->nucleus<<endl
01050     <<", ei->had_fs="<<ei->had_fs<<endl
01051     <<endl;
01052 }

std::vector< double > NuZBeamReweight::ReadParameters ( TString  filename  )  const [private]

Definition at line 1078 of file NuZBeamReweight.cxx.

Referenced by GetSKZPWeightCalculator2018().

01078                                                                        {
01079 
01080   TFile* f = new TFile(filename.Data());
01081 
01082   TTree *infotree = (TTree *)f->Get("info");
01083   int npar;
01084 
01085   infotree->SetBranchAddress("npar",&npar);
01086 
01087   infotree->GetEntry(0);
01088   const int npars = npar;
01089   const int MAXNPARS=20;
01090   double par[MAXNPARS];
01091 
01092   for(int i=0;i<npars;i++){
01093     char pn[100];
01094     sprintf(pn,"par_%d",i);
01095     infotree->SetBranchAddress(pn,&par[i]);
01096   }
01097   infotree->GetEntry(0);
01098 
01099   std::vector<double> parameters;
01100 
01101   for (int i = 0; i<npars;i++){
01102     parameters.push_back(par[i]);
01103   }
01104 
01105   return parameters;
01106 
01107 }


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

Generated on 13 Nov 2018 for loon by  doxygen 1.6.1