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

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N20-12-01/FNEX/custom/NOvA_Experiment.h"

Inheritance diagram for fnex::NOvA_Experiment:
fnex::Experiment

Public Member Functions

 NOvA_Experiment (fhicl::ParameterSet const &pset)
 
 ~NOvA_Experiment ()
 
bool Reconfigure (fhicl::ParameterSet const &pset)
 
bool ApplyPoint (InputPoint &pInputPoint)
 
bool ApplyCorrelations (InputPoint &pInputPoint)
 
double FitValue ()
 
int NDOF ()
 
bool SetEventListMap (EventListMap const &pEventListMap)
 
const std::string ToString () const
 
void DrawPlots (art::TFileDirectory *plotDir) const
 
bool IsConfigured ()
 
bool HasPlots ()
 
const std::string ShortName () const
 

Public Attributes

std::unique_ptr< CorrectedSpectrumfCorrectedSpectrum
 
std::unique_ptr< FitEvaluationfFitEvaluation
 
std::unique_ptr< CorrelationsfCorrelations
 

Protected Attributes

bool fIsConfigured
 
bool fHasPlots
 
std::string fShortName
 

Private Attributes

std::vector< fnex::SelectionType_tfSelectionTypes
 
fnex::BeamType_t fBeamType
 
EventListMap fEventListMap
 

Detailed Description

Definition at line 14 of file NOvA_Experiment.h.

Constructor & Destructor Documentation

fnex::NOvA_Experiment::NOvA_Experiment ( fhicl::ParameterSet const &  pset)

Definition at line 16 of file NOvA_Experiment.cxx.

References Reconfigure().

17  : Experiment(pset)
18  {
19  this->Reconfigure(pset);
20  }
bool Reconfigure(fhicl::ParameterSet const &pset)
Experiment(fhicl::ParameterSet const &pset)
Definition: Experiment.cxx:6
fnex::NOvA_Experiment::~NOvA_Experiment ( )
inline

Member Function Documentation

bool fnex::NOvA_Experiment::ApplyCorrelations ( InputPoint pInputPoint)
virtual

Implements fnex::Experiment.

Definition at line 171 of file NOvA_Experiment.cxx.

Referenced by ~NOvA_Experiment().

171  {
172 
173  // TODO - do we need to uncomment this line?
174 
175  //fCorrelations->ApplyCorrelations(pInputPoint);
176 
177  return true;
178  }
bool fnex::NOvA_Experiment::ApplyPoint ( InputPoint pInputPoint)
virtual

Implements fnex::Experiment.

Definition at line 153 of file NOvA_Experiment.cxx.

References fCorrectedSpectrum.

Referenced by ~NOvA_Experiment().

153  {
154 
155  //std::cout << " About to apply correlations \n";
156  //std::cout << pInputPoint << std::endl;
157  //this->ApplyCorrelations(pInputPoint);
158  //std::cout << " Already applied correlations \n";
159  //std::cout << pInputPoint << std::endl;
160 
161  // Apply point to the attached CorrectedSpectrum
162  fCorrectedSpectrum->ApplyPoint(pInputPoint);
163 
164  // We're done here
165  return true;
166 
167  }
std::unique_ptr< CorrectedSpectrum > fCorrectedSpectrum
void fnex::NOvA_Experiment::DrawPlots ( art::TFileDirectory plotDir) const
virtual

Implements fnex::Experiment.

Definition at line 32 of file NOvA_Experiment.cxx.

References fCorrectedSpectrum, art::TFileDirectory::mkdir(), and ToString().

Referenced by ~NOvA_Experiment().

32  {
33  art::TFileDirectory thisExpDir = plotDir->mkdir(this->ToString());
34  fCorrectedSpectrum->DrawStacks(&thisExpDir);
35  fCorrectedSpectrum->DrawDataVsMC(&thisExpDir);
36  fCorrectedSpectrum->DrawCounts(&thisExpDir);
37  return;
38  }
const std::string ToString() const
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
std::unique_ptr< CorrectedSpectrum > fCorrectedSpectrum
double fnex::NOvA_Experiment::FitValue ( )
virtual

Implements fnex::Experiment.

