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

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

Public Member Functions

 MultiExperiment (fhicl::ParameterSet const &pset)
 
 ~MultiExperiment ()
 
void Reconfigure (fhicl::ParameterSet const &pset)
 
void ApplyPoint (InputPoint &pInputPoint)
 
bool ApplyCorrelations (StringPointMap &pStringPointMap)
 
double FitValue ()
 
bool SetEventListMap (EventListMap const &pEventListMap)
 
const std::vector< std::unique_ptr< Experiment > > & ListExperiments () const
 
void DrawPlots (art::TFileDirectory *plotDir) const
 
void DrawParallelPlots (art::TFileDirectory *plotDir) const
 
void DrawFitterProgressGraphs (art::TFileDirectory *plotDir) const
 

Private Member Functions

void CreateNuisanceParameterExperiments ()
 

Private Attributes

bool fIsConfigured
 has the object been configured? More...
 
bool fNuisanceExMade
 have the NuisanceParameterExperiments been made? More...
 
std::vector< std::unique_ptr< Experiment > > fExperiments
 
std::vector< std::vector< double > > fSystUncCorrs
 
std::vector< FitIterationfIterations
 Attempted point and chi^2 for each iteration of the fit. More...
 
std::unique_ptr< CorrelationsfCorrelations
 

Detailed Description

Definition at line 31 of file MultiExperiment.h.

Constructor & Destructor Documentation

fnex::MultiExperiment::MultiExperiment ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 70 of file MultiExperiment.cxx.

References Reconfigure().

71  : fIsConfigured (false)
72  , fNuisanceExMade(false)
73  {
74  this->Reconfigure(pset);
75  }
bool fIsConfigured
has the object been configured?
bool fNuisanceExMade
have the NuisanceParameterExperiments been made?
void Reconfigure(fhicl::ParameterSet const &pset)
fnex::MultiExperiment::~MultiExperiment ( )
inline

Definition at line 37 of file MultiExperiment.h.

37 { };

Member Function Documentation

bool fnex::MultiExperiment::ApplyCorrelations ( StringPointMap pStringPointMap)

Definition at line 206 of file MultiExperiment.cxx.

References fCorrelations.

Referenced by ApplyPoint().

206  {
207 
208  //std::cout << " About to apply correlations \n";
209  //std::cout << pInputPoint << std::endl;
210  //this->ApplyCorrelations(pInputPoint);
211  //std::cout << " Already applied correlations \n";
212  //std::cout << pInputPoint << std::endl;
213 
214  fCorrelations->ApplyCorrelations(pStringPointMap);
215  return true;
216  }
std::unique_ptr< Correlations > fCorrelations
void fnex::MultiExperiment::ApplyPoint ( InputPoint pInputPoint)

Definition at line 169 of file MultiExperiment.cxx.

References ApplyCorrelations(), CreateNuisanceParameterExperiments(), stan::math::exp(), fExperiments, fIterations, fnex::ShifterAndWeighter::Instance(), it, and fnex::ShifterAndWeighter::SetCurrentVals().

Referenced by fnex::FitFunction_ForROOT(), and fnex::FitAlg_ROOTFactoryFit::LoadFinalResults().

