Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
cmf::ParameterUtility Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-04-19/CovarianceMatrixFit/utilities/ParameterUtility.h"

Public Member Functions

void Initialize (fhicl::ParameterSet const &pset)
 
bool UseSysPar (std::string const &parName)
 
cmf::Parameter const & ParameterInfo (std::string const &parName) const
 
cmf::Parameter const & OscParameterInfo (std::string const &parName, cmf::DetType_t const &det=cmf::kFARDET) const
 
cmf::Parameter const & SysParameterInfo (std::string const &parName) const
 
cmf::Location ParametersAsLocation ()
 
std::set< std::stringSysParNames () const
 
std::set< uint8_t > SysParKeys () const
 
std::vector< cmf::Parameter > const & SysParameters (cmf::DetType_t const &det=cmf::kFARDET) const
 

Static Public Member Functions

static ParameterUtilityInstance ()
 

Private Member Functions

 ParameterUtility ()
 
 ~ParameterUtility ()
 

Private Attributes

std::vector< cmf::ParameterSpaceLocfDetOscParameters
 values for the oscillation parameters in each detector More...
 
std::vector< cmf::ParameterSpaceLocfDetSysParameters
 values for the systematic parameters in each detector More...
 

Detailed Description

Definition at line 25 of file ParameterUtility.h.

Constructor & Destructor Documentation

cmf::ParameterUtility::ParameterUtility ( )
private

Definition at line 92 of file ParameterUtility.cxx.

Referenced by Instance().

93  {
94  }
cmf::ParameterUtility::~ParameterUtility ( )
private

Member Function Documentation

void cmf::ParameterUtility::Initialize ( fhicl::ParameterSet const &  pset)

Definition at line 97 of file ParameterUtility.cxx.

References cmf::cDetType_Strings(), cmf::Location::DetectorLocation(), cmf::SelectionUtility::DetectorsToUse(), msf_helper::dets, fDetOscParameters, fDetSysParameters, fhicl::ParameterSet::get(), cmf::SelectionUtility::Instance(), PandAna.Demos.demo0::loc, MF_LOG_VERBATIM, cmf::ParameterSpaceLoc::Parameters(), and cmf::ParameterSetToLocation().

Referenced by cmf::PredictionLibraryMaker::PredictionLibraryMaker(), cmf::CMFSpectraMaker::reconfigure(), cmf::SpectraFromPredictions::reconfigure(), cmf::CovarianceMatrixFitter::reconfigure(), cmf::ContourFromGrid::reconfigure(), cmf::CovarianceMatrixMaker::reconfigure(), cmf::ContourFromLibrary::reconfigure(), cmf::GridPointsBestFit::reconfigure(), cmf::RandomUniverses::reconfigure(), cmf::FitFeldmanCousinsPoint::reconfigure(), cmf::DSTToEventList::reconfigure(), and cmf::CAFToEventList::reconfigure().

