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