170  {
171  // first attempt to make the Nuisance parameter experiments. The Create
172  // function returns if the fNuisanceExMade data member is true
174 
175  // Keep track of what the fitter is doing by making a vector of each
176  // input point and chi^2 value. Fill the chi^2 value in the FitValue method
177  // That method is called nearly right after this one, so the point and chi^2
178  // values should not get out of sync with each other
179  fIterations.emplace_back(pInputPoint, 0.);
180 
181 
182  // Create fExperiments.size() copies of this pInputPoint
183  StringPointMap tempStringPointMap;
184  for(auto & exp : fExperiments)
185  tempStringPointMap.emplace(exp->ShortName(), pInputPoint);
186 
187  // Apply correlations between them
188  this->ApplyCorrelations(tempStringPointMap);
189 
190  // Apply correlated point to each experiment
191  for(auto& it : fExperiments){
192  if(!it->IsConfigured()) continue;
193 
194  // we now have the next iteration, so update the shifter and weighter info
195  fnex::ShifterAndWeighter::Instance()->SetCurrentVals(tempStringPointMap[it->ShortName()]);
196 
197  it->ApplyPoint(tempStringPointMap[it->ShortName()]);
198  }
199 
200  // We're done here
201  return;
202 
203  }
void SetCurrentVals(fnex::InputPoint const &curPoint)
void CreateNuisanceParameterExperiments()
set< int >::iterator it
static ShifterAndWeighter * Instance()
std::vector< FitIteration > fIterations
Attempted point and chi^2 for each iteration of the fit.
std::vector< std::unique_ptr< Experiment > > fExperiments
bool ApplyCorrelations(StringPointMap &pStringPointMap)
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
std::map< std::string, InputPoint > StringPointMap
Definition: Correlations.h:23
void fnex::MultiExperiment::CreateNuisanceParameterExperiments ( )
private

Definition at line 80 of file MultiExperiment.cxx.

References fExperiments, fNuisanceExMade, fnex::NuisanceParameters::Instance(), LOG_VERBATIM, fnex::NuisanceParameters::NuisanceParameterInfo(), and fhicl::ParameterSet::put().

Referenced by ApplyPoint().

81  {
82  if(fNuisanceExMade) return;
83 
85 
86  for(auto const& itr : nuisancePars){
87 
88  LOG_VERBATIM("MultiExperiment")
89  << "Adding NuisanceParameter_experiment "
90  << "NP_" + itr.first;
91 
92  // make the parameter set for this NuisanceParameter_experiment
93  // and then add the experiment to the collection of experiments
95  pset.put("ShortName", "NP_" + itr.first );
96  pset.put("VarKey", itr.first );
97  pset.put("CentralValue", itr.second.fCentralValue);
98  pset.put("Variance", itr.second.fVariance );
99 
100  fExperiments.push_back(std::make_unique<fnex::NuisanceParameter_Experiment>(pset));
101  }
102 
103  fNuisanceExMade = true;
104 
105  return;
106  }
void put(std::string const &key)
std::vector< std::unique_ptr< Experiment > > fExperiments
bool fNuisanceExMade
have the NuisanceParameterExperiments been made?
std::map< std::string, NPInfo > const & NuisanceParameterInfo() const
#define LOG_VERBATIM(category)
static NuisanceParameters * Instance()
void fnex::MultiExperiment::DrawFitterProgressGraphs ( art::TFileDirectory plotDir) const

Definition at line 298 of file MultiExperiment.cxx.

References allTimeWatchdog::can, fd, fIterations, MECModelEnuComparisons::i, novadaq::cnv::kFARDET, LOG_DEBUG, art::TFileDirectory::make(), art::TFileDirectory::mkdir(), and string.

Referenced by fnex::FitAlgorithm::DrawPlots().

