Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
cmf::FitFeldmanCousinsPoint Class Reference
Inheritance diagram for cmf::FitFeldmanCousinsPoint:
art::ResultsProducer art::ProductRegistryHelper art::Consumer

Public Types

template<typename UserConfig , typename KeysToIgnore = void>
using Table = ProducerTable< UserConfig, detail::PluginConfig, KeysToIgnore >
 

Public Member Functions

 FitFeldmanCousinsPoint (fhicl::ParameterSet const &pset)
 
virtual ~FitFeldmanCousinsPoint ()
 
 FitFeldmanCousinsPoint (FitFeldmanCousinsPoint const &)=delete
 
 FitFeldmanCousinsPoint (FitFeldmanCousinsPoint &&)=delete
 
FitFeldmanCousinsPointoperator= (FitFeldmanCousinsPoint const &)=delete
 
FitFeldmanCousinsPointoperator= (FitFeldmanCousinsPoint &&)=delete
 
void readResults (art::Results const &r) override
 
void writeResults (art::Results &r) override
 
void clear () override
 
void beginJob () override
 
void reconfigure (fhicl::ParameterSet const &p)
 
void doBeginJob ()
 
void doEndJob ()
 
void doBeginSubRun (SubRunPrincipal const &)
 
void doEndSubRun (SubRunPrincipal const &)
 
void doBeginRun (RunPrincipal const &)
 
void doEndRun (RunPrincipal const &)
 
void doEvent (EventPrincipal const &)
 
void doReadResults (ResultsPrincipal const &)
 
void doWriteResults (ResultsPrincipal &)
 
void doClear ()
 
void registerProducts (MasterProductRegistry &mpr, ProductDescriptions &producedProducts, ModuleDescription const &md)
 
