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

Public Types

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

Public Member Functions

 FitPoint (fhicl::ParameterSet const &pset)
 
virtual ~FitPoint ()
 
void readResults (art::Results const &r)
 
void writeResults (art::Results &r)
 
void reconfigure (const fhicl::ParameterSet &p)
 
void clear ()
 
void beginJob ()
 
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 Attributes

art::ServiceHandle< art::TFileServicefTFS
 TFileService. More...
 
fhicl::ParameterSet fFitterParameters
 parameter set for all experiments to run More...
 
fhicl::ParameterSet fFakeParameters
 the fake point parameters More...
 
fhicl::ParameterSet fInitialGuessParameters
 the initial guess point parameters More...
 
fhicl::ParameterSet fManipulatorParameters
 the EventListManipulator parameters More...
 
std::unique_ptr< fnex::FitAlgorithmfFit
 algorithm for doing the fit More...
 
fnex::EventListMap fEventLists
 the lists of events we are going to use, data and MC More...
 
bool fDrawDebugPlots
 turn on/off drawing of debug plots More...
 

Detailed Description

Definition at line 37 of file FitPoint_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

fnex::FitPoint::FitPoint ( fhicl::ParameterSet const &  pset)
explicit

Definition at line 61 of file FitPoint_plugin.cc.

References fFakeParameters, fhicl::ParameterSet::is_empty(), and reconfigure().

62  {
63  this->reconfigure(pset);
64  produces<fnex::InputPoint >();
65  produces<fnex::PointResult>();
66 
67  if( !fFakeParameters.is_empty() )
68  produces<fnex::InputPoint >("FakeInput");
69 
70  return;
71  }
bool is_empty() const
void reconfigure(const fhicl::ParameterSet &p)
fhicl::ParameterSet fFakeParameters
the fake point parameters
fnex::FitPoint::~FitPoint ( )
virtual

Definition at line 74 of file FitPoint_plugin.cc.

75  {
76  }

Member Function Documentation

void fnex::FitPoint::beginJob ( )
virtual

Reimplemented from art::ResultsProducer.

Definition at line 109 of file FitPoint_plugin.cc.

110  {
111  return;
112  }
void fnex::FitPoint::clear ( )
virtual

Implements art::ResultsProducer.

Definition at line 117 of file FitPoint_plugin.cc.

References fEventLists.

118  {
119  fEventLists.clear();
120 
121  return;
122  }
fnex::EventListMap fEventLists
the lists of events we are going to use, data and MC
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
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
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 fnex::FitPoint::readResults ( art::Results const &  r)
virtual

Reimplemented from art::ResultsProducer.

Definition at line 125 of file FitPoint_plugin.cc.

References fEventLists, fInitialGuessParameters, and fManipulatorParameters.