299  {
300  art::TFileDirectory itrDir = plotDir->mkdir( "MultiExperimentIterations" );
301 
302  std::string canvasname = "NOvAExperiment_";
303 
304  // get the lists of oscillation and systematic parameters
306  auto oscParDets = fIterations[0].point.FitParameters();
307  auto sysParDets = fIterations[0].point.FitSystematics();
308 
309  // first make the collections of TGraphs for oscillation and systematic
310  // parameters
311  std::map<ParameterDet, TGraph*> grMap;
312  for(auto itr : oscParDets){
313 
314  // do nothing if this parameter is not in the FD
315  if( itr.second != fd ) continue;
316 
317  grMap[itr] = itrDir.make<TGraph>(fIterations.size());
318  grMap[itr]->SetName((itr.first + "IterGraph").c_str());
319  grMap[itr]->SetTitle(itr.first.c_str());
320  grMap[itr]->SetMarkerStyle(20);
321  }
322  for(auto itr : sysParDets){
323 
324  // do nothing if this parameter is not in the FD
325  if( itr.second != fd ) continue;
326 
327  grMap[itr] = itrDir.make<TGraph>(fIterations.size());
328  grMap[itr]->SetName((itr.first + "IterGraph").c_str());
329  grMap[itr]->SetTitle(itr.first.c_str());
330  grMap[itr]->SetMarkerStyle(20);
331  }
332 
333  // Make the TGraph for the chi^2 values
334  TGraph* chisq_graph = itrDir.make<TGraph>(fIterations.size());
335  chisq_graph->SetName("IterGraphChiSqr");
336  chisq_graph->SetTitle("#chi^{2}");
337  chisq_graph->SetMarkerStyle(20);
338 
339  //loop over the iterations to fill the graphs
340  double parVal = 0.;
341  for(size_t i = 0; i < fIterations.size(); ++i){
342 
343  // get the value for each parameter we care about and put it into its
344  // graph
345  for(auto mapItr : grMap){
346  parVal = fIterations[i].point.ParameterValue(mapItr.first);
347 
348  mapItr.second->SetPoint(i, i * 1., parVal);
349  }
350  //TODO: remove following lines once you figure out that why the last point has a 0 chisq value.
351  //Print out some values of the chisq to find out that why there is an extra last entry
352  //with zero value of the chisq
353  LOG_DEBUG("MultiExperiment")
354  << "Fit Iteration step: "
355  << i
356  << " "
357  << " chisq value: "
358  << fIterations[i].chiSqr;
359 
360  // fill the chi^2 graph
361  chisq_graph->SetPoint(i, i * 1., fIterations[i].chiSqr);
362  } // end loop over iterations
363 
364  // now loop over the graphs and create a canvas for each
365  TCanvas* can = nullptr;
366 
367  for(auto mapItr : grMap){
368  canvasname = "ParameterIterationCanv_" + mapItr.first.first;
369  can = itrDir.make<TCanvas>(canvasname.data(), canvasname.data(), 800, 800);
370 
371  mapItr.second->Draw("ACP");
372 
373  // Save the canvas to file
374  can->Update();
375  can->Write();
376 
377  }//end of loop over canvases
378 
379  // now for the chi^2 iterations
380  can = itrDir.make<TCanvas>("chisq_can", "chisq", 800, 800);
381  chisq_graph->Draw("ACP");
382 
383  can->Update();
384 
385  // Save the canvas to file
386  can->Write();
387 
388  return;
389  }
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
std::vector< FitIteration > fIterations
Attempted point and chi^2 for each iteration of the fit.
Far Detector at Ash River, MN.
T * make(ARGS...args) const
enum BeamMode string
void fnex::MultiExperiment::DrawParallelPlots ( art::TFileDirectory plotDir) const

Definition at line 392 of file MultiExperiment.cxx.

References a, b, om::cout, fillBadChanDBTables::det, getGoodRuns4SAM::detname, fetch_tb_beamline_files::experiment, MECModelEnuComparisons::i, novadaq::cnv::kFARDET, novadaq::cnv::kNEARDET, ListExperiments(), LOG_VERBATIM, art::TFileDirectory::mkdir(), and string.

Referenced by fnex::FitAlgorithm::DrawPlots().

