Classes | Functions | Variables
ana2019::fakedata Namespace Reference

Classes

class  EvtHashRNG
 base class: random number generator with easily settable seed... More...
 
class  KeepEvtFunc
 
class  KeepMCEventFunc
 

Functions

void SetAna2018Calc (osc::IOscCalculatorAdjustable &calc)
 
std::map< std::string, std::unique_ptr< Spectrum > > Get2019Prediction (osc::IOscCalculator *calc, EAnaType2018 analysis, BeamType2018 beam, int quartileIfNumu=-1, bool asimov=false)
 

Variables

const double FULL_RHC_EXPOSURE = 12e20
 
const int NUM_FAKEDATA_THROWS = 100
 
const std::string OUT_FILE_STUB = "fake_fd_events_2019_%s.root"
 

Function Documentation

std::map<std::string, std::unique_ptr<Spectrum> > ana2019::fakedata::Get2019Prediction ( osc::IOscCalculator calc,
EAnaType2018  analysis,
BeamType2018  beam,
int  quartileIfNumu = -1,
bool  asimov = false 
)

Get a mock FD data spectrum based on the observed 2018 data spectra plus predictions for the 2019 additional exposure based on the 2018 best fit

Definition at line 117 of file generate_fake_data.C.

References POTSpillRate::beam, make_associated_cosmic_defs::cosmics, om::cout, allTimeWatchdog::endl, ana::Spectrum::FakeData(), FULL_RHC_EXPOSURE, ana::kAna2018RHCLivetime, ana::kAna2018RHCPOT, ana2019::kCosmicSpectra, ana2019::kDataSpectra, ana::kFHC, ana::kLivetime, ana::kNumuAna2018, ana::kPOT, ana2019::kPredictions, ana::Spectrum::MockData(), ana::Spectrum::OverridePOT(), plot_validation_datamc::pred, ana::IPrediction::Predict(), and runNovaSAM::ret.

Referenced by generate_fake_data().