template<typename T , BranchType = InEvent>
ProductToken< Tconsumes (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< Tconsumes (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void consumesMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > consumesView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TconsumesView (InputTag const &it)
 
template<typename T , BranchType = InEvent>
ProductToken< TmayConsume (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ProductToken< TmayConsume (InputTag const &it)
 
template<typename T , BranchType = InEvent>
void mayConsumeMany ()
 
template<typename Element , BranchType = InEvent>
ViewToken< Element > mayConsumeView (InputTag const &)
 
template<typename T , art::BranchType BT>
art::ViewToken< TmayConsumeView (InputTag const &it)
 

Static Public Member Functions

static cet::exempt_ptr< Consumernon_module_context ()
 

Protected Member Functions

template<class P >
void produces (std::string const &instanceName={})
 
void validateConsumedProduct (BranchType const bt, ProductInfo const &pi)
 
void setModuleDescription (ModuleDescription const &md)
 
void prepareForJob (fhicl::ParameterSet const &pset)
 
void showMissingConsumes () const
 

Private Member Functions

void FillHistograms (size_t const &u, double const &chiSqrInput, cmf::OscillationParameterMap const &oscParMap, cmf::PointResult const &pr)
 
void MakeCanvases ()
 

Private Attributes

fhicl::ParameterSet fManipulatorPars
 parameters to make object for deserializing events More...
 
unsigned int fStartUniverse
 which universe to start? More...
 
unsigned int fNumUniverses
 which universe to start? More...
 
cmf::FCUniverseCollection fFakeUniverses
 the input fake universes More...
 
fhicl::ParameterSet fChiSqrCalcPars
 parameters for the ChiSqrCalculator singleton More...
 
fhicl::ParameterSet fHelperPars
 covariance fit helper parameters More...
 
fhicl::ParameterSet fMinimizerPars
 ROOT minimizer configuration. More...
 
fhicl::ParameterSet fSAWPars
 ShifterAndWeighter configuration. More...
 
std::vector< cmf::OscParamPointfPredictionLib
 library of predictions More...
 
std::string fPredictionModule
 label for module containing the prediction point library More...
 
cmf::ChiSqrCalc_t fChiSqrToUse
 chi^2 calculation methods to use for fitting More...
 
std::string fInputUniverseLabel
 module label where we get the random universes More...
 
cmf::OscParm_t fXParameter
 oscillation parameter defining the x axis of the grid More...
 
cmf::OscParm_t fYParameter
 oscillation parameter defining the y axis of the grid More...
 
float fXVal
 x value for the point in space More...
 
float fYVal
 y value for the point in space More...
 
TH1D * fFitStatus
 fit status for each universe More...
 
TH1D * fDeltaChiSqrInput
 difference in the chi^2 from the fit vs the input location More...
 
TH2D * fDeltaChiSqrVsInput
 difference in the chi^2 from the fit vs the input location More...
 
std::map< cmf::OscParm_t, TH2D * > fDeltaFitOscVals
 differences between the input and fit values More...
 
std::map< cmf::OscParm_t, TH2D * > fFitVsInputOscVals
 the input and fit values More...
 

Detailed Description

Definition at line 52 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Member Typedef Documentation

template<typename UserConfig , typename KeysToIgnore = void>
using art::ResultsProducer::Table = ProducerTable<UserConfig, detail::PluginConfig, KeysToIgnore>
inherited

Definition at line 114 of file ResultsProducer.h.

Constructor & Destructor Documentation

cmf::FitFeldmanCousinsPoint::FitFeldmanCousinsPoint ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 102 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References reconfigure(), and ~FitFeldmanCousinsPoint().

103  : fManipulatorPars(pset.get<fhicl::ParameterSet>("EventListManipulator") )
104  , fChiSqrCalcPars (pset.get<fhicl::ParameterSet>("ChiSqrCalculationParameters") )
105  , fHelperPars (pset.get<fhicl::ParameterSet>("FitHelperParameters") )
106  , fMinimizerPars (pset.get<fhicl::ParameterSet>("ROOTMinimizerParameters") )
107  , fSAWPars (pset.get<fhicl::ParameterSet>("ShifterAndWeighterParameters"))
108  {
109  this->reconfigure(pset);
110 
111  // Produce the best fit point for each universe and the spectrum for
112  // that universe
113  produces< std::vector<cmf::FCResultCollection> >();
114  }
fhicl::ParameterSet fHelperPars
covariance fit helper parameters
fhicl::ParameterSet fMinimizerPars
ROOT minimizer configuration.
fhicl::ParameterSet fManipulatorPars
parameters to make object for deserializing events
fhicl::ParameterSet fChiSqrCalcPars
parameters for the ChiSqrCalculator singleton
fhicl::ParameterSet fSAWPars
ShifterAndWeighter configuration.
void reconfigure(fhicl::ParameterSet const &p)
cmf::FitFeldmanCousinsPoint::~FitFeldmanCousinsPoint ( )
virtualdefault

Referenced by FitFeldmanCousinsPoint().

cmf::FitFeldmanCousinsPoint::FitFeldmanCousinsPoint ( FitFeldmanCousinsPoint const &  )
delete
cmf::FitFeldmanCousinsPoint::FitFeldmanCousinsPoint ( FitFeldmanCousinsPoint &&  )
delete

Member Function Documentation

void cmf::FitFeldmanCousinsPoint::beginJob ( )
overridevirtual

Reimplemented from art::ResultsProducer.

Definition at line 144 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References cmf::cOscParams_LatexScales, cmf::cOscParams_Scales, cmf::cOscParams_Strings_Latex, fChiSqrCalcPars, fDeltaChiSqrInput, fDeltaChiSqrVsInput, fDeltaFitOscVals, fFitStatus, fFitVsInputOscVals, fHelperPars, fManipulatorPars, fMinimizerPars, fNumUniverses, fPredictionModule, fSAWPars, fStartUniverse, cmf::CovarianceFitHelper::Initialize(), cmf::ParameterUtility::Instance(), cmf::CovarianceFitHelper::Instance(), cmf::IsAngleParameter(), PandAna.Demos.demo0::loc, art::TFileDirectory::make(), par, cmf::ParameterUtility::ParametersAsLocation(), and string.

145  {
146  // make some histograms
148 
149  fFitStatus = tfs->make<TH1D>("FitStatus",
150  ";Universe;Fit Status",
153  fStartUniverse + fNumUniverses);
154 
155  fDeltaChiSqrInput = tfs->make<TH1D>("DeltaChiSqrInput",
156  ";Universe;#chi^{2}_{Best Fit} - #chi^{2}_{Input}",
157  fStartUniverse + fNumUniverses,
159  fStartUniverse + fNumUniverses);
160 
161  fDeltaChiSqrVsInput = tfs->make<TH2D>("DeltaChiSqrVsInputChiSqr",
162  ";#chi^{2}_{Input};#chi^{2}_{Best Fit} - #chi^{2}_{Input}",
163  200,
164  50,
165  250,
166  40,
167  -10,
168  10);
169 
170  // make histograms of the difference between the input and best fit
171  // values for each oscillation parameter that is fit
173 
174  std::string histName1;
175  std::string histName2;
176  std::string histTitle1;
177  std::string histTitle2;
178  double lowVal;
179  double highVal;
181  // We only need to loop over the FD values as the oscillation parameters
182  // are the same in the two detectors except for the length, and that doesn't
183  // change in the fit.
184  for(auto const& itr : loc.FDLocation()){
185  if(!itr.second.IsOscPar() ||
186  itr.second.IsFixed() ) continue;
187 
188  par = (cmf::OscParm_t)itr.second.Key();
189 
190  // remember the range of the histogram is for the difference from the input
191  // value, so taking the max excursion from 0 as being the difference between
192  // the upper and lower bounds for the parameter makes sense.
193  highVal = (itr.second.UpperBound() - itr.second.LowerBound()) * cmf::cOscParams_Scales[par];
194  lowVal = -1. * highVal;
195 
196  histName1 = "Delta_" + itr.first;
197  histTitle1 = ";" + cmf::cOscParams_Strings_Latex[par] + " (Input)" + cmf::cOscParams_LatexScales[par];
198  histTitle1 += ";#Delta(" + cmf::cOscParams_Strings_Latex[par] + ")";
199  histTitle1 += cmf::cOscParams_LatexScales[par];
200 
201  histName2 = "FitVsInput_" + itr.first;
202  histTitle2 = ";" + cmf::cOscParams_Strings_Latex[par] + " (Input)";
203  histTitle2 += cmf::cOscParams_LatexScales[par];
204  histTitle2 += ";" + cmf::cOscParams_Strings_Latex[par] + " (Fit)";
205  histTitle2 += cmf::cOscParams_LatexScales[par];
206  if(cmf::IsAngleParameter(par)){
207  histTitle1 = ";sin^{2}(" + cmf::cOscParams_Strings_Latex[par] + ") (Input)";
208  histTitle1 += ";#Delta(sin^{2}(" + cmf::cOscParams_Strings_Latex[par] + "));";
209 
210  histTitle2 = ";sin^{2}(" + cmf::cOscParams_Strings_Latex[par] + ") (Input)";
211  histTitle2 += ";sin^{2}(" + cmf::cOscParams_Strings_Latex[par] + ") (Fit)";
212  }
213 
214  fDeltaFitOscVals.emplace(par,
215  tfs->make<TH2D>(histName1.c_str(),
216  histTitle1.c_str(),
217  50,
218  itr.second.LowerBound() * cmf::cOscParams_Scales[par],
219  itr.second.UpperBound() * cmf::cOscParams_Scales[par],
220  50,
221  lowVal,
222  highVal));
223 
224  lowVal = itr.second.LowerBound() * cmf::cOscParams_Scales[par];
225  highVal = itr.second.UpperBound() * cmf::cOscParams_Scales[par];
226  fFitVsInputOscVals.emplace(par,
227  tfs->make<TH2D>(histName2.c_str(),
228  histTitle2.c_str(),
229  50,
230  lowVal,
231  highVal,
232  50,
233  lowVal,
234  highVal));
235  }
236 
237  // Initialize the FitHelper - if we are only looping over the
238  // library predictions we don't need the ELM parameters
239  if(!fPredictionModule.empty()){
241  }
242  else{
247  fSAWPars);
248  }
249  }
enum cmf::osc_params OscParm_t
fhicl::ParameterSet fHelperPars
covariance fit helper parameters
Int_t par
Definition: SimpleIterate.C:24
TH1D * fDeltaChiSqrInput
difference in the chi^2 from the fit vs the input location
fhicl::ParameterSet fMinimizerPars
ROOT minimizer configuration.
unsigned int fNumUniverses
which universe to start?
unsigned int fStartUniverse
which universe to start?
const std::string cOscParams_LatexScales[kNumOscParams]
Definition: Constants.h:236
const double cOscParams_Scales[kNumOscParams]
Definition: Constants.h:214
static bool IsAngleParameter(cmf::OscParm_t const &par)
Definition: StaticFuncs.h:350
std::map< cmf::OscParm_t, TH2D * > fDeltaFitOscVals
differences between the input and fit values
fhicl::ParameterSet fManipulatorPars
parameters to make object for deserializing events
static ParameterUtility * Instance()
TH1D * fFitStatus
fit status for each universe
std::map< cmf::OscParm_t, TH2D * > fFitVsInputOscVals
the input and fit values
static CovarianceFitHelper * Instance()
const std::string cOscParams_Strings_Latex[kNumOscParams]
Definition: Constants.h:279
fhicl::ParameterSet fChiSqrCalcPars
parameters for the ChiSqrCalculator singleton
T * make(ARGS...args) const
std::string fPredictionModule
label for module containing the prediction point library
void Initialize(fhicl::ParameterSet const &helperPars, fhicl::ParameterSet const &chiSqrCalcPars, fhicl::ParameterSet const &manipulatorPars, fhicl::ParameterSet const &minimizerPars, fhicl::ParameterSet const &sawPars)
cmf::Location ParametersAsLocation()
fhicl::ParameterSet fSAWPars
ShifterAndWeighter configuration.
TH2D * fDeltaChiSqrVsInput
difference in the chi^2 from the fit vs the input location
enum BeamMode string
void cmf::FitFeldmanCousinsPoint::clear ( )
overridevirtual

Implements art::ResultsProducer.

Definition at line 252 of file CMFFitFeldmanCousinsPoint_plugin.cc.

253  {
254 
255  }
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::consumes ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::consumes ( InputTag const &  it)
inherited

Definition at line 146 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

147 {
148  if (!moduleContext_)
149  return ProductToken<T>::invalid();
150 
151  consumables_[BT].emplace_back(ConsumableType::Product,
152  TypeID{typeid(T)},
153  it.label(),
154  it.instance(),
155  it.process());
156  return ProductToken<T>{it};
157 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::consumesMany ( )
inherited

Definition at line 161 of file Consumer.h.

References T.

162 {
163  if (!moduleContext_)
164  return;
165 
166  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
167 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::consumesView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::consumesView ( InputTag const &  it)
inherited

Definition at line 171 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

172 {
173  if (!moduleContext_)
174  return ViewToken<T>::invalid();
175 
176  consumables_[BT].emplace_back(ConsumableType::ViewElement,
177  TypeID{typeid(T)},
178  it.label(),
179  it.instance(),
180  it.process());
181  return ViewToken<T>{it};
182 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
void art::ResultsProducer::doBeginJob ( )
inlineinherited

Definition at line 165 of file ResultsProducer.h.

References ana::assert(), breakpoints::beginJob(), fhicl::ParameterSetRegistry::get(), and art::Consumer::setModuleDescription().

Referenced by art::RootOutput::beginJob().

166 {
168  // Preparing the consumer for the job must be done after the
169  // constructer has been called.
170  auto const& mainID = moduleDescription_->mainParameterSetID();
171  auto const& scheduler_pset =
173  "services.scheduler");
175  prepareForJob(scheduler_pset);
176  beginJob();
177 }
static collection_type const & get() noexcept
void setModuleDescription(ModuleDescription const &md)
void prepareForJob(fhicl::ParameterSet const &pset)
assert(nhit_max >=nhit_nbins)
virtual void beginJob()
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doBeginRun ( RunPrincipal const &  rp)
inlineinherited

Definition at line 201 of file ResultsProducer.h.

References r().

Referenced by art::RootOutput::beginRun().

202 {
203  Run const r{rp, *moduleDescription_, this};
204  beginRun(r);
205 }
virtual void beginRun(Run const &)
TRandom3 r(0)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doBeginSubRun ( SubRunPrincipal const &  srp)
inlineinherited

Definition at line 187 of file ResultsProducer.h.

References sr.

Referenced by art::RootOutput::beginSubRun().

188 {
189  SubRun const sr{srp, *moduleDescription_, this};
190  beginSubRun(sr);
191 }
virtual void beginSubRun(SubRun const &)
caf::StandardRecord * sr
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doClear ( )
inlineinherited

Definition at line 229 of file ResultsProducer.h.

References clear.

Referenced by art::RootOutput::finishEndFile().

230 {
231  clear();
232 }
virtual void clear()=0
void art::ResultsProducer::doEndJob ( )
inlineinherited

Definition at line 180 of file ResultsProducer.h.

Referenced by art::RootOutput::endJob().

181 {
182  endJob();
184 }
virtual void endJob()
void showMissingConsumes() const
void art::ResultsProducer::doEndRun ( RunPrincipal const &  rp)
inlineinherited

Definition at line 208 of file ResultsProducer.h.

References r().

Referenced by art::RootOutput::endRun().

209 {
210  Run const r{rp, *moduleDescription_, this};
211  endRun(r);
212 }
virtual void endRun(Run const &)
TRandom3 r(0)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doEndSubRun ( SubRunPrincipal const &  srp)
inlineinherited

Definition at line 194 of file ResultsProducer.h.

References sr.

Referenced by art::RootOutput::endSubRun().

195 {
196  SubRun const sr{srp, *moduleDescription_, this};
197  endSubRun(sr);
198 }
caf::StandardRecord * sr
virtual void endSubRun(SubRun const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doEvent ( EventPrincipal const &  ep)
inlineinherited

Definition at line 215 of file ResultsProducer.h.

References e, and lem_server::ep.

Referenced by art::RootOutput::event().

216 {
217  Event const e{ep, *moduleDescription_, this};
218  event(e);
219 }
Float_t e
Definition: plot.C:35
virtual void event(Event const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doReadResults ( ResultsPrincipal const &  resp)
inlineinherited

Definition at line 222 of file ResultsProducer.h.

Referenced by art::RootOutput::readResults().

223 {
224  Results const res{resp, *moduleDescription_, this};
225  readResults(res);
226 }
virtual void readResults(Results const &)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::ResultsProducer::doWriteResults ( ResultsPrincipal )
inherited
void cmf::FitFeldmanCousinsPoint::FillHistograms ( size_t const &  u,
double const &  chiSqrInput,
cmf::OscillationParameterMap const &  oscParMap,
cmf::PointResult const &  pr 
)
private

Definition at line 296 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References cmf::PointResult::ChiSqr(), cmf::cOscParams_Scales, release_diff::diff, fDeltaChiSqrInput, fDeltaChiSqrVsInput, fDeltaFitOscVals, fFitStatus, fFitVsInputOscVals, cmf::PointResult::FitStatus(), cmf::IsAngleParameter(), cmf::PointResult::ParameterSpaceLocation(), cet::pow(), and std::sin().

Referenced by writeResults().

300  {
301  fFitStatus ->Fill(u, pr.FitStatus() );
302  fDeltaChiSqrInput ->Fill(u, pr.ChiSqr() - chiSqrInput);
303  fDeltaChiSqrVsInput->Fill(chiSqrInput, pr.ChiSqr() - chiSqrInput);
304 
305  double diff;
306  double fitVal;
307  double inputVal;
308  for(auto const& oscItr : pr.ParameterSpaceLocation()){
309  if(fDeltaFitOscVals.count(oscItr.first)){
310  fitVal = oscItr.second * cmf::cOscParams_Scales[oscItr.first];
311  inputVal = oscParMap.find(oscItr.first)->second * cmf::cOscParams_Scales[oscItr.first];
312  if(cmf::IsAngleParameter(oscItr.first)){
313  fitVal = std::pow(std::sin(fitVal), 2.);
314  inputVal = std::pow(std::sin(inputVal), 2.);
315  }
316  diff = (fitVal - inputVal);
317  fDeltaFitOscVals .find(oscItr.first)->second->Fill(inputVal, diff );
318  fFitVsInputOscVals.find(oscItr.first)->second->Fill(inputVal, fitVal);
319  }
320  } // end loop over oscillation parameters
321  }
constexpr T pow(T x)
Definition: pow.h:75
TH1D * fDeltaChiSqrInput
difference in the chi^2 from the fit vs the input location
const double cOscParams_Scales[kNumOscParams]
Definition: Constants.h:214
static bool IsAngleParameter(cmf::OscParm_t const &par)
Definition: StaticFuncs.h:350
std::map< cmf::OscParm_t, TH2D * > fDeltaFitOscVals
differences between the input and fit values
TH1D * fFitStatus
fit status for each universe
std::map< cmf::OscParm_t, TH2D * > fFitVsInputOscVals
the input and fit values
T sin(T number)
Definition: d0nt_math.hpp:132
TH2D * fDeltaChiSqrVsInput
difference in the chi^2 from the fit vs the input location
void cmf::FitFeldmanCousinsPoint::MakeCanvases ( )
private

Definition at line 324 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References stan::math::ceil(), fDeltaChiSqrInput, fDeltaChiSqrVsInput, fDeltaFitOscVals, fFitStatus, fFitVsInputOscVals, art::TFileDirectory::make(), and art::TFileDirectory::mkdir().

Referenced by writeResults().

325  {
327 
328  auto tfd = tfs->mkdir("Fit_Input_Comparisons");
329 
330  auto deltaVsInputCanv = tfd.make<TCanvas>("DeltaVsInputCanv",
331  "DeltaVsInputCanv",
332  1200,
333  1200);
334 
335  auto fitVsInputCanv = tfd.make<TCanvas>("FitVsInputCanv",
336  "FitVsInputCanv",
337  1200,
338  1200);
339 
340  int numDivs = std::ceil(fDeltaFitOscVals.size() * 0.5);
341  deltaVsInputCanv->Divide(numDivs, numDivs);
342  fitVsInputCanv ->Divide(numDivs, numDivs);
343 
344  numDivs = 1;
345  for(auto const& itr : fDeltaFitOscVals){
346 
347  deltaVsInputCanv->cd(numDivs);
348  itr.second->Draw("colz");
349  deltaVsInputCanv->Update();
350 
351  fitVsInputCanv->cd(numDivs);
352  fFitVsInputOscVals.find(itr.first)->second->Draw("colz");
353  fitVsInputCanv->Update();
354 
355  ++numDivs;
356  }
357 
358  deltaVsInputCanv->Write();
359  fitVsInputCanv->Write();
360 
361  auto statusCanv = tfd.make<TCanvas>("ChiSqrCanv",
362  "ChiSqrCanv",
363  1200,
364  1200);
365 
366  statusCanv->Divide(2, 2);
367  statusCanv->cd(1);
368  fFitStatus->Draw();
369  statusCanv->cd(2);
370  fDeltaChiSqrInput->Draw();
371  statusCanv->cd(3);
372  fDeltaChiSqrVsInput->Draw("colz");
373 
374  statusCanv->Update();
375  statusCanv->Write();
376  }
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
TH1D * fDeltaChiSqrInput
difference in the chi^2 from the fit vs the input location
std::map< cmf::OscParm_t, TH2D * > fDeltaFitOscVals
differences between the input and fit values
TH1D * fFitStatus
fit status for each universe
std::map< cmf::OscParm_t, TH2D * > fFitVsInputOscVals
the input and fit values
T * make(ARGS...args) const
TH2D * fDeltaChiSqrVsInput
difference in the chi^2 from the fit vs the input location
fvar< T > ceil(const fvar< T > &x)
Definition: ceil.hpp:11
template<typename T , BranchType = InEvent>
ProductToken<T> art::Consumer::mayConsume ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ProductToken<T> art::Consumer::mayConsume ( InputTag const &  it)
inherited

Definition at line 189 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

190 {
191  if (!moduleContext_)
192  return ProductToken<T>::invalid();
193 
194  consumables_[BT].emplace_back(ConsumableType::Product,
195  TypeID{typeid(T)},
196  it.label(),
197  it.instance(),
198  it.process());
199  return ProductToken<T>{it};
200 }
set< int >::iterator it
static ProductToken< T > invalid()
Definition: ProductToken.h:47
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename T , art::BranchType BT>
void art::Consumer::mayConsumeMany ( )
inherited

Definition at line 204 of file Consumer.h.

References T.

205 {
206  if (!moduleContext_)
207  return;
208 
209  consumables_[BT].emplace_back(ConsumableType::Many, TypeID{typeid(T)});
210 }
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
template<typename Element , BranchType = InEvent>
ViewToken<Element> art::Consumer::mayConsumeView ( InputTag const &  )
inherited
template<typename T , art::BranchType BT>
art::ViewToken<T> art::Consumer::mayConsumeView ( InputTag const &  it)
inherited

Definition at line 214 of file Consumer.h.

References art::InputTag::instance(), PandAna.reco_validation.prod5_pid_validation::invalid, art::InputTag::label(), art::InputTag::process(), and T.

215 {
216  if (!moduleContext_)
217  return ViewToken<T>::invalid();
218 
219  consumables_[BT].emplace_back(ConsumableType::ViewElement,
220  TypeID{typeid(T)},
221  it.label(),
222  it.instance(),
223  it.process());
224  return ViewToken<T>{it};
225 }
set< int >::iterator it
static ViewToken< Element > invalid()
Definition: ProductToken.h:75
ConsumableProducts consumables_
Definition: Consumer.h:137
double T
Definition: Xdiff_gwt.C:5
bool moduleContext_
Definition: Consumer.h:135
static cet::exempt_ptr<Consumer> art::Consumer::non_module_context ( )
staticinherited
FitFeldmanCousinsPoint& cmf::FitFeldmanCousinsPoint::operator= ( FitFeldmanCousinsPoint const &  )
delete
FitFeldmanCousinsPoint& cmf::FitFeldmanCousinsPoint::operator= ( FitFeldmanCousinsPoint &&  )
delete
void art::Consumer::prepareForJob ( fhicl::ParameterSet const &  pset)
protectedinherited
template<class P >
void art::ResultsProducer::produces ( std::string const &  instanceName = {})
inlineprotectedinherited

Definition at line 159 of file ResultsProducer.h.

160 {
161  ProductRegistryHelper::produces<P, InResults>(instanceName);
162 }
void cmf::FitFeldmanCousinsPoint::readResults ( art::Results const &  r)
overridevirtual

Reimplemented from art::ResultsProducer.

Definition at line 258 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References cmf::FCUniverseCollection::AppendFakeUniverse(), fFakeUniverses, fInputUniverseLabel, fPredictionLib, fPredictionModule, LOG_VERBATIM, LOG_WARNING, and cmf::readVectorResults().

259  {
260  std::vector<cmf::FCUniverseCollection> fcCol;
262  LOG_VERBATIM("FitFeldmanCousinsPoint")
263  << "Valid handle to std::vector<cmf::FCUniverseCollection> "
264  << "objects found in "
266  << " vector size "
267  << fcCol.size();
268 
269  // now look for the grid point we want to fit
270  auto itr = std::find(fcCol.begin(), fcCol.end(), fFakeUniverses);
271 
272  if(itr != fcCol.end()){
273  for(auto const& uni : itr->FakeUniverseVec()) fFakeUniverses.AppendFakeUniverse(uni);
274  }
275  else
276  LOG_WARNING("FitFeldmanCousinsPoint")
277  << "no collection of universes found for point "
278  << fFakeUniverses;
279  }
280 
281  // look to see if we have a prediction library to read in
282  if(fPredictionModule.empty()) return;
283 
285  LOG_VERBATIM("CovarianceMatrixFitter")
286  << "Valid handle to std::vector<cmf::OscParamPoint> "
287  << "objects found in "
289  << " "
290  << " vector size "
291  << fPredictionLib.size();
292  }
293  }
std::vector< cmf::OscParamPoint > fPredictionLib
library of predictions
cmf::FCUniverseCollection fFakeUniverses
the input fake universes
static bool readVectorResults(art::Results const &r, std::string const &module, std::string const &instance, std::vector< T > &resvec, bool clearResVec=true)
void AppendFakeUniverse(cmf::FakeUniverse const &fakeU)
#define LOG_WARNING(category)
std::string fPredictionModule
label for module containing the prediction point library
TRandom3 r(0)
#define LOG_VERBATIM(category)
std::string fInputUniverseLabel
module label where we get the random universes
void cmf::FitFeldmanCousinsPoint::reconfigure ( fhicl::ParameterSet const &  p)

Definition at line 121 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References fChiSqrToUse, fFakeUniverses, fInputUniverseLabel, fNumUniverses, fPredictionModule, fStartUniverse, fXParameter, fXVal, fYParameter, fYVal, fhicl::ParameterSet::get(), cmf::CovarianceBinUtility::Initialize(), cmf::ParameterUtility::Initialize(), cmf::PlotUtilities::Initialize(), cmf::SelectionUtility::Initialize(), cmf::CovarianceBinUtility::Instance(), cmf::ParameterUtility::Instance(), cmf::PlotUtilities::Instance(), cmf::SelectionUtility::Instance(), cmf::kGarbageFloat, string, cmf::StringToChiSqrType(), and cmf::StringToOscParmType().

Referenced by FitFeldmanCousinsPoint().

122  {
125  cmf::ParameterUtility::Instance() ->Initialize(p.get< fhicl::ParameterSet >("ParametersToUse" ));
126  cmf::PlotUtilities::Instance() ->Initialize(p.get< fhicl::ParameterSet >("PlotUtilities" ));
127 
128  fChiSqrToUse = cmf::StringToChiSqrType(p.get<std::string>("ChiSqrCalcToUse"));
129  fStartUniverse = p.get<unsigned int>("StartUniverse" );
130  fNumUniverses = p.get<unsigned int>("NumberOfUniverses" );
131  fInputUniverseLabel = p.get<std::string >("InputUniverseModule" );
132  fPredictionModule = p.get<std::string >("PredictionLibraryModule", std::string());
133 
134  // figure out the point in the grid we want
135  fXVal = p.get<float>("GridXVal", cmf::kGarbageFloat);
136  fYVal = p.get<float>("GridYVal", cmf::kGarbageFloat);
137  fXParameter = cmf::StringToOscParmType(p.get<std::string>("XParameter", "Th23" ));
138  fYParameter = cmf::StringToOscParmType(p.get<std::string>("YParameter", "Dmsq32"));
139 
141  }
cmf::OscParm_t fXParameter
oscillation parameter defining the x axis of the grid
void Initialize(fhicl::ParameterSet const &pset)
cmf::FCUniverseCollection fFakeUniverses
the input fake universes
const char * p
Definition: xmltok.h:285
static SelectionUtility * Instance()
unsigned int fNumUniverses
which universe to start?
unsigned int fStartUniverse
which universe to start?
float fXVal
x value for the point in space
static ParameterUtility * Instance()
cmf::OscParm_t fYParameter
oscillation parameter defining the y axis of the grid
static const float kGarbageFloat
Definition: Constants.h:23
void Initialize(fhicl::ParameterSet const &pset)
void Initialize(fhicl::ParameterSet const &plottingPars)
static cmf::ChiSqrCalc_t StringToChiSqrType(std::string const &str)
std::string fPredictionModule
label for module containing the prediction point library
static PlotUtilities * Instance()
void Initialize(fhicl::ParameterSet const &pset)
float fYVal
y value for the point in space
static cmf::OscParm_t StringToOscParmType(std::string const &str)
std::string fInputUniverseLabel
module label where we get the random universes
static CovarianceBinUtility * Instance()
enum BeamMode string
cmf::ChiSqrCalc_t fChiSqrToUse
chi^2 calculation methods to use for fitting
void art::ResultsProducer::registerProducts ( MasterProductRegistry mpr,
ProductDescriptions producedProducts,
ModuleDescription const &  md 
)
inlineinherited

Definition at line 128 of file ResultsProducer.h.

References fetch_tb_beamline_files::md, and art::ProductRegistryHelper::registerProducts().

Referenced by art::RootOutput::doRegisterProducts().

131  {
132  ProductRegistryHelper::registerProducts(mpr, producedProducts, md);
134  }
void registerProducts(MasterProductRegistry &mpr, ProductDescriptions &productsToRegister, ModuleDescription const &md)
cet::exempt_ptr< ModuleDescription const > moduleDescription_
void art::Consumer::setModuleDescription ( ModuleDescription const &  md)
protectedinherited
void art::Consumer::showMissingConsumes ( ) const
protectedinherited

Referenced by art::RootOutput::endJob().

void art::Consumer::validateConsumedProduct ( BranchType const  bt,
ProductInfo const &  pi 
)
protectedinherited
void cmf::FitFeldmanCousinsPoint::writeResults ( art::Results r)
overridevirtual

Implements art::ResultsProducer.

Definition at line 379 of file CMFFitFeldmanCousinsPoint_plugin.cc.

References cmf::ChiSqrCalculator::ChiSqr(), DEFINE_ART_RESULTS_PLUGIN, cmf::FCUniverseCollection::FakeUniverseVec(), fChiSqrToUse, fFakeUniverses, cmf::CovarianceFitHelper::FillDataSpectrum(), FillHistograms(), cmf::CovarianceFitHelper::FindInitialGuess(), fNumUniverses, fPredictionLib, fStartUniverse, cmf::ChiSqrCalculator::Instance(), cmf::CovarianceFitHelper::Instance(), LOG_VERBATIM, LOG_WARNING, MakeCanvases(), cmf::CovarianceFitHelper::MakeResultPlots(), cmf::CovarianceFitHelper::Minimize(), gammaraytel::pr, art::Results::put(), cmf::CovarianceFitHelper::Result(), cmf::ChiSqrCalculator::SetSpectrum(), art::to_string(), submit_hadd::u, cmf::GridPoint::X(), cmf::GridPoint::XPar(), cmf::GridPoint::Y(), and cmf::GridPoint::YPar().

380  {
381  // make the vectors we are going to write to the file
382  std::unique_ptr<std::vector<cmf::FCResultCollection> > resVec = std::make_unique<std::vector<cmf::FCResultCollection>>();
383 
384  if(!fFakeUniverses.FakeUniverseVec().empty()){
385  // loop over the input universes and fit the ones we want
386  LOG_VERBATIM("FitFeldmanCousinsPoint")
387  << "Begin fitting universes "
388  << fStartUniverse
389  << " to "
391  << " at point "
392  << fFakeUniverses
393  << " out of "
394  << fFakeUniverses.FakeUniverseVec().size()
395  << " possible universes";
396 
397  double chiSqrInput;
398 
400 
401  bool loadSpectrumFromEventLists = false;
402 
404 
406  throw cet::exception("FFCP")
407  << "requested start universe "
408  << fStartUniverse
409  << " is larger than FakeUniverseVec size "
410  << fFakeUniverses.FakeUniverseVec().size()
411  << ", so we cannot proceed.";
412  }
413 
414  size_t endU = fStartUniverse + fNumUniverses;
415  if(endU > fFakeUniverses.FakeUniverseVec().size() ){
416  LOG_WARNING("FFCP")
417  << "asking to fit universes "
418  << fStartUniverse
419  << " to "
420  << endU
421  << " but only "
422  << fFakeUniverses.FakeUniverseVec().size()
423  << " universes are available, stop there";
424 
425  endU = fFakeUniverses.FakeUniverseVec().size();
426  }
427 
428  double totalTime = 0.;
429  for(size_t u = fStartUniverse; u < endU; ++u){
430 
431  LOG_VERBATIM("FitFeldmanCousinsPoint")
432  << "universe "
433  << u
434  << " has input location of "
436 
437  // set the data spectrum for this universe
439 
440  oscParMap = fFakeUniverses.FakeUniverseVec()[u].OscParMap();
441 
442  // set the MC spectrum to the input Asimov spectrum to find the chi^2 for this universe
443  // compared to the known input values
445  chiSqrInput = cmf::ChiSqrCalculator::Instance()->ChiSqr(fChiSqrToUse, oscParMap);
446 
447  TStopwatch ts;
448  ts.Start();
449 
450  if(fPredictionLib.size() > 0){
452  }
453  else{
455  loadSpectrumFromEventLists = true;
456  }
457 
458  totalTime += ts.RealTime();
459 
460  // we have a best fit, let's grab it.
461  pr = *(cmf::CovarianceFitHelper::Instance()->Result(loadSpectrumFromEventLists));
462 
463  LOG_VERBATIM("FitFeldmanCousinsPoint")
464  << "Universe "
465  << u
466  << " best fit: "
467  << pr
468  << " compared to chi^2: "
469  << chiSqrInput
470  << "\n"
472 
473  // fill the histograms comparing this result to the input values
474  this->FillHistograms(u,
475  chiSqrInput,
476  oscParMap,
477  pr);
478 
479  // now get the expected spectrum at the best fit point
480  resVec->emplace_back(fFakeUniverses.X(),
481  fFakeUniverses.Y(),
483  fFakeUniverses.YPar());
484  resVec->back().AppendPointResultAndSpectrum(pr,
485  cmf::CovarianceFitHelper::Instance()->BestFitSpectrum(loadSpectrumFromEventLists));
486 
487  // create plots showing the minimizer progress, the false says don't use
488  // event lists to make any plots
489  cmf::CovarianceFitHelper::Instance()->MakeResultPlots("FitResults_Universe_",
490  std::to_string(u),
491  loadSpectrumFromEventLists);
492  }
493 
494  // make canvases for the histograms
495  this->MakeCanvases();
496 
497  LOG_VERBATIM("FitFeldmanCousinsPoint")
498  << "Time to fit "
499  << endU - fStartUniverse
500  << " universes: "
501  << totalTime
502  << " or "
503  << totalTime / (1. * (endU - fStartUniverse))
504  << " per universe";
505 
506  } // end if we have fake universes
507 
508  // put the output into the file
509  r.put(std::move(resVec));
510  }
void FillHistograms(size_t const &u, double const &chiSqrInput, cmf::OscillationParameterMap const &oscParMap, cmf::PointResult const &pr)
std::vector< cmf::OscParamPoint > fPredictionLib
library of predictions
std::vector< cmf::FakeUniverse > const & FakeUniverseVec() const
cmf::FCUniverseCollection fFakeUniverses
the input fake universes
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
art::ProductID put(std::unique_ptr< PROD > &&product)
Definition: Results.h:78
unsigned int fNumUniverses
which universe to start?
unsigned int fStartUniverse
which universe to start?
void Minimize(cmf::ChiSqrCalc_t const &chiSqrCalc=cmf::kCovMat)
std::map< cmf::OscParm_t, float > OscillationParameterMap
Definition: Constants.h:612
void FindInitialGuess(std::vector< cmf::OscParamPoint > const &library)
void SetSpectrum(std::vector< float > const &spectrum, bool isData)
float const & X() const
static cmf::ChiSqrCalculator * Instance()
double ChiSqr(cmf::ChiSqrCalc_t const &chiSqrCalc, std::vector< std::string > const &pars, const double *vals)
static CovarianceFitHelper * Instance()
#define LOG_WARNING(category)
void MakeResultPlots(std::string const &dirBaseName, std::string const &uniqueID=std::string(), bool fillFromLists=true)
cmf::OscParm_t const & XPar() const
float const & Y() const
#define LOG_VERBATIM(category)
std::string to_string(ModuleType mt)
Definition: ModuleType.h:32
void FillDataSpectrum(cmf::EventListColl const &eventLists)
cmf::OscParm_t const & YPar() const
std::unique_ptr< cmf::PointResult > Result(bool loadFromEventList=true)
cmf::ChiSqrCalc_t fChiSqrToUse
chi^2 calculation methods to use for fitting

Member Data Documentation

fhicl::ParameterSet cmf::FitFeldmanCousinsPoint::fChiSqrCalcPars
private

parameters for the ChiSqrCalculator singleton

Definition at line 81 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob().

cmf::ChiSqrCalc_t cmf::FitFeldmanCousinsPoint::fChiSqrToUse
private

chi^2 calculation methods to use for fitting

Definition at line 87 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by reconfigure(), and writeResults().

TH1D* cmf::FitFeldmanCousinsPoint::fDeltaChiSqrInput
private

difference in the chi^2 from the fit vs the input location

Definition at line 94 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), FillHistograms(), and MakeCanvases().

TH2D* cmf::FitFeldmanCousinsPoint::fDeltaChiSqrVsInput
private

difference in the chi^2 from the fit vs the input location

Definition at line 95 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), FillHistograms(), and MakeCanvases().

std::map<cmf::OscParm_t, TH2D*> cmf::FitFeldmanCousinsPoint::fDeltaFitOscVals
private

differences between the input and fit values

Definition at line 96 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), FillHistograms(), and MakeCanvases().