393  {
394 
395  // Now output the contributions to ChiSq from each experiment
396 
397  // How many are NOvA_Experiments? How many are NP experiments?
398 
399  int countOfNOvAExps = 0;
400  int countOfNuisExps = 0;
401 
402  std::vector<std::string> exp_names;
403  std::vector<double> exp_chisq;
404  std::vector<int> exp_ndof;
405  std::vector<std::unique_ptr<TCanvas>> exp_cans_nd;
406  std::vector<std::unique_ptr<TCanvas>> exp_cans_fd;
407  std::vector<std::unique_ptr<TCanvas>> exp_cans_nd_oscpars;
408  std::vector<std::unique_ptr<TCanvas>> exp_cans_fd_oscpars;
409  std::vector<std::unique_ptr<TCanvas>> exp_cans_nd_systs;
410  std::vector<std::unique_ptr<TCanvas>> exp_cans_fd_systs;
411 
412  std::vector<std::string> np_names;
413  std::vector<double> np_chisq;
414  std::vector<int> np_ndof;
415 
418 
419  for(auto & experiment : this->ListExperiments()){
420 
421  if(NOvA_Experiment * nova_experiment = dynamic_cast<NOvA_Experiment*>(&(*experiment))) {
422  ++countOfNOvAExps;
423  std::string expname = nova_experiment->ShortName();
424 
425  LOG_VERBATIM("MultiExperiment")
426  << " Found a NOvA Experiment named: "
427  << expname
428  << "\n With chisq/dof = "
429  << nova_experiment->FitValue()
430  << " / "
431  << nova_experiment->NDOF();
432 
433  exp_names .push_back(expname);
434  exp_chisq .push_back(nova_experiment->FitValue());
435  exp_ndof .push_back(nova_experiment->NDOF());
436  exp_cans_nd .push_back( nova_experiment->fCorrectedSpectrum->GetCorrectedStacksCanvasCopy(det_nd, expname) );
437  exp_cans_fd .push_back( nova_experiment->fCorrectedSpectrum->GetCorrectedStacksCanvasCopy(det_fd, expname) );
438  exp_cans_nd_oscpars.push_back( nova_experiment->fCorrectedSpectrum->GetOscParCanvasCopy(det_nd, expname) );
439  exp_cans_fd_oscpars.push_back( nova_experiment->fCorrectedSpectrum->GetOscParCanvasCopy(det_fd, expname) );
440  exp_cans_nd_systs .push_back( nova_experiment->fCorrectedSpectrum->GetSystCanvasCopy(det_nd, expname) );
441  exp_cans_fd_systs .push_back( nova_experiment->fCorrectedSpectrum->GetSystCanvasCopy(det_fd, expname) );
442  }
443 
444  if(NuisanceParameter_Experiment * np_experiment = dynamic_cast<NuisanceParameter_Experiment*>(&(*experiment))) {
445  ++countOfNuisExps;
446  std::string expname = np_experiment->ShortName();
447  std::cout << " Found a Nuisance Parameter Experiment named: " << expname << "\n";
448  std::cout << " With chisq/dof = " << np_experiment->FitValue() << " / " << np_experiment->NDOF() << "\n";
449  np_names.push_back(expname);
450  np_chisq.push_back(np_experiment->FitValue());
451  np_ndof.push_back(np_experiment->NDOF());
452  }
453 
454  }
455 
456 
457  if(countOfNOvAExps <= 0) return;
458 
459  // Order exp vectors by chisq
460  // (exp_index now holds the indices, sorted by
461  // decreasing chisq)
462  std::vector<unsigned int> exp_index(exp_chisq.size(), 0);
463  for (unsigned int i = 0 ; i != exp_index.size() ; i++) {
464  exp_index[i] = i;
465  }
466  sort(exp_index.begin(), exp_index.end(),
467  [&](const int& a, const int& b) {
468  return (exp_chisq[a] > exp_chisq[b]);
469  }
470  );
471 
472  // Order np vectors by chisq
473  // (np_index now holds the indices, sorted by
474  // decreasing chisq)
475  std::vector<unsigned int> np_index(np_chisq.size(), 0);
476  for (unsigned int i = 0 ; i != np_index.size() ; i++) {
477  np_index[i] = i;
478  }
479  sort(np_index.begin(), np_index.end(),
480  [&](const int& a, const int& b) {
481  return (np_chisq[a] > np_chisq[b]);
482  }
483  );
484 
485  // Now that we know this, let's make the side-by-side canvases,
486  // for each the ND and FD
487 
488 
489  art::TFileDirectory mexpDir = plotDir->mkdir( "MultiExperimentParallel" );
490 
491  for(int i=0; i<2; i++){
492 
494  if(i==0) det = novadaq::cnv::kFARDET;
495  if(i==1) det = novadaq::cnv::kNEARDET;
496 
497  std::string canvasname = "NOvAExperimentContributions_";
498  std::string detname = (det == novadaq::cnv::kFARDET) ? "FD" : "ND";
499  canvasname.append(detname);
500 
501  // Make the side-by-side canvas
502  TCanvas * canmain = nullptr;
503  if(countOfNOvAExps==3){
504  canmain = mexpDir.make<TCanvas>(canvasname.data(), canvasname.data(), 2400, 1600);
505  canmain->Divide(3,2);
506  }
507  else if(countOfNOvAExps == 1){
508  canmain = mexpDir.make<TCanvas>(canvasname.data(), canvasname.data(), 1600, 1600);
509  canmain->Divide(2,2);
510  }
511  else if(countOfNOvAExps == 4){
512  canmain = mexpDir.make<TCanvas>(canvasname.data(), canvasname.data(), 3200, 1600);
513  canmain->Divide(4,2);
514  }
515  else if(countOfNOvAExps > 4 && countOfNOvAExps < 13){
516  canmain = mexpDir.make<TCanvas>(canvasname.data(), canvasname.data(), 3200, 3200);
517  canmain->Divide(4,3);
518  }
519  else if(countOfNOvAExps > 13 && countOfNOvAExps < 15){
520  canmain = mexpDir.make<TCanvas>(canvasname.data(), canvasname.data(), 4800, 3200);
521  canmain->Divide(5,4);
522  }
523 
524  // Loop through the experiments and draw their spectra to the joint canvas
525  int curCanvas=1;
526  std::vector<TPaveText *> expLegend(exp_index.size());
527  for(auto i : exp_index){
528  canmain->cd(curCanvas);
529  if(det == novadaq::cnv::kNEARDET) exp_cans_nd[i]->DrawClonePad();
530  else exp_cans_fd[i]->DrawClonePad();
531  //expLegend[i] = new TPaveText(0.525, 0.7, 0.875, 0.9);
532  //expLegend[i]->SetBorderSize(1);
533  //expLegend[i]->SetFillColor(0);
534  //expLegend[i]->AddText(exp_names[exp_index[i]].data());
535  //expLegend[i]->Draw("SAME");
536  ++curCanvas;
537  }
538 
539  // Add the ChiSq canvas (each 'normal' exp + sum of all nuisance par contributions)
540  // Then can even put non-zero individual nuisance par contributions below this
541  // Make parameter legend
542 
543  canmain->cd(curCanvas);
544  TPaveText pointLegend(0.1, 0.1, 0.9, 0.9);
545  pointLegend.SetBorderSize(1);
546  pointLegend.SetFillColor(0);
547 
548  // Get chisq and number of degrees of freedom (ndof)
549  int nFreeOscPars = 0;
550  int nFreeSystPars = 0;
551  int nFreePars = 0;
552  for(auto & experiment : this->ListExperiments()){
553  if(NOvA_Experiment * nova_experiment = dynamic_cast<NOvA_Experiment*>(&(*experiment))) {
554  nFreeOscPars =
555  nova_experiment->fCorrectedSpectrum->RefInputPoint().ParameterSpaceLocation(det).size() -
556  nova_experiment->fCorrectedSpectrum->RefInputPoint().FixedParameters(det).size();
557  nFreeSystPars =
558  nova_experiment->fCorrectedSpectrum->RefInputPoint().SystematicPulls(det).size() -
559  nova_experiment->fCorrectedSpectrum->RefInputPoint().FixedSystematics(det).size();
560  nFreePars = nFreeOscPars + nFreeSystPars;
561  break;
562  }
563  }
564 
565  // All experiments chisq
566  int ndof_all = 0;
567  double chisq_all = 0;
568  for(unsigned int i=0; i<exp_index.size(); i++){
569  ndof_all += exp_ndof[exp_index[i]];
570  chisq_all += exp_chisq[exp_index[i]];
571  }
572 
573  // Total nuisance parameter ChiSq and NDOF
574  int np_ndof_tot = 0;
575  double np_chisq_tot = 0;
576  for(unsigned int i=0; i<np_index.size(); i++){
577  np_ndof_tot += np_ndof[np_index[i]];
578  np_chisq_tot += np_chisq[np_index[i]];
579  }
580 
581 
582  std::stringstream all_chi;
583  all_chi << "MultiExperiment "
584  << "#chi^{2} / NDOF = " << chisq_all + np_chisq_tot << " / " << ndof_all + np_ndof_tot - nFreePars;
585  pointLegend.AddText(all_chi.str().data());
586  std::stringstream free_info;
587  free_info << "NDOF Adj By " << nFreeOscPars << " Free Oscillation Parameters ";
588  pointLegend.AddText(free_info.str().data());
589 
590  // Individual experiment ChiSq
591  pointLegend.AddText("");
592  for(unsigned int i=0; i<exp_index.size(); i++){
593  std::stringstream ss_chi;
594  ss_chi << exp_names[exp_index[i]] << " "
595  << "#chi^{2} / NDOF = " << exp_chisq[exp_index[i]] << " / " << exp_ndof[exp_index[i]];
596  pointLegend.AddText(ss_chi.str().data());
597  }
598 
599 
600  std::stringstream np_chi;
601  np_chi << "All Nuisance Pars "
602  << "#chi^{2} / NDOF = " << np_chisq_tot << " / " << np_ndof_tot;
603  pointLegend.AddText(np_chi.str().data());
604 
605  // Individual nuisance parameter ChiSq NDOF
606  pointLegend.AddText("");
607  for(unsigned int i=0; i<np_index.size(); i++){
608  std::stringstream ss_chi;
609  ss_chi << np_names[np_index[i]] << " "
610  << "#chi^{2} / NDOF = " << np_chisq[np_index[i]] << " / " << np_ndof[np_index[i]];
611  pointLegend.AddText(ss_chi.str().data());
612  }
613 
614  //Total chisq Multiexperiment + Nuisance parameters contribution
615  pointLegend.AddText("");
616  std::stringstream ss_chi_total;
617  ss_chi_total
618  << "Total #chi^{2} / NDOF = "
619  << chisq_all + np_chisq_tot
620  << "/"
621  << ndof_all + np_ndof_tot;
622  pointLegend.AddText(ss_chi_total.str().data());
623 
624  pointLegend.Draw();
625 
626 
627  // Add the oscillation parameter canvas
628  ++curCanvas;
629  canmain->cd(curCanvas);
630  if(det == novadaq::cnv::kNEARDET) exp_cans_nd_oscpars[0]->DrawClonePad();
631  else exp_cans_fd_oscpars[0]->DrawClonePad();
632 
633 
634  // Add the systematics parameter canvas
635  ++curCanvas;
636  canmain->cd(curCanvas);
637  if(det == novadaq::cnv::kNEARDET) exp_cans_nd_systs[0]->DrawClonePad();
638  else exp_cans_fd_systs[0]->DrawClonePad();
639 
640 
641  // Save the canvas to file
642  canmain->Update();
643  canmain->Write();
644 
645  }
646 
647 
648  }
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
Far Detector at Ash River, MN.
const double a
const std::vector< std::unique_ptr< Experiment > > & ListExperiments() const
Near Detector in the NuMI cavern.
OStream cout
Definition: OStream.cxx:6
const hit & b
Definition: hits.cxx:21
#define LOG_VERBATIM(category)
enum BeamMode string
void fnex::MultiExperiment::DrawPlots ( art::TFileDirectory plotDir) const