122  {
123  std::map<std::string, std::unique_ptr<Spectrum>> ret;
124  ret.emplace("2018_data", std::make_unique<Spectrum>(kDataSpectra.Get(analysis, beam, quartileIfNumu)));
125 
126  // always start with the 2018 data
127  ret.emplace("2019_totalPred", std::make_unique<Spectrum>(*ret.at("2018_data")));
128 
129  // FHC will be unchanged for 2019
130  if (beam == kFHC)
131  return ret;
132 
133  std::cout << "analysis = " << analysis << ", beam = " << beam;
134  if (analysis == kNumuAna2018)
135  std::cout << ", quartile = " << quartileIfNumu;
136  std::cout << std::endl;
137 
138  // start with the data spectrum
139  auto & sumPred = ret.at("2019_totalPred");
140 
141  std::cout << " original data spectrum = " << ret.at("2018_data")->Integral(ret.at("2018_data")->POT(), nullptr, kPOT) << " events"
142  << " (" << kAna2018RHCPOT << " POT, " << kAna2018RHCLivetime << "s live)" << std::endl;
143 
144  // we are going to eventually have a spectrum at the new exposure.
145  // (anything we make below needs to have this same exposure, or it will wind up scaled to it...)
146  double scaleFactor = FULL_RHC_EXPOSURE / kAna2018RHCPOT;
147  sumPred->OverridePOT(FULL_RHC_EXPOSURE);
148 
149  // this cosmic spectrum was created from kAna2018RHCLivetime.
150  Spectrum cosmicsPred(kCosmicSpectra.Get(analysis, beam, quartileIfNumu));
151  cosmicsPred.OverridePOT(kAna2018RHCPOT * cosmicsPred.Livetime()/kAna2018RHCLivetime); // have to use POT for MockData()
152  std::cout << " (cosmics for 2018 RHC livetime: "
153  << cosmicsPred.Integral(kAna2018RHCLivetime, 0, kLivetime) << ")" << std::endl;
154 
155  double newPOT = (scaleFactor - 1) * kAna2018RHCPOT;
156  ret.emplace("2019_cosmicsPred", std::make_unique<Spectrum>(asimov ? cosmicsPred.FakeData(newPOT)
157  : cosmicsPred.MockData(newPOT)));
158  auto & cosmics = ret.at("2019_cosmicsPred");
159  // if its internal POT is different than that of 'ret'
160  // when we go to add it, this spectrum will be scaled so that
161  // its POT matches 'ret' before adding.
162  // since we've now produced the prediction at the correct exposure,
163  // we don't want it being rescaled, so just make its POT match
164  // and zero off its livetime so that its livetime isn't used at all.
165  cosmics->OverridePOT(FULL_RHC_EXPOSURE);
166  cosmics->OverrideLivetime(0);
167  *sumPred += *cosmics;
168 
169  std::cout << " cosmics = " << cosmics->Integral(cosmics->POT()) << " events"
170  << " (" << (scaleFactor - 1) * kAna2018RHCLivetime << "s live)" << std::endl;
171 
172  // finally, the beam prediction for the new exposure.
173  // this has to be overridden to the total exposure also
174  // so that it is added to 'ret' without rescaling
175  const IPrediction & pred = kPredictions.Get(analysis, beam, quartileIfNumu);
176  double newDataPOT = (scaleFactor-1)/scaleFactor * FULL_RHC_EXPOSURE;
177  if (asimov)
178  ret.emplace("2019_beamPred", std::make_unique<Spectrum>(pred.Predict(calc).FakeData(newDataPOT)));
179  else
180  ret.emplace("2019_beamPred", std::make_unique<Spectrum>(pred.Predict(calc).MockData(newDataPOT)));
181  auto & fakeData = ret.at("2019_beamPred");
182  fakeData->OverridePOT(FULL_RHC_EXPOSURE);
183  *sumPred += *fakeData;
184 
185  std::cout << " new " << (asimov ? "Asimov" : "fake") << " data = "
186  << fakeData->Integral(fakeData->POT(), nullptr, kPOT) << " events"
187  << " (" << (scaleFactor-1)/scaleFactor * FULL_RHC_EXPOSURE << " POT)" << std::endl;
188 
189  std::cout << " new total = " << sumPred->Integral(sumPred->POT(), nullptr, kPOT) << " events" << std::endl;
190 
191  return std::move(ret);
192  } // Get2019Prediction()
const TieredAnaObjStorage< Spectrum > kDataSpectra([](const std::string &beamStr){return GetNueData2018(beamStr);}, [](const std::string &beamStr){auto vec=GetNumuData2018(4, beamStr);std::vector< const Spectrum * > ret;ret.insert(ret.end(), vec.begin(), vec.end());return ret;})
void OverridePOT(double newpot)
DO NOT USE UNLESS YOU ARE 110% CERTAIN THERE ISN&#39;T A BETTER WAY!
Definition: Spectrum.h:269
const TieredAnaObjStorage< IPrediction > kPredictions([](const std::string &beamStr){return GetNuePrediction2018(beamStr=="fhc"?"combo":"prop", DefaultOscCalc(), false, beamStr, false);}, [](const std::string &beamStr){return GetNumuPredictions2018(4, false, beamStr);})
virtual Spectrum Predict(osc::IOscCalculator *calc) const =0
Representation of a spectrum in any variable, with associated POT.
Definition: Spectrum.h:37
const double kAna2018RHCPOT
Definition: Exposures.h:208
const double FULL_RHC_EXPOSURE
Definition: fake_data.h:17
Spectrum FakeData(double pot) const
Fake data is a MC spectrum scaled to the POT expected in the data.
Definition: Spectrum.cxx:830
OStream cout
Definition: OStream.cxx:6
const TieredAnaObjStorage< Spectrum > kCosmicSpectra([](const std::string &beamStr){std::string name;std::string anaDir="/nova/ana/nu_e_ana/Ana2018/";if(beamStr=="rhc") name="cosmic_spect_rhc";else name="cosmic_spect_fhc";auto spec=LoadFromFile< Spectrum >(anaDir+"/Predictions/cosmic/cosmic_prediction_real_data.root", name).release();return spec;}, [](const std::string &beamStr){std::string dir="/nova/ana/nu_mu_ana/Ana2018/Cosmics/";std::string filename=(beamStr=="rhc")?"cosmics_rhc__numu2018.root":"cosmics_fhc__numu2018.root";auto fcosm=TFile::Open((dir+filename).c_str());if(fcosm->IsZombie()){std::cerr<< "bad cosmics\n";exit(1);}std::vector< const Spectrum * > numu_cosmics;for(int i=1;i<=4;++i) numu_cosmics.emplace_back(new Spectrum(dynamic_cast< TH1 * >(fcosm->Get(Form("cosmics_q%d", i))), 0, (beamStr=="rhc")?kAna2018RHCLivetime:kAna2018FHCLivetime));return numu_cosmics;})
Spectrum MockData(double pot, int idx=0) const
Mock data is FakeData with Poisson fluctuations applied.
Definition: Spectrum.cxx:798
Standard interface to all prediction techniques.
Definition: IPrediction.h:57
const double kAna2018RHCLivetime
Definition: Exposures.h:214
void ana2019::fakedata::SetAna2018Calc ( osc::IOscCalculatorAdjustable calc)

Definition at line 21 of file fake_data.h.

References dCP, dmsq32, ana::ResetOscCalcToDefault(), SetFakeCalc(), and ssth23.

Referenced by generate_fake_data().

22  {
24 
25  const double dCP = 0.186;
26  const double ssth23 = 0.585;
27  const double dmsq32 = 2.501e-3;
28 
29  SetFakeCalc(&calc, ssth23, dmsq32, dCP);
30  }
double ssth23
void ResetOscCalcToDefault(osc::IOscCalculatorAdjustable *calc)
Reset calculator to default assumptions for all parameters.
Definition: Calcs.cxx:23
double dCP
double dmsq32
void SetFakeCalc(osc::IOscCalculatorAdjustable *calc, double ssth23=-5, double dmsq32=-5, double dCP_Pi=-5)

Variable Documentation

const double ana2019::fakedata::FULL_RHC_EXPOSURE = 12e20

Definition at line 17 of file fake_data.h.

Referenced by generate_fd_fake_events(), and Get2019Prediction().

const int ana2019::fakedata::NUM_FAKEDATA_THROWS = 100

Definition at line 19 of file fake_data.h.

Referenced by generate_fake_data().

const std::string ana2019::fakedata::OUT_FILE_STUB = "fake_fd_events_2019_%s.root"

Definition at line 42 of file generate_fd_fake_events.C.

Referenced by generate_fd_fake_events().