98  {
99  // have default empty vectors for these which is what we expect if
100  // making the event lists
101  std::vector<std::string> psetNames({"OscillationParameters",
102  "SystematicParameters"});
103 
105  for(auto const& detItr : dets){
106  for(auto const& nameItr : psetNames){
107  cmf::Location loc(dets);
108  cmf::ParameterSetToLocation(pset.get<fhicl::ParameterSet>(nameItr), detItr, loc);
109 
110  if(nameItr.find("Oscillation") != std::string::npos)
111  fDetOscParameters.emplace_back(detItr, loc.DetectorLocation(detItr).Parameters());
112  else if(nameItr.find("Systematic") != std::string::npos)
113  fDetSysParameters.emplace_back(detItr, loc.DetectorLocation(detItr).Parameters());
114 
115  } // end loop over parameter set names
116  } // end loop over detectors
117 
118  MF_LOG_VERBATIM("cmf::CovarianceMatrixMaker")
119  << "\n-------------------------------------------------------"
120  << "\nPARAMETER SUMMARY"
121  << "\n-------------------------------------------------------";
122 
123  for(auto const& itr : fDetSysParameters){
124  MF_LOG_VERBATIM("ParameterUtility")
125  << "\n=======================================================\n"
126  << cmf::cDetType_Strings[itr.Detector()]
127  << "\n======================================================="
128  << "\n\nRunning with systematic parameters set to \n";
129 
130  for(auto const& parItr : itr.Parameters()){
131  MF_LOG_VERBATIM("ParameterUtility")
132  << " -- parameter: "
133  << std::setw(30)
134  << parItr.Name()
135  << " val: "
136  << std::setw(15)
137  << parItr.Value()
138  << " fixed: "
139  << std::setw(3)
140  << parItr.IsFixed();
141  } // end loop over parameters for detector
142 
143  MF_LOG_VERBATIM("ParameterUtility")
144  << "\nRunning with oscillation parameters set to \n";
145  for(auto const& odItr : fDetOscParameters){
146  if(odItr.Detector() != itr.Detector()) continue;
147  for(auto const& oscItr : odItr.Parameters()){
148  MF_LOG_VERBATIM("ParameterUtility")
149  << " -- parameter: "
150  << std::setw(30)
151  << oscItr.Name()
152  << " val: "
153  << std::setw(15)
154  << oscItr.Value()
155  << " fixed: "
156  << std::setw(3)
157  << oscItr.IsFixed();
158  } // end loop over oscillation parameters
159  } // end loop over detectors for oscillation parameters
160  } // end loop over systematic parameter detectors
161  }
std::vector< cmf::ParameterSpaceLoc > fDetOscParameters
values for the oscillation parameters in each detector
const std::vector< std::string > cDetType_Strings({"UnknownDet","NearDet","FarDet","MINOSNear","MINOSFar","AllDetectors"})
static SelectionUtility * Instance()
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector
void ParameterSetToLocation(fhicl::ParameterSet const &pset, cmf::DetType_t const &det, cmf::Location &loc)
std::set< cmf::DetType_t > const & DetectorsToUse()
#define MF_LOG_VERBATIM(category)
ParameterUtility * cmf::ParameterUtility::Instance ( )
static

Definition at line 84 of file ParameterUtility.cxx.

References cmf::gParUtil, and ParameterUtility().

Referenced by cmf::CovarianceMatrixMaker::beginJob(), cmf::RandomUniverses::beginJob(), cmf::FitFeldmanCousinsPoint::beginJob(), cmf::ChiSqrCalculator::ChiSqrNuisance(), cmf::CMFDecorrelator::CMFDecorrelator(), cmf::CMFSpectraMaker::endJob(), cmf::CovarianceMatrixFitter::FillDataSpectrum(), cmf::EventListManipulator::FillEventList(), cmf::SpectrumPredictionMaker::Initialize(), cmf::CovarianceFitHelper::InitializeGlobalVars(), cmf::CovarianceFitHelper::InitializeMinimizer(), cmf::CovarianceFitHelper::InitializeShifterAndWeighter(), cmf::CovarianceFitHelper::MinimizeCP(), cmf::PredictionLibraryMaker::PredictionLibraryMaker(), cmf::CMFSpectraMaker::reconfigure(), cmf::ContourFromGrid::reconfigure(), cmf::SpectraFromPredictions::reconfigure(), cmf::CovarianceMatrixFitter::reconfigure(), cmf::CovarianceMatrixMaker::reconfigure(), cmf::ContourFromLibrary::reconfigure(), cmf::GridPointsBestFit::reconfigure(), cmf::RandomUniverses::reconfigure(), cmf::FitFeldmanCousinsPoint::reconfigure(), cmf::DSTToEventList::reconfigure(), cmf::CAFToEventList::reconfigure(), cmf::CovarianceMatrixMaker::SetSystematicParameter(), and cmf::CovarianceMatrixMaker::writeResults().