Definition at line 258 of file MultiExperiment.cxx.

References allTimeWatchdog::can, fetch_tb_beamline_files::experiment, ListExperiments(), art::TFileDirectory::make(), and art::TFileDirectory::mkdir().

Referenced by fnex::FitAlgorithm::DrawPlots().

259  {
260 
261  // Call DrawPlots( ) for each individual experiment
262  art::TFileDirectory mexpDir = plotDir->mkdir( "MultiExperiment" );
263  for(auto & experiment : this->ListExperiments()){
264  experiment->DrawPlots(&mexpDir);
265  }
266 
267  // Now output the contributions to ChiSq from each experiment
268  TCanvas *can = nullptr;
269  can = mexpDir.make<TCanvas>("Experiment ChiSq Contributions", "Experiment ChiSq Contributions", 800, 800);
270  can->cd(1);
271 
272  // Make contributions legend
273  TPaveText chisqContributionLegend(0.1, 0.1, 0.9, 0.9);
274  chisqContributionLegend.SetBorderSize(1);
275  chisqContributionLegend.SetFillColor(0);
276  std::stringstream ss_chi;
277  ss_chi << "Contribution" << " : " << "Fit Value";
278  chisqContributionLegend.AddText(ss_chi.str().data());
279  for(auto & experiment : this->ListExperiments()){
280  ss_chi.str("");
281  ss_chi << experiment->ToString() << " : " << experiment->FitValue();
282  chisqContributionLegend.AddText(ss_chi.str().data());
283  }
284 
285  // We're done here. Draw the canvas describing par / syst space
286  // and update the canvas
287  chisqContributionLegend.Draw();
288  can->Update();
289 
290  // Save the canvas to file
291  can->Write();
292 
293  return;
294  }
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
const std::vector< std::unique_ptr< Experiment > > & ListExperiments() const
T * make(ARGS...args) const
double fnex::MultiExperiment::FitValue ( )