Definition at line 181 of file NOvA_Experiment.cxx.

References fCorrectedSpectrum, and fFitEvaluation.

Referenced by ~NOvA_Experiment().

181  {
182 
183  // A NOvA_Experiment only has one corrected spectrum
184  // object. Return its value of chisq for the given
185  // FitEvaluation instance
186 
187  double chisq = fFitEvaluation->FitValue(fCorrectedSpectrum->DataForFit(),
188  fCorrectedSpectrum->MCForFit(),
189  fCorrectedSpectrum->DataPointsForFit(),
190  fCorrectedSpectrum->WeightsForFit());
191 
192  // We're done here
193  return chisq;
194 
195  }
std::unique_ptr< FitEvaluation > fFitEvaluation
std::unique_ptr< CorrectedSpectrum > fCorrectedSpectrum
bool fnex::Experiment::HasPlots ( )
inlineinherited
bool fnex::Experiment::IsConfigured ( )
inlineinherited

Definition at line 40 of file Experiment.h.

References fnex::Experiment::fIsConfigured.

40 { return fIsConfigured; }
int fnex::NOvA_Experiment::NDOF ( )
virtual

Implements fnex::Experiment.

Definition at line 198 of file NOvA_Experiment.cxx.

References fCorrectedSpectrum, and fFitEvaluation.

Referenced by ~NOvA_Experiment().

198  {
199 
200  // A NOvA_Experiment only has one corrected spectrum
201  // object. Return its value of chisq for the given
202  // FitEvaluation instance
203 
204  int ndof = fFitEvaluation->NDOF(fCorrectedSpectrum->DataForFit(),
205  fCorrectedSpectrum->MCForFit(),
206  fCorrectedSpectrum->DataPointsForFit(),
207  fCorrectedSpectrum->WeightsForFit());
208 
209  // We're done here
210  return ndof;
211 
212  }
std::unique_ptr< FitEvaluation > fFitEvaluation
std::unique_ptr< CorrectedSpectrum > fCorrectedSpectrum
bool fnex::NOvA_Experiment::Reconfigure ( fhicl::ParameterSet const &  pset)
virtual

Implements fnex::Experiment.

Definition at line 71 of file NOvA_Experiment.cxx.

References fBeamType, fCorrectedSpectrum, fFitEvaluation, fnex::Experiment::fHasPlots, fnex::Experiment::fIsConfigured, fSelectionTypes, fnex::Experiment::fShortName, fhicl::ParameterSet::get(), it, fnex::kFHC, fnex::kNuESelection, fnex::kNuESelectionHighPID, fnex::kNuESelectionLowPID, fnex::kNuESelectionMidPID, fnex::kNuESelectionPeripheral, fnex::kNuMuSelection, fnex::kNuMuSelectionQ1, fnex::kNuMuSelectionQ2, fnex::kNuMuSelectionQ3, fnex::kNuMuSelectionQ4, fnex::kRHC, fhicl::ParameterSet::put_or_replace(), string, and gen_hdf5record::types.

Referenced by NOvA_Experiment(), and ~NOvA_Experiment().