cmf::FCUniverseCollection cmf::FitFeldmanCousinsPoint::fFakeUniverses
private

the input fake universes

Definition at line 80 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by readResults(), reconfigure(), and writeResults().

TH1D* cmf::FitFeldmanCousinsPoint::fFitStatus
private

fit status for each universe

Definition at line 93 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), FillHistograms(), and MakeCanvases().

std::map<cmf::OscParm_t, TH2D*> cmf::FitFeldmanCousinsPoint::fFitVsInputOscVals
private

the input and fit values

Definition at line 97 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), FillHistograms(), and MakeCanvases().

fhicl::ParameterSet cmf::FitFeldmanCousinsPoint::fHelperPars
private

covariance fit helper parameters

Definition at line 82 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob().

std::string cmf::FitFeldmanCousinsPoint::fInputUniverseLabel
private

module label where we get the random universes

Definition at line 88 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by readResults(), and reconfigure().

fhicl::ParameterSet cmf::FitFeldmanCousinsPoint::fManipulatorPars
private

parameters to make object for deserializing events

Definition at line 77 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob().

fhicl::ParameterSet cmf::FitFeldmanCousinsPoint::fMinimizerPars
private

ROOT minimizer configuration.

Definition at line 83 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob().

unsigned int cmf::FitFeldmanCousinsPoint::fNumUniverses
private