Definition at line 220 of file MultiExperiment.cxx.

References fExperiments, fIterations, it, and LOG_VERBATIM.

Referenced by fnex::FitFunction_ForROOT().

221  {
222 
223  // Add together values of fit value for all attached
224  // Experiment objects (added linearly for now)
225  LOG_VERBATIM("MultiExperiment")
226  << std::setw(40)
227  << "Experiment"
228  << std::setw(20)
229  << "ChiSq";
230 
231  double chisq = 0.0;
232  for(auto& it : fExperiments){
233  chisq += it->FitValue();
234  LOG_VERBATIM("MultiExperiment")
235  << std::setw(40)
236  << it->ToString()
237  << std::setw(20)
238  << it->FitValue();
239  }
240 
241  LOG_VERBATIM("MultiExperiment")
242  << std::setw(40)
243  << "TOTAL"
244  << std::setw(20)
245  << chisq;
246 
247  // set the last entered input point in the Iteration collection
248  // to have this chi^2 The two functions are called one after the other,
249  // so there should not be a risk of getting out of sync
250  fIterations.back().chiSqr = chisq;
251 
252  // We're done here
253  return chisq;
254 
255  }
set< int >::iterator it
std::vector< FitIteration > fIterations
Attempted point and chi^2 for each iteration of the fit.
std::vector< std::unique_ptr< Experiment > > fExperiments
#define LOG_VERBATIM(category)
const std::vector< std::unique_ptr<Experiment> >& fnex::MultiExperiment::ListExperiments ( ) const
inline