71  {
72 
73  fIsConfigured = true;
74  fHasPlots = true;
75 
76  // Get the short name (used to connect cross-experiment correlations and for quick reference)
77  fShortName = pset.get< std::string >("ShortName");
78 
79  // Look for a FitEval
80  auto fePSet = pset.get<fhicl::ParameterSet>("FitEvaluation");
81  auto type = fePSet.get<std::string>("FitEvaluationType");
82  if(type == "ChiSq" ) fFitEvaluation = std::make_unique<FitEval_ChiSq >(fePSet);
83  else if(type == "Counting") fFitEvaluation = std::make_unique<FitEval_Counting>(fePSet);
84  else if(type == "UBL" ) fFitEvaluation = std::make_unique<FitEval_UBL >(fePSet);
85  else{
86  throw cet::exception("NOvA_Experiment")
87  << " requested unknown fit evaluation type "
88  << type
89  << " in configuration of NOvA_Experiment";
90  }
91 
92  // And a CorrectedSpectrum
93  auto csPSet = pset.get< fhicl::ParameterSet >("CorrectedSpectrum");
94 
95  // Make sure the CorrectedSpectrum gets the FitEval information
96  csPSet.put_or_replace< std::string >("FitEvaluationType", type);
97 
98  auto csType = csPSet.get<std::string>("CorrectedSpectrumType");
99  if(csType == "SimpleExtrap" ) fCorrectedSpectrum = std::make_unique<CorrSpec_SimpleExtrap >(csPSet);
100  else if(csType == "PropDecomp" ) fCorrectedSpectrum = std::make_unique<CorrSpec_PropDecomp >(csPSet);
101  else if(csType == "BENDecomp" ) fCorrectedSpectrum = std::make_unique<CorrSpec_BENDecomp >(csPSet);
102  else if(csType == "MichelDecomp" ) fCorrectedSpectrum = std::make_unique<CorrSpec_MichelDecomp >(csPSet);
103  else if(csType == "NoExtrapNuMu" ) fCorrectedSpectrum = std::make_unique<CorrSpec_NoExtrapNuMu >(csPSet);
104  else if(csType == "SimpleNuMuExtrap" ) fCorrectedSpectrum = std::make_unique<CorrSpec_SimpleNuMuExtrap >(csPSet);
105  else{
106  throw cet::exception("NOvA_Experiment")
107  << " requested unknown corrected spectrum type "
108  << csType
109  << " in configuration of NOvA_Experiment";
110  }
111 
112  // Grab the selection type
113  auto types = pset.get< std::vector<std::string> >("SelectionTypes", std::vector<std::string>());
114  for(auto it : types){
115  if (it.compare("NuMuSel" ) == 0 ) fSelectionTypes.push_back(fnex::kNuMuSelection);
116  else if(it.find("NuMuSelQ1" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuMuSelectionQ1);
117  else if(it.find("NuMuSelQ2" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuMuSelectionQ2);
118  else if(it.find("NuMuSelQ3" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuMuSelectionQ3);
119  else if(it.find("NuMuSelQ4" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuMuSelectionQ4);
120  else if(it.find("NuESel_AllPID" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuESelection);
121  else if(it.find("NuESel_LowPID" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuESelectionLowPID);
122  else if(it.find("NuESel_MidPID" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuESelectionMidPID);
123  else if(it.find("NuESel_HighPID" ) != std::string::npos) fSelectionTypes.push_back(fnex::kNuESelectionHighPID);
124  else if(it.find("NuESel_Peripheral") != std::string::npos) fSelectionTypes.push_back(fnex::kNuESelectionPeripheral);
125  else{
126  throw cet::exception("NOvA_Experiment")
127  << "requested unknown selection type "
128  << it
129  << " in NOvA_Experiment.";
130  }
131  }
132 
133  // determine the beam type
134  auto beamString = pset.get< std::string >("BeamType", "FHC");
135  fBeamType = ( beamString.compare("FHC") == 0) ? fnex::kFHC : fnex::kRHC;
136 
137  // Figure out final configuration status
138  fIsConfigured = fCorrectedSpectrum->IsConfigured() && fFitEvaluation->IsConfigured();
139 
140  // Get the correlations
141  //fCorrelations = std::make_unique<Correlations>(pset.get< fhicl::ParameterSet >("Correlations"));
142 
143  // Set the fitter's range based on the fit range set in CorrectedSpectrum
144  fFitEvaluation->SetRange( fCorrectedSpectrum->FitRangeMin(),
145  fCorrectedSpectrum->FitRangeMax() );
146 
147  // We're done here
148  return fIsConfigured;
149 
150  }
set< int >::iterator it
std::vector< fnex::SelectionType_t > fSelectionTypes
void put_or_replace(std::string const &key)
std::unique_ptr< FitEvaluation > fFitEvaluation
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
T get(std::string const &key) const
Definition: ParameterSet.h:231
std::unique_ptr< CorrectedSpectrum > fCorrectedSpectrum
fnex::BeamType_t fBeamType
std::string fShortName
Definition: Experiment.h:65
enum BeamMode string
bool fnex::NOvA_Experiment::SetEventListMap ( EventListMap const &  pEventListMap)
virtual

Implements fnex::Experiment.

Definition at line 42 of file NOvA_Experiment.cxx.

References e, allTimeWatchdog::endl, fBeamType, fCorrectedSpectrum, fEventListMap, fSelectionTypes, it, and fnex::Experiment::ShortName().

Referenced by ~NOvA_Experiment().

42  {
43  // Only add EventList objects with the appropriate selection type and beam
44  // type
45 
46  for(auto & fEventList : pEventListMap){
47 
48  if(fEventList.second.ListMetaData().BeamType() != fBeamType) continue;
49 
50  fnex::SelectionType_t seltype = fEventList.second.ListMetaData().selectionType;
51  for(auto it : fSelectionTypes){
52  if(seltype == it) fEventListMap.emplace(fEventList.first, fEventList.second);
53  }
54  }
55 
56  try{
57  fCorrectedSpectrum->GenerateSpectrumList(fEventListMap);
58  }
59  catch(cet::exception &e){
60  throw cet::exception("NOvA_Experiment")
61  << "Experiment: "
62  << this->ShortName()
63  << std::endl
64  << e;
65  }
66 
67  return true;
68  }
set< int >::iterator it
std::vector< fnex::SelectionType_t > fSelectionTypes
EventListMap fEventListMap
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
enum fnex::sel_type SelectionType_t
std::unique_ptr< CorrectedSpectrum > fCorrectedSpectrum
fnex::BeamType_t fBeamType
Float_t e
Definition: plot.C:35
const std::string ShortName() const
Definition: Experiment.h:50
const std::string fnex::Experiment::ShortName ( ) const
inlineinherited

Definition at line 50 of file Experiment.h.

References fnex::Experiment::DrawPlots(), and fnex::Experiment::fShortName.

Referenced by SetEventListMap().

50 { return fShortName; }
std::string fShortName
Definition: Experiment.h:65
const std::string fnex::NOvA_Experiment::ToString ( ) const
virtual

Implements fnex::Experiment.

Definition at line 24 of file NOvA_Experiment.cxx.

References fnex::cBeamType_Strings, fnex::cSelectionType_Strings, fBeamType, fSelectionTypes, r(), and string.

Referenced by DrawPlots(), and ~NOvA_Experiment().

24  {
25  std::string r = "NOvA";
26  for(auto seltype : fSelectionTypes)
28  return r;
29  }
std::vector< fnex::SelectionType_t > fSelectionTypes
const std::string cBeamType_Strings[4]
Definition: Constants.h:76
fnex::BeamType_t fBeamType
TRandom3 r(0)
const std::string cSelectionType_Strings[11]
Definition: Constants.h:101
enum BeamMode string

Member Data Documentation

fnex::BeamType_t fnex::NOvA_Experiment::fBeamType
private

Definition at line 59 of file NOvA_Experiment.h.

Referenced by Reconfigure(), SetEventListMap(), and ToString().

std::unique_ptr<CorrectedSpectrum> fnex::NOvA_Experiment::fCorrectedSpectrum

Definition at line 48 of file NOvA_Experiment.h.

Referenced by ApplyPoint(), DrawPlots(), FitValue(), NDOF(), Reconfigure(), and SetEventListMap().

std::unique_ptr<Correlations> fnex::NOvA_Experiment::fCorrelations

Definition at line 50 of file NOvA_Experiment.h.

EventListMap fnex::NOvA_Experiment::fEventListMap
private

Definition at line 62 of file NOvA_Experiment.h.

Referenced by SetEventListMap().

std::unique_ptr<FitEvaluation> fnex::NOvA_Experiment::fFitEvaluation

Definition at line 49 of file NOvA_Experiment.h.

Referenced by FitValue(), NDOF(), and Reconfigure().

bool fnex::Experiment::fHasPlots
protectedinherited
bool fnex::Experiment::fIsConfigured
protectedinherited
std::vector<fnex::SelectionType_t> fnex::NOvA_Experiment::fSelectionTypes
private

Definition at line 56 of file NOvA_Experiment.h.

Referenced by Reconfigure(), SetEventListMap(), and ToString().

std::string fnex::Experiment::fShortName
protectedinherited

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