84  {
85  if(gParUtil == nullptr)
86  gParUtil = new ParameterUtility();
87 
88  return gParUtil;
89  }
static ParameterUtility * gParUtil
cmf::Parameter const & cmf::ParameterUtility::OscParameterInfo ( std::string const &  parName,
cmf::DetType_t const &  det = cmf::kFARDET 
) const

Definition at line 164 of file ParameterUtility.cxx.

References cmf::cDetType_Strings(), fillBadChanDBTables::det, and fDetOscParameters.

Referenced by ParameterInfo().

166  {
167  // TODO this method returns the first parameter from any detector matching the name
168  // we should probably match the detector too, but as of March 2021, nothing calls it
169  for(auto const& dopItr : fDetOscParameters){
170  if(dopItr.Detector() != det) continue;
171 
172  if(dopItr.count(parName) < 1)
173  throw cet::exception("ParameterUtility")
174  << "oscillation parameter "
175  << parName
176  << " is not in the list for the "
178  << " detector";
179 
180  return dopItr.Parameter(parName);
181  } // end loop over detectors
182 
183  // we should never get here, but make the compiler happy
184  return fDetOscParameters.front().Parameter(parName);
185  }
std::vector< cmf::ParameterSpaceLoc > fDetOscParameters
values for the oscillation parameters in each detector
const std::vector< std::string > cDetType_Strings({"UnknownDet","NearDet","FarDet","MINOSNear","MINOSFar","AllDetectors"})
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
cmf::Parameter const & cmf::ParameterUtility::ParameterInfo ( std::string const &  parName) const

Definition at line 207 of file ParameterUtility.cxx.

References cmf::IsOscillationParameter(), OscParameterInfo(), and SysParameterInfo().

Referenced by cmf::ChiSqrCalculator::ChiSqrNuisance(), cmf::CovarianceFitHelper::InitializeMinimizer(), and cmf::CovarianceFitHelper::MinimizeCP().

208  {
209  // the oscillation parameters are the same in all detectors, so the
210  // default of the NOvA FD is fine
211  if(cmf::IsOscillationParameter(parName))
212  return this->OscParameterInfo(parName);
213 
214  // if we don't have an oscillation parameter it must be a systematic parameter
215  return this->SysParameterInfo(parName);
216  }
cmf::Parameter const & OscParameterInfo(std::string const &parName, cmf::DetType_t const &det=cmf::kFARDET) const
static bool IsOscillationParameter(std::string const &str)
cmf::Parameter const & SysParameterInfo(std::string const &parName) const
cmf::Location cmf::ParameterUtility::ParametersAsLocation ( )

Definition at line 230 of file ParameterUtility.cxx.

References fDetOscParameters, fDetSysParameters, and PandAna.Demos.demo0::loc.

Referenced by cmf::RandomUniverses::beginJob(), cmf::FitFeldmanCousinsPoint::beginJob(), cmf::CMFDecorrelator::CMFDecorrelator(), cmf::SpectrumPredictionMaker::Initialize(), cmf::CovarianceFitHelper::InitializeGlobalVars(), cmf::CovarianceFitHelper::InitializeShifterAndWeighter(), cmf::CMFSpectraMaker::reconfigure(), and cmf::CovarianceMatrixMaker::writeResults().

231  {
232 
233  // loop over the detectors we are using and combine the systematic
234  // and oscillation parameters
235  std::vector<cmf::ParameterSpaceLoc> pslVec;
236 
237  for(auto const& itr : fDetOscParameters){
238  std::vector<cmf::Parameter> detPars;
239 
240  for(auto const& oscParItr : itr.Parameters()){
241  detPars.emplace_back(oscParItr);
242  }
243 
244  for(auto const& sysDetItr : fDetSysParameters){
245  if(sysDetItr.Detector() == itr.Detector()){
246  for(auto const& sysParItr : sysDetItr.Parameters()){
247  detPars.emplace_back(sysParItr);
248  }
249  }
250  } // end loop to get systematic parameters for the detector
251 
252  pslVec.emplace_back(itr.Detector(), detPars);
253  }
254 
255  cmf::Location loc(pslVec);
256 
257  return std::move(loc);
258  }
std::vector< cmf::ParameterSpaceLoc > fDetOscParameters
values for the oscillation parameters in each detector
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector
cmf::Parameter const & cmf::ParameterUtility::SysParameterInfo ( std::string const &  parName) const