Definition at line 56 of file MultiExperiment.h.

References DrawPlots().

Referenced by DrawParallelPlots(), and DrawPlots().

56 { return fExperiments; }
std::vector< std::unique_ptr< Experiment > > fExperiments
void fnex::MultiExperiment::Reconfigure ( fhicl::ParameterSet const &  pset)

Definition at line 122 of file MultiExperiment.cxx.

References fCorrelations, fExperiments, fIsConfigured, fhicl::ParameterSet::get(), fhicl::ParameterSet::get_names(), it, LOG_VERBATIM, LOG_WARNING, and string.

Referenced by MultiExperiment().

122  {
123 
124  // Find block of Experiment psets
125  fhicl::ParameterSet const& experiments_pset = pset.get< fhicl::ParameterSet >("Experiments");
126  std::vector< std::string > experiments_keys = experiments_pset.get_names();
127 
128  // Construct a new Experiment object for each, and pass each its respective pset.
129  // Store in the combined std::vector< Experiment > fExperiments
130  fExperiments.resize(experiments_keys.size());
131  unsigned int curExp = 0;
132  for(auto& it: experiments_keys){
133  LOG_VERBATIM("MultiExperiment")
134  << "Getting experiment "
135  << it;
136 
137  auto exPSet = experiments_pset.get< fhicl::ParameterSet >(it);
138  auto type = exPSet.get<std::string>("ExperimentType");
139 
140  if(type != "NOvA"){
141  LOG_WARNING("MultiExperiment")
142  << "Requesting experiment type "
143  << type
144  << " in MultiExperiment configuration, but only NOvA type is recognized."
145  << " Ignoring this experiment.";
146  continue;
147  }
148 
149  fExperiments[curExp] = std::make_unique<NOvA_Experiment>(exPSet);
150 
151  ++curExp;
152  }
153 
154  // sort the experiments for display purposes
155  //std::sort(fExperiments.begin(), fExperiments.end(), orderByExperimentShortName);
156 
157  // Get the correlations
158  fCorrelations = std::make_unique<Correlations>(pset.get< fhicl::ParameterSet >("Correlations"));
159 
160  // Test correlations are registered
161  fCorrelations->Print();
162 
163  // Configuration done
164  fIsConfigured = true;
165 
166  }
set< int >::iterator it
std::unique_ptr< Correlations > fCorrelations
std::vector< std::unique_ptr< Experiment > > fExperiments
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::vector< std::string > get_names() const
#define LOG_WARNING(category)
bool fIsConfigured
has the object been configured?
#define LOG_VERBATIM(category)
enum BeamMode string
bool fnex::MultiExperiment::SetEventListMap ( EventListMap const &  pEventListMap)

