CorrSpec_BENDecomp.cxx
Go to the documentation of this file.
1 #include <bitset>
2 #include "TH2.h"
3 
5 
7 #include "FNEX/core/VarBinning.h"
8 
9 namespace fnex{
10 
11  //----------------------------------------------------------------------------
13  : CorrectedSpectrum(pset)
14  {
15  this->Reconfigure(pset);
16  }
17 
18  //----------------------------------------------------------------------------
20  {
21  fVarName = pset.get< std::string >("VarName");
22  fIsConfigured = true;
23  fFarNormalizationType = pset.get< std::string >("FarNormalizationType");
24  fNearNormalizationType = pset.get< std::string >("NearNormalizationType");
25  fDoOscillate[novadaq::cnv::kNEARDET] = pset.get< bool >("OscillateND", false);
26  fDoOscillate[novadaq::cnv::kFARDET] = pset.get< bool >("OscillateFD", true );
27 
28  return;
29  }
30 
31  //----------------------------------------------------------------------------
33  {
34  std::string r = "CorrSpec_BENDecomp_";
35  r += fVarName;
36  return r;
37  }
38 
39  //----------------------------------------------------------------------------
40  const TH1D & CorrSpec_BENDecomp::DataForFit() const
41  {
43  }
44 
45  //----------------------------------------------------------------------------
46  const TH1D & CorrSpec_BENDecomp::MCForFit() const
47  {
49  }
50 
51  //----------------------------------------------------------------------------
52  const std::vector<double> & CorrSpec_BENDecomp::DataPointsForFit() const
53  {
54  return fDataPointsForFit;
55  }
56 
57  //----------------------------------------------------------------------------
58  const std::vector<double> & CorrSpec_BENDecomp::WeightsForFit() const
59  {
60  return fWeightsForFit;
61  }
62 
63  //----------------------------------------------------------------------------
65  {
66 
68  throw cet::exception("CorrSpec_BENDecomp")
69  << "SpectrumList not generated! Cannot SetPlotStyles.";
70 
71  // Both the Corrected and UnCorrected maps are expected to have
72  // the same MetaData keys present
73  int color = 0;
75  auto uncorritr = fUncorrectedHistMap.begin();
76  for(auto corritr : fCorrectedHistMap){
77  md = corritr.first;
78  uncorritr = fUncorrectedHistMap.find(md);
79 
80  if(uncorritr == fUncorrectedHistMap.end())
81  throw cet::exception("CorrSpec_BENDecomp")
82  << "Unable to find metadata "
83  << md.ToString()
84  << " in the uncorrected histogram map";
85 
86  if(md.isMC){
87  if (md.fileType == fnex::kBeam ) color = 9;
88  else if(md.fileType == fnex::kTauSwap) color = 8;
89  else if(md.fileType == fnex::kSwap ) color = 7;
90 
91  corritr.second.SetFillColor(color);
92  corritr.second.SetFillStyle(1001);
93  corritr.second.SetOption("HIST");
94 
95  uncorritr->second.SetFillColor(color);
96  uncorritr->second.SetFillStyle(1001);
97  uncorritr->second.SetOption("HIST");
98  } // end if MC
99  else{
100  corritr.second.SetFillStyle(0);
101  corritr.second.SetMarkerColor(1);
102  corritr.second.SetMarkerStyle(2);
103  corritr.second.SetLineWidth(1);
104  corritr.second.SetOption("E1");
105 
106  uncorritr->second.SetFillStyle(0);
107  uncorritr->second.SetMarkerColor(1);
108  uncorritr->second.SetMarkerStyle(2);
109  uncorritr->second.SetLineWidth(1);
110  uncorritr->second.SetOption("E1");
111  } // end if data
112  } // end loop over spectrum metadata
113 
114 
115  // DetHistMap
116  std::set<novadaq::cnv::DetId> dets({novadaq::cnv::kNEARDET, novadaq::cnv::kFARDET});
117 
118  for(auto const& det : dets){
119 
120  // Corrected
121  fCorrectedHist_All_Data.at(det).SetMarkerColor(1);
122  fCorrectedHist_All_Data.at(det).SetMarkerStyle(2);
123  fCorrectedHist_All_Data.at(det).SetLineWidth(1);
124  fCorrectedHist_All_Data.at(det).SetOption("E1");
125 
126  fCorrectedHist_All_MC.at(det).SetFillStyle(0);
127  fCorrectedHist_All_MC.at(det).SetLineColor(2);
128  fCorrectedHist_All_MC.at(det).SetLineWidth(1);
129  fCorrectedHist_All_MC.at(det).SetOption("HIST");
130 
131  fCorrectedHist_All_Data_Over_MC.at(det).SetMarkerColor(1);
132  fCorrectedHist_All_Data_Over_MC.at(det).SetMarkerStyle(2);
133  fCorrectedHist_All_Data_Over_MC.at(det).SetLineWidth(1);
134  fCorrectedHist_All_Data_Over_MC.at(det).SetOption("E1");
135 
136  // Uncorrected
137  fUncorrectedHist_All_Data.at(det).SetMarkerColor(1);
138  fUncorrectedHist_All_Data.at(det).SetMarkerStyle(2);
139  fUncorrectedHist_All_Data.at(det).SetLineWidth(1);
140  fUncorrectedHist_All_Data.at(det).SetOption("E1");
141 
142  fUncorrectedHist_All_MC.at(det).SetFillStyle(0);
143  fUncorrectedHist_All_MC.at(det).SetLineColor(2);
144  fUncorrectedHist_All_MC.at(det).SetLineWidth(1);
145  fUncorrectedHist_All_MC.at(det).SetOption("HIST");
146 
147  fUncorrectedHist_All_Data_Over_MC.at(det).SetMarkerColor(1);
148  fUncorrectedHist_All_Data_Over_MC.at(det).SetMarkerStyle(2);
149  fUncorrectedHist_All_Data_Over_MC.at(det).SetLineWidth(1);
150  fUncorrectedHist_All_Data_Over_MC.at(det).SetOption("E1");
151 
152  }
153 
154  return;
155  }
156 
157  //----------------------------------------------------------------------------
159  {
160 
161  // Clear out existing SpectrumList if it's filled
162  fSpectrumListGenerated = false;
163  fSpectrumList.clear();
164 
165  // Keep a constant reference to the EventListMap
166  fEventListMap = &pEventListMap;
167 
168  fnex::Binning const* binning;
169 
170  if(fFitEvalType == "UBL" && (fVarName == "Nu_RecoE" ||
171  fVarName == "Lep_RecoE" ||
172  fVarName == "Had_RecoE" ))
173  binning = fnex::VarBinning::Instance()->BinInfo(fVarName + "_UBL");
174  else
176 
177  // keep track of the types of MetaData which are present, at a minimum
178  // require ND data, ND beam MC, ND flux swap MC, FD data, FD beam MC, FD flux swap MC,
179  // FD tau swap MC, set the bits in that order
180  // the bitset has all locations initialized to 0 by default.
181  std::bitset<7> requiredMD;
182 
183  // Look through pEventListMap, check for basic types required;
184  // if found, assign to class-wide MetaData definition for use as keys
186  size_t bit;
187  for(auto const& eventList : *fEventListMap){
188  md = eventList.first;
189 
190  // only use the nue selected events for this extrapolation
191  if(!md.IsNuESelected()) continue;
192 
193  fSpectrumList.emplace(md, Spectrum(eventList.second, binning, md.ToString()));
194 
195  // reset the bit
196  bit = 0;
197 
198  if(md.detector == novadaq::cnv::kFARDET) bit = 3;
199 
200  switch(md.fileType){
201  case fnex::kDataFile:
202  bit += 0;
203  break;
204  case fnex::kBeam:
205  bit += 1;
206  break;
207  case fnex::kSwap:
208  bit += 2;
209  break;
210  case fnex::kTauSwap:
211  bit += 3;
212  break;
214  break;
215  default:
216  throw cet::exception("CorrSpec_BENDecomp")
217  << "Unknown FileType: " << md.ToString();
218  }
219 
220  LOG_DEBUG("CorrSpec_BENDecomp")
221  << md.ToString()
222  << " " << requiredMD.to_string()
223  << " " << bit
224  << " " << md.fileType;
225 
226  requiredMD.set(bit);
227  }
228 
229  // check that the expected metadata are present.
230  if( !requiredMD.all() ){
231  //TODO: need to remove this check when we have ND flux swap events
232  requiredMD.set(2);
233  if( !requiredMD.all() )
234  throw cet::exception("CorrSpec_BENDecomp")
235  << "Some expected metadata are missing: "
236  << requiredMD.to_string() << std::endl;
237  }
238 
239 
240  // we got here, so all the spectra are accounted for
241  fSpectrumListGenerated = true;
242 
243  // Now make the corrected histograms
244  LOG_VERBATIM("CorrSpec_BENDecomp")
245  << "Making CorrSpec_BENDecomp Histograms"
246  << " Spectrum list size: "
247  << fSpectrumList.size();
248 
250  this->MakeCorrectedHistograms();
251 
252  // We're done here
253  return fSpectrumListGenerated;
254  }
255 
256 
257  //----------------------------------------------------------------------------
259  {
260 
261  // Check that spectrum list is generated
263  throw cet::exception("CorrSpec_BENDecomp")
264  << "Spectrum list not generated!";
265 
266  // Make histograms, appropriately scaled to data those factors
267  std::string histname;
268  std::string histtitle;
269  std::string xaxisname = fVarName;
270  std::string yaxisname = "Events";
271 
272  // make the HistMaps (uncombined hists)
273  // use the same binning as in the histograms for each metadata type
274  auto hist = fSpectrumList.begin()->second.Histogram(fVarName);
275  int bins = hist->GetNbinsX();
276  double low = hist->GetXaxis()->GetXmin();
277  double high = hist->GetXaxis()->GetXmax();
278 
280  for(auto & spectrum : fSpectrumList){
281  md = spectrum.first;
282  histname = md.ToString() + "_Uncorr_BENDecomp_" + fVarName;
283  histtitle = md.ToStringLatex() + " (Uncorr::BENDecomp) (" + fVarName + ")";
284  histtitle += ";" + xaxisname + ";" + yaxisname;
285  fUncorrectedHistMap.emplace(md, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high) );
286  this->AddSpectrumHistogram(spectrum.second, fUncorrectedHistMap.at(md), fVarName);
287  }
288 
289  return true;
290  }
291 
292  //----------------------------------------------------------------------------
294  {
295 
296  // Check that spectrum list is generated
298  throw cet::exception("CorrSpec_BENDecomp")
299  << "Spectrum list not generated!";
300 
301  // Make histograms, appropriately scaled to data those factors
302  std::string histname;
303  std::string histtitle;
304  std::string xaxisname = fVarName;
305  std::string yaxisname = "Events";
306 
307  // make the HistMaps (uncombined hists)
308  // use the same binning as in the histograms for each metadata type
309  auto hist = fSpectrumList.begin()->second.Histogram(fVarName);
310  int bins = hist->GetNbinsX();
311  double low = hist->GetXaxis()->GetXmin();
312  double high = hist->GetXaxis()->GetXmax();
313 
314  // First the uncorrected HistMap (uncombined hists)
316  for(auto & spectrum : fSpectrumList){
317  md = spectrum.first;
318  histname = md.ToString() + "_Corr_BENDecomp_" + fVarName;
319  histtitle = md.ToStringLatex() + " (Corr::BENDecomp) (" + fVarName + ")";
320  histtitle += ";" + xaxisname + ";" + yaxisname;
321  fCorrectedHistMap.emplace(md, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high) );
322  this->AddSpectrumHistogram(spectrum.second, fCorrectedHistMap.at(md), fVarName);
323  }
324 
325  // Now name and title all of the histograms
326  // (ROOT's the worst; you'll get segfaults and other unpleasantries
327  // without unique names and titles for all TH1D instances)
328  std::set<std::pair<novadaq::cnv::DetId, std::string> > detectors({std::make_pair(novadaq::cnv::kNEARDET, "ND"),
330 
331  for(auto const& det : detectors){
332 
333  histname = det.second + "_Uncorr_BENDecomp_Data_" + fVarName;
334  histtitle = det.second + "::Uncorr::BENDecomp::Data::" + fVarName;
335  histtitle += ";" + xaxisname + ";" + yaxisname;
336  fUncorrectedHist_All_Data.emplace(det.first, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high));
337 
338  fUncorrectedHist_All_Data.at(det.first).Sumw2();
339 
340  histname = det.second + "_Uncorr_BENDecomp_MC_" + fVarName;
341  histtitle = det.second + "::Uncorr::BENDecomp::MC::" + fVarName;
342  histtitle += ";" + xaxisname + ";" + yaxisname;
343  fUncorrectedHist_All_MC.emplace(det.first, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high));
344  fUncorrectedHist_All_MC.at(det.first).Sumw2();
345 
346  histname = det.second + "_Uncorr_BENDecomp_Data_Over_MC_" + fVarName;
347  histtitle = det.second + "::Uncorr::BENDecomp::Data_Over_MC::" + fVarName;
348  histtitle += ";" + xaxisname + ";" + yaxisname;
349  fUncorrectedHist_All_Data_Over_MC.emplace(det.first, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high));
350  fUncorrectedHist_All_Data_Over_MC.at(det.first).Sumw2();
351 
352  histname = det.second + "_Uncorr_BENDecomp_Data_" + fVarName;
353  histtitle = det.second + "::Uncorr::BENDecomp::Data::" + fVarName;
354  histtitle += ";" + xaxisname + ";" + yaxisname;
355  fCorrectedHist_All_Data.emplace(det.first, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high));
356  fCorrectedHist_All_Data.at(det.first).Sumw2();
357 
358  histname = det.second + "_Uncorr_BENDecomp_MC_" + fVarName;
359  histtitle = det.second + "::Uncorr::BENDecomp::MC::" + fVarName;
360  histtitle += ";" + xaxisname + ";" + yaxisname;
361  fCorrectedHist_All_MC.emplace(det.first, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high));
362  fCorrectedHist_All_MC.at(det.first).Sumw2();
363 
364  histname = det.second + "_Uncorr_BENDecomp_Data_Over_MC_" + fVarName;
365  histtitle = det.second + "::Uncorr::BENDecomp::Data_Over_MC::" + fVarName;
366  histtitle += ";" + xaxisname + ";" + yaxisname;
367  fCorrectedHist_All_Data_Over_MC.emplace(det.first, TH1D(histname.c_str(), histtitle.c_str(), bins, low, high));
368 
369  fCorrectedHist_All_Data_Over_MC.at(det.first).Sumw2();
370 
371  }
372 
373  LOG_VERBATIM("CorrSpec_BENDecomp")
374  << "Finished making histograms. There are "
375  << "\nUncorrectedHistMap: " << fUncorrectedHistMap.size()
376  << "\nCorrectedHistMap: " << fCorrectedHistMap.size()
377  << "\nUncorrectedAllData: " << fUncorrectedHist_All_Data.size()
378  << "\nUncorrectedAllMC: " << fUncorrectedHist_All_MC.size()
379  << "\nUncorrectedAllData/MC: " << fUncorrectedHist_All_Data_Over_MC.size()
380  << "\nCorrectedAllData: " << fCorrectedHist_All_Data.size()
381  << "\nCorrectedAllMC: " << fCorrectedHist_All_MC.size()
382  << "\nCorrectedAllData/MC: " << fCorrectedHist_All_Data_Over_MC.size();
383 
384  //std::cout << " about to set plot styles" << histname << std::endl;
385  this->SetPlotStyles();
386 
387  // We're done here
388  return true;
389  }
390 
391 
392  //----------------------------------------------------------------------------
394  {
395 
396 
397  // KM June 6 2016
398  // Reset fDataPointsForFit/fWeightsForFit. These are used for UBL fits.
399  fDataPointsForFit.resize(0);
400  fWeightsForFit.resize(0);
401 
402  // Check that spectrum list is generated
404  throw cet::exception("CorrSpec_BENDecomp")
405  << "Spectrum list not generated!";
406 
407  std::unordered_map<fnex::MetaData,
408  std::pair<double, double>,
409  fnex::MetaDataHasher> mdToEventsPOT;
410 
411  // store the number of events and POT for each detector's data
412  // the key is det * 1e4 + epoch
413  std::map<int, std::pair<double, double> > dataEventsPOT;
414 
415  // The key to fEventListMap and fSpectrumList is a fnex::MetaData,
416  // and both maps should have the same metadata present
417  fnex::MetaData md;
419  auto specItr = fSpectrumList.begin();
420  double events = 0.;
421  double pot = 0.;
422  int epochDetKey = 0;
423 
424  LOG_VERBATIM("CorrSpec_BENDecompEventsPerPOT")
425  << "EVENTS/POT:";
426 
427  // loop over the event lists to ensure that we have
428  // a spectrum for each list
429 
430  for(auto evitr : *fEventListMap){
431  md = evitr.first;
432 
433  // we don't want to mess with numu selected events here
434  if(md.IsNuMuSelected()) continue;
435 
436  det = md.detector;
437  pot = evitr.second.ListSpillSummary().goodPOT;
438  events = 1. * fUncorrectedHistMap.at(md).GetEntries();
439 
440  mdToEventsPOT[md] = std::make_pair(events, pot);
441 
442  LOG_VERBATIM("CorrSpec_BENDecompEventsPerPOT")
443  << std::setw(35) << md.ToString()
444  << " " << std::setw(15) << events
445  << " / " << std::setw(15) << pot
446  << " = " << std::setw(15) << events / pot;
447 
448  if(!md.isMC){
449  epochDetKey = 1e4 * det + md.epoch;
450  dataEventsPOT[epochDetKey] = std::make_pair(events, pot);
451  }
452 
453  specItr = fSpectrumList.find(md);
454  if(specItr == fSpectrumList.end() )
455  throw cet::exception("CorrSpec_BENDecomp")
456  << "EventListMap and SpectrumList have different metadata keys: "
457  << md.ToString();
458 
459  // reset the uncorrected and corrected histograms, fill the uncorrected
460  // histograms now
461  fUncorrectedHistMap.at(md).Reset();
462  fCorrectedHistMap .at(md).Reset();
463  if(md.isMC){
464  this->AddSpectrumHistogram(specItr->second,
465  fUncorrectedHistMap.at(md),
466  fVarName);
467  }else{
468  if(det == novadaq::cnv::kFARDET){
469  // Grab FD data points as well as making histogram,
470  // and add to fDataPointsForFit. There will never be
471  // very many FD data events, this should not have
472  // an appreciable effect on speed.
473  this->AddSpectrumHistogram(specItr->second, fUncorrectedHistMap.at(md), fVarName);
474  std::vector<double> thisFDData = specItr->second.BaseVals(fVarName);
476  thisFDData.begin(),
477  thisFDData.end());
478 
479  // SJB Aug 3 2016 - also grab data weights in order to pass
480  // these to the UBL fit object so that UBL fit value
481  // contributions can be weighted correctly.
482  std::vector<double> thisFDWeights = specItr->second.BaseVals(fnex::KeyToVarName(fnex::kFake_Weight));
483  fWeightsForFit.insert(fWeightsForFit.end(),
484  thisFDWeights.begin(),
485  thisFDWeights.end());
486  }else{
487  this->AddSpectrumHistogram(specItr->second, fUncorrectedHistMap.at(md), fVarName);
488  }
489  }
490  } // end loop over metadata to fill maps
491 
492  // reset the (un)corrected histograms for data and MC in each detector
493  std::set<novadaq::cnv::DetId> detectors({novadaq::cnv::kNEARDET, novadaq::cnv::kFARDET});
494  for(auto const& det : detectors){
495  fUncorrectedHist_All_Data .at(det).Reset();
496  fUncorrectedHist_All_MC .at(det).Reset();
497  fUncorrectedHist_All_Data_Over_MC.at(det).Reset();
498  fCorrectedHist_All_Data .at(det).Reset();
499  fCorrectedHist_All_MC .at(det).Reset();
500  fCorrectedHist_All_Data_Over_MC .at(det).Reset();
501  }
502 
503  // Make scale factors
504  // loop over the event and pot maps to determine the scale factors, we
505  // couldn't do this above because we did not know where the data were
506  std::pair<double, double> eventsPOT;
508  double scale = 0.;
509 
510  for(auto itr : *fEventListMap){
511  md = itr.first;
512 
513  // We don't want to do anything with numu selected events in
514  // nue analysis
515  if(md.IsNuMuSelected()) continue;
516 
517 
518  det = md.detector;
519  scale = 1.;
520  eventsPOT = mdToEventsPOT.find(md)->second;
521  epochDetKey = 1e4 * det + md.epoch;
522 
523  // no need to normalize data
524  if(md.isMC){
525 
526  // figure out how we are normalizing for each detector
528  else if(det == novadaq::cnv::kFARDET ) norm = fFarNormalizationType;
529 
530  if(norm.compare("POT") == 0){
531  scale = dataEventsPOT.find(epochDetKey)->second.second/eventsPOT.second;
532  LOG_VERBATIM("CorrSpec_BENDecompScale")
533  << "POT AND SCALES:"
534  << std::setw(50)
535  << md.ToString()
536  << " "
537  << std::setw(15)
538  << eventsPOT.second
539  << " / "
540  << scale;
541  }
542  else if(norm.compare("AREA") == 0){
543  scale = dataEventsPOT.find(epochDetKey)->second.first/eventsPOT.first;
544  LOG_VERBATIM("CorrSpec_BENDecompScale")
545  << "AREA AND SCALES:\n"
546  << std::setw(50)
547  << md.ToString()
548  << " "
549  << std::setw(15)
550  << eventsPOT.first
551  << " / "
552  << scale;
553  }
554  else
555  LOG_VERBATIM("CorrSpec_BENDecomp")
556  << std::setw(40) << md.ToString() << " NO KNOWN NEAR NORM TYPE REGISTERED, ALL SCALES SET = 1.0";
557  } // end if MC
558 
559  // scale the histograms for each type of metadata accordingly
560  fUncorrectedHistMap.at(md).Scale(scale);
561 
562  if( md.isMC ){
563  // combine the results for all the metadata for each detector
564  //std::cout << "Adding in PLACE 6 " << md.ToString()<< std::endl;
565  fUncorrectedHist_All_MC.at(det).Add( &(fUncorrectedHistMap.at(md)) );
566  }
567  else{
568  // there is only 1 metadata type for each detector for data, so if we
569  // are not looking at MC events, then md is the only option for this det
570  fUncorrectedHist_All_Data.at(det).Add( &(fUncorrectedHistMap.at(md) ) );
571  }
572  } // end loop over the event lists (ie MetaData) for uncorrected histograms
573 
574  // take the ratio of the data to MC for the uncorrected histograms
577 
580 
581 
582  //------------------------------------------------------
583  // Here's where the corrected histograms are made!!!
584  // #BENDecompChampion #LindasWedding
585  //
586  // Possible interaction types are listed in FNEX/dataProducts/Constants.h
587  // Also listed here (accurate on 06/29/2016 @ 11:10 CDT)
588  //
589  // kUnknownInteraction = 0 (Also used to mean data)
590  // kNuMuCC,
591  // kNuMuBarCC,
592  // kNuECC,
593  // kNuEBarCC,
594  // kNuTauCC,
595  // kNuTauBarCC,
596  // kNC,
597  // kCosmicMuon
598  //------------------------------------------------------
599 
600  // Now make the corrected HistMap (uncombined hists)
601  for(auto & itr : *fEventListMap){
602  md = itr.first;
603  det = md.detector;
604 
605  // don't want to use numu selected events here
606  if(md.IsNuMuSelected()) continue;
607 
608  // start off with the corrected histogram being the same as the
609  // uncorrected one
610  fCorrectedHistMap.at(md).Add( &(fUncorrectedHistMap.at(md)) );
611 
612  if(md.isMC){
613 
614  // correct the FD MC histograms for the extrapolation from the ND
615  if(det == novadaq::cnv::kFARDET){
616 
617  // KM 09 07 2016 Pretty sure this is all we have to do for the backgrounds.
618  // Nue signal was already reweighted in the call to NearTrueEnergyRatio( )
619  if(md.interactionType == kNuMuCC ||
620  md.interactionType == kNuMuBarCC ||
621  md.interactionType == kNC ||
622  (md.interactionType == kNuECC && md.fileType == fnex::kBeam) ||
624  )
626 
627  } // end if FD
628 
629  fCorrectedHist_All_MC.at(det).Add( &(fCorrectedHistMap.at(md )) );
630 
631  } // end if MC
632  else{
633  // there is only 1 metadata type for each detector for data, so if we
634  // are not looking at MC events, then md is the only option for this det
635  fCorrectedHist_All_Data.at(det).Add( &(fCorrectedHistMap.at(md )) );
636  } // end if data
637 
638 
639  } // end loop over metadata for corrected histograms
640 
641  // make the ratios of data to MC
644 
647 
648  // We're done here
649  return true;
650  }
651 
652  //----------------------------------------------------------------------------
654  TH1D & hist,
655  std::string const& varName)
656  {
657  TH1D* specHist = (TH1D*)spectrum.Histogram(varName);
658 
659  if( specHist ) hist.Add(specHist);
660 
661  return;
662  }
663 
664 
665  //----------------------------------------------------------------------------
667  {
668 
669  // Assign reference input point
670  fRefInputPoint = pInputPoint;
671 
672  LOG_DEBUG("CorrSpec_BENDecomp")
673  << "Applying point\n"
674  << " Getting shift collections:";
675 
676  // Currently just updates the histograms; no way to pass the
677  // information into the spectrum right now
678  LOG_DEBUG("CorrSpec_BENDecomp")
679  << " Calling update on corrected histograms: ";
680 
681  LOG_DEBUG("CorrSpec_BENDecomp")
682  << "CORRSPEC_BENDecomp: Calling UpdateCorrectedHistograms : \n";
683 
685 
686  return;
687  }
688 
689 
690 } //end of namespace fnex
void Reconfigure(fhicl::ParameterSet const &pset)
#define LOG_DEBUG(stream)
Definition: Messenger.h:149
bool IsNuESelected() const
Definition: Structs.cxx:265
const EventListMap * fEventListMap
DetHistMap fUncorrectedHist_All_Data_Over_MC
bool IsNuMuSelected() const
Definition: Structs.cxx:256
const std::string ToString() const
const TH1 * Histogram(std::string const &varName)
Prepare a histogram using the fnex::Event objects in the fnex::EventList this Spectrum is using...
Definition: Spectrum.cxx:53
SpectrumList fSpectrumList
Internal-use function that updates the weight collections for a new set of oscillation parameters...
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::map< fnex::MetaData, fnex::EventList > EventListMap
Definition: Event.h:186
std::pair< Spectrum *, CheatDecomp * > make_pair(SpectrumLoaderBase &loader_data, SpectrumLoaderBase &loader_mc, HistAxis *axis, Cut *cut, const SystShifts &shift, const Var &wei)
Definition: DataMCLoad.C:336
static const unsigned char kFake_Weight
Definition: VarVals.h:39
Create a list of fnex::Events to be used in fits.
void ApplyPoint(InputPoint const &pInputPoint)
Double_t scale
Definition: plot.C:25
std::string const ToString() const
Definition: Structs.cxx:114
Far Detector at Ash River, MN.
void AddSpectrumHistogram(fnex::Spectrum &spectrum, TH1D &hist, std::string const &varName)
const TH1D & MCForFit() const
The Spectrum is the means for interaction with Event collections.
Definition: Spectrum.h:29
T get(std::string const &key) const
Definition: ParameterSet.h:231
DetHistMap fCorrectedHist_All_Data_Over_MC
#define pot
Near Detector in the NuMI cavern.
const Binning bins
novadaq::cnv::DetId detector
Definition: Structs.h:50
static VarBinning * Instance()
Definition: VarBinning.cxx:15
std::vector< double > fWeightsForFit
fnex::FileType_t fileType
Definition: Structs.h:51
bool GenerateSpectrumList(EventListMap const &pEventListMap)
::xsd::cxx::tree::string< char, simple_type > string
Definition: Database.h:154
Float_t norm
CorrSpec_BENDecomp(fhicl::ParameterSet const &pset)
std::vector< double > fDataPointsForFit
fnex::InteractionType_t interactionType
Definition: Structs.h:53
TRandom3 r(0)
std::string KeyToVarName(unsigned char const &key)
Definition: VarVals.h:445
#define LOG_VERBATIM(category)
Base class for &#39;binning&#39; objects. Pure virtual – you want either a FixedBinning or a VariableBinning...
Definition: Binning.h:20
std::string const ToStringLatex() const
Definition: Structs.cxx:144
const std::vector< double > & DataPointsForFit() const
const TH1D & DataForFit() const
fnex::Binning const * BinInfo(std::string const &varName)
Definition: VarBinning.cxx:65
void events(int which)
Definition: Cana.C:52
const std::vector< double > & WeightsForFit() const