Definition at line 188 of file ParameterUtility.cxx.

References fDetSysParameters.

Referenced by ParameterInfo().

189  {
190  // TODO this method returns the first parameter from any detector matching the name
191  // we should probably match the detector too, but as of March 2021, nothing calls it
192  for(auto const& dspItr : fDetSysParameters){
193  if(dspItr.count(parName) < 1)
194  throw cet::exception("ParameterUtility")
195  << "systematic parameter "
196  << parName
197  << " is not in the list";
198 
199  return dspItr.Parameter(parName);
200  } // end loop over detectors
201 
202  // we should never get here, but make the compiler happy
203  return fDetSysParameters.front().Parameter(parName);
204  }
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector
std::vector< cmf::Parameter > const & cmf::ParameterUtility::SysParameters ( cmf::DetType_t const &  det = cmf::kFARDET) const

Definition at line 285 of file ParameterUtility.cxx.

References fillBadChanDBTables::det, and fDetSysParameters.

286  {
287  for(auto const& itr : fDetSysParameters){
288  if(itr.Detector() == det) return itr.Parameters();
289  }
290 
291  // if there are no systematic parameters for this detector return an
292  // empty vector.
293  std::vector<cmf::Parameter> emptyParVec;
294  return std::move(emptyParVec);
295  }
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector
std::set< uint8_t > cmf::ParameterUtility::SysParKeys ( ) const

Definition at line 273 of file ParameterUtility.cxx.

References fDetSysParameters.

Referenced by cmf::EventListManipulator::FillEventList().

274  {
275  std::set<uint8_t> parKeys;
276  for(auto const& itr : fDetSysParameters){
277  for(auto const& parItr : itr.Parameters())
278  parKeys.emplace(parItr.Key());
279  }
280 
281  return std::move(parKeys);
282  }
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector
std::set< std::string > cmf::ParameterUtility::SysParNames ( ) const

Definition at line 261 of file ParameterUtility.cxx.

References fDetSysParameters.

Referenced by cmf::CMFSpectraMaker::endJob(), and cmf::CovarianceMatrixMaker::writeResults().

262  {
263  std::set<std::string> parNames;
264  for(auto const& itr : fDetSysParameters){
265  for(auto const& parItr : itr.Parameters())
266  parNames.emplace(parItr.Name());
267  }
268 
269  return std::move(parNames);
270  }
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector
bool cmf::ParameterUtility::UseSysPar ( std::string const &  parName)

Definition at line 219 of file ParameterUtility.cxx.

References fDetSysParameters.

220  {
221  // the systematic parameters could be different, so check all the lists
222  for(auto const& dspItr : fDetSysParameters){
223  if(dspItr.count(parName) > 0 ) return true;
224  }
225 
226  return false;
227  }
std::vector< cmf::ParameterSpaceLoc > fDetSysParameters
values for the systematic parameters in each detector

Member Data Documentation

std::vector<cmf::ParameterSpaceLoc> cmf::ParameterUtility::fDetOscParameters
private

values for the oscillation parameters in each detector

Definition at line 55 of file ParameterUtility.h.

Referenced by Initialize(), OscParameterInfo(), and ParametersAsLocation().

std::vector<cmf::ParameterSpaceLoc> cmf::ParameterUtility::fDetSysParameters
private

values for the systematic parameters in each detector

Definition at line 56 of file ParameterUtility.h.

Referenced by Initialize(), ParametersAsLocation(), SysParameterInfo(), SysParameters(), SysParKeys(), SysParNames(), and UseSysPar().


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