which universe to start?

Definition at line 79 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), reconfigure(), and writeResults().

std::vector<cmf::OscParamPoint> cmf::FitFeldmanCousinsPoint::fPredictionLib
private

library of predictions

Definition at line 85 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by readResults(), and writeResults().

std::string cmf::FitFeldmanCousinsPoint::fPredictionModule
private

label for module containing the prediction point library

Definition at line 86 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), readResults(), and reconfigure().

fhicl::ParameterSet cmf::FitFeldmanCousinsPoint::fSAWPars
private

ShifterAndWeighter configuration.

Definition at line 84 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob().

unsigned int cmf::FitFeldmanCousinsPoint::fStartUniverse
private

which universe to start?

Definition at line 78 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by beginJob(), reconfigure(), and writeResults().

cmf::OscParm_t cmf::FitFeldmanCousinsPoint::fXParameter
private

oscillation parameter defining the x axis of the grid

Definition at line 89 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by reconfigure().

float cmf::FitFeldmanCousinsPoint::fXVal
private

x value for the point in space

Definition at line 91 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by reconfigure().

cmf::OscParm_t cmf::FitFeldmanCousinsPoint::fYParameter
private

oscillation parameter defining the y axis of the grid

Definition at line 90 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by reconfigure().

float cmf::FitFeldmanCousinsPoint::fYVal
private

y value for the point in space

Definition at line 92 of file CMFFitFeldmanCousinsPoint_plugin.cc.

Referenced by reconfigure().


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