126  {
127 
128  // the following lines are commented out until we can read the
129  // fnex::EventLists from the art file
130  // get the fnex::EventList objects for all the relevant lists
131  //art::Handle<fnex::EventList> lists;
132  //evt.getByLabel(fClusterInput, hSlices);
133 
134  //================================
135  // the code between these lines of ==== is the workaround for not being able
136  // to read in the fnex::EventLists from the art file
137  std::unique_ptr<fnex::EventListManipulator> manipulator = std::make_unique<fnex::EventListManipulator>(fManipulatorParameters,
139  fEventLists = manipulator->Deserialize();
140  //================================
141 
142  return;
143  }
fnex::EventListMap fEventLists
the lists of events we are going to use, data and MC
fhicl::ParameterSet fManipulatorParameters
the EventListManipulator parameters
fhicl::ParameterSet fInitialGuessParameters
the initial guess point parameters
void fnex::FitPoint::reconfigure ( const fhicl::ParameterSet p)

Definition at line 79 of file FitPoint_plugin.cc.

References fDrawDebugPlots, fFakeParameters, fFit, fFitterParameters, fInitialGuessParameters, fManipulatorParameters, fhicl::ParameterSet::get(), and string.

Referenced by FitPoint().

80  {
81 
82  // create the manipulator
83  fManipulatorParameters = pset.get<fhicl::ParameterSet>("EventListManipulator");
84 
85  // create the input point and put it into the data member
86  // Make input point
87  fInitialGuessParameters = pset.get<fhicl::ParameterSet>("InitialGuessInputPoint");
89 
90  // create the unique_ptr to the FitAlgorithm
91  fFitterParameters = pset.get<fhicl::ParameterSet>("FitterParameters");
92 
93  auto fitType = fFitterParameters.get<std::string>("FitType");
94 
95  if (fitType.compare("SeparatedSyst") == 0) fFit = std::make_unique<fnex::FitAlg_SeparatedSystFit>(fFitterParameters);
96  else if(fitType.compare("ROOTFactory") == 0) fFit = std::make_unique<fnex::FitAlg_ROOTFactoryFit >(fFitterParameters);
97  else
98  throw cet::exception("FitPoint")
99  << "unknown FitType: "
100  << fitType;
101 
102  // Draw debug plots?
103  fDrawDebugPlots = pset.get< bool >("DrawDebugPlots", false);
104 
105  return;
106  }
fhicl::ParameterSet fManipulatorParameters
the EventListManipulator parameters
fhicl::ParameterSet fInitialGuessParameters
the initial guess point parameters
::xsd::cxx::tree::exception< char > exception
Definition: Database.h:225
fhicl::ParameterSet fFitterParameters
parameter set for all experiments to run
bool fDrawDebugPlots
turn on/off drawing of debug plots
T get(std::string const &key) const
Definition: ParameterSet.h:231
fhicl::ParameterSet fFakeParameters
the fake point parameters
std::unique_ptr< fnex::FitAlgorithm > fFit
algorithm for doing the fit
enum BeamMode string
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 fnex::FitPoint::writeResults ( art::Results r)
virtual

Implements art::ResultsProducer.

Definition at line 146 of file FitPoint_plugin.cc.

References DEFINE_ART_RESULTS_PLUGIN, fEventLists, fFakeParameters, fFit, fInitialGuessParameters, fTFS, fnex::ShifterAndWeighter::InitShiftsAndWeightsToUse(), fnex::ShifterAndWeighter::Instance(), fhicl::ParameterSet::is_empty(), LOG_VERBATIM, art::TFileDirectory::mkdir(), gammaraytel::pr, and art::Results::put().

147  {
148 
149  // need to setup the fit algorithm object here, pass it the appropriate
150  // parameter sets and the appropriate fnex::EventLists
151  fnex::PointResult pointResult;
152 
153  std::unique_ptr<fnex::InputPoint> initialGuess = std::make_unique<fnex::InputPoint>(fInitialGuessParameters);
154  LOG_VERBATIM("FitPoint")
155  << "Initial Guess Point\n"
156  << *initialGuess;
157 
158  // get the shifter and weighter stuff ready
160 
161  fFit->Fit(fEventLists, *initialGuess, pointResult);
162  //if(fDrawDebugPlots){
163  art::TFileDirectory fitDir = fTFS->mkdir( "Fit" );
164  fFit->DrawPlots(&fitDir);
165  LOG_VERBATIM("FitPoint")
166  << "INPUT POINT WAS: \n"
167  << *initialGuess
168  << "\n"
169  << "FIT POINT WAS: \n"
170  << pointResult;
171  //}
172 
173  std::unique_ptr<fnex::PointResult> pr(new fnex::PointResult(pointResult));
174 
175  r.put(std::move(initialGuess));
176  r.put(std::move(pr));
177 
178  if( !fFakeParameters.is_empty() ){
179  std::unique_ptr<fnex::InputPoint> fakeInputPoint = std::make_unique<InputPoint>(fFakeParameters);
180  LOG_VERBATIM("FitPoint")
181  << "Fake Input Point\n"
182  << *(fakeInputPoint.get());
183 
184  r.put(std::move(fakeInputPoint), "FakeInput");
185  } // end if we are making the fake input point to store
186 
187  } // end writeResults
fnex::EventListMap fEventLists
the lists of events we are going to use, data and MC
fhicl::ParameterSet fInitialGuessParameters
the initial guess point parameters
void InitShiftsAndWeightsToUse(fnex::InputPoint const &curPoint, std::string CalibFilename="FNEX/data/calibration/CalibrationSystematics2018.root")
bool is_empty() const
TFileDirectory mkdir(std::string const &dir, std::string const &descr="")
art::ProductID put(std::unique_ptr< PROD > &&product)
Definition: Results.h:78
static ShifterAndWeighter * Instance()
art::ServiceHandle< art::TFileService > fTFS
TFileService.
fhicl::ParameterSet fFakeParameters
the fake point parameters
std::unique_ptr< fnex::FitAlgorithm > fFit
algorithm for doing the fit
#define LOG_VERBATIM(category)

Member Data Documentation

bool fnex::FitPoint::fDrawDebugPlots
private

turn on/off drawing of debug plots

Definition at line 57 of file FitPoint_plugin.cc.

Referenced by reconfigure().

fnex::EventListMap fnex::FitPoint::fEventLists
private

the lists of events we are going to use, data and MC

Definition at line 56 of file FitPoint_plugin.cc.

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

fhicl::ParameterSet fnex::FitPoint::fFakeParameters
private

the fake point parameters

Definition at line 52 of file FitPoint_plugin.cc.

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

std::unique_ptr<fnex::FitAlgorithm> fnex::FitPoint::fFit
private

algorithm for doing the fit

Definition at line 55 of file FitPoint_plugin.cc.

Referenced by reconfigure(), and writeResults().

fhicl::ParameterSet fnex::FitPoint::fFitterParameters
private

parameter set for all experiments to run

Definition at line 51 of file FitPoint_plugin.cc.

Referenced by reconfigure().

fhicl::ParameterSet fnex::FitPoint::fInitialGuessParameters
private

the initial guess point parameters

Definition at line 53 of file FitPoint_plugin.cc.

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

fhicl::ParameterSet fnex::FitPoint::fManipulatorParameters
private

the EventListManipulator parameters

Definition at line 54 of file FitPoint_plugin.cc.

Referenced by readResults(), and reconfigure().

art::ServiceHandle<art::TFileService> fnex::FitPoint::fTFS
private

TFileService.

Definition at line 50 of file FitPoint_plugin.cc.

Referenced by writeResults().


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