Definition at line 109 of file MultiExperiment.cxx.

References fetch_tb_beamline_files::experiment, and fExperiments.

Referenced by fnex::FitAlg_ROOTFactoryFit::FillGlobalVariables().

109  {
110  // Keep track of an errors along the way
111  bool noerror = true;
112  // Pass this event list to all experiments; each experiment is responsible
113  // for choosing which it needs, and complaining if it does not find them
114  for(auto & experiment : fExperiments){
115  noerror = noerror && experiment->SetEventListMap(pEventListMap);
116  }
117  return noerror;
118  }
std::vector< std::unique_ptr< Experiment > > fExperiments

Member Data Documentation

std::unique_ptr<Correlations> fnex::MultiExperiment::fCorrelations
private

Definition at line 77 of file MultiExperiment.h.

Referenced by ApplyCorrelations(), and Reconfigure().

std::vector< std::unique_ptr<Experiment> > fnex::MultiExperiment::fExperiments
private
bool fnex::MultiExperiment::fIsConfigured
private

has the object been configured?

Definition at line 72 of file MultiExperiment.h.

Referenced by Reconfigure().

std::vector<FitIteration> fnex::MultiExperiment::fIterations
private

Attempted point and chi^2 for each iteration of the fit.

Definition at line 76 of file MultiExperiment.h.

Referenced by ApplyPoint(), DrawFitterProgressGraphs(), and FitValue().

bool fnex::MultiExperiment::fNuisanceExMade
private

have the NuisanceParameterExperiments been made?

Definition at line 73 of file MultiExperiment.h.

Referenced by CreateNuisanceParameterExperiments().

std::vector< std::vector< double > > fnex::MultiExperiment::fSystUncCorrs
private

Definition at line 75 of file MultiExperiment.h.


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