All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MCSFitProducer_module.cc
Go to the documentation of this file.
1 #include "art/Framework/Core/EDProducer.h"
2 #include "art/Framework/Core/ModuleMacros.h"
3 #include "art/Framework/Principal/Event.h"
4 #include "art/Framework/Principal/Handle.h"
5 
6 #include "fhiclcpp/types/Atom.h"
7 #include "fhiclcpp/types/Table.h"
8 #include "canvas/Utilities/InputTag.h"
9 
12 
14 
15 #include <memory>
16 
17 namespace trkf {
18  /**
19  * @file MCSFitProducer_module.cc
20  * @class trkf::MCSFitProducer
21  *
22  * @brief Producer for TrajectoryMCSFitter.
23  *
24  * Producer for TrajectoryMCSFitter, which performs a Maximum Likelihood fit of Multiple Coulomb Scattering angles between segments within a Track or Trajectory.
25  * It reads a recob::Track collection and produces a collection of recob::MCSFitResult where the elements are in the same order as the input collection (no explicit association is written).
26  *
27  * For configuration options see MCSFitProducer#Inputs and MCSFitProducer#Config
28  *
29  * @author G. Cerati (FNAL, MicroBooNE), based on code from L. Kalousis and D. Kaleko
30  * @date 2017
31  * @version 1.0
32  */
33  class MCSFitProducer : public art::EDProducer {
34  public:
35 
36  struct Inputs {
37  using Name = fhicl::Name;
38  using Comment = fhicl::Comment;
39  fhicl::Atom<art::InputTag> inputLabel {
40  Name("inputLabel"),
41  Comment("Label of recob::TrackTrajectory Collection to be fit")
42  };
43  };
44 
45  struct Config {
46  using Name = fhicl::Name;
47  fhicl::Table<MCSFitProducer::Inputs> inputs {
48  Name("inputs"),
49  };
50  fhicl::Table<TrajectoryMCSFitter::Config> fitter {
51  Name("fitter")
52  };
53  };
54  using Parameters = art::EDProducer::Table<Config>;
55 
56  explicit MCSFitProducer(Parameters const & p);
58 
59  // Plugins should not be copied or assigned.
60  MCSFitProducer(MCSFitProducer const &) = delete;
61  MCSFitProducer(MCSFitProducer &&) = delete;
62  MCSFitProducer & operator = (MCSFitProducer const &) = delete;
64 
65  private:
66  void produce(art::Event & e) override;
67 
69  art::InputTag inputTag;
71  };
72 }
73 
75  : EDProducer{p}, p_(p), mcsfitter(p_().fitter)
76 {
77  inputTag = art::InputTag(p_().inputs().inputLabel());
78  produces<std::vector<recob::MCSFitResult> >();
79 }
80 
82 
83 void trkf::MCSFitProducer::produce(art::Event & e)
84 {
85  //
86  auto output = std::make_unique<std::vector<recob::MCSFitResult> >();
87  //
88  art::Handle<std::vector<recob::Track> > inputH;
89  bool ok = e.getByLabel(inputTag,inputH);
90  if (!ok) throw cet::exception("MCSFitProducer") << "Cannot find input art::Handle with inputTag " << inputTag;
91  const auto& inputVec = *(inputH.product());
92  for (const auto& element : inputVec) {
93  //fit
94  recob::MCSFitResult result = mcsfitter.fitMcs(element);
95  output->emplace_back(std::move(result));
96  }
97  e.put(std::move(output));
98 }
99 
100 DEFINE_ART_MODULE(trkf::MCSFitProducer)
MCSFitProducer & operator=(MCSFitProducer const &)=delete
MCSFitProducer(Parameters const &p)
pdgs p
Definition: selectors.fcl:22
Producer for TrajectoryMCSFitter.
fhicl::Table< MCSFitProducer::Inputs > inputs
void produce(art::Event &e) override
BEGIN_PROLOG vertical distance to the surface Name
fhicl::Table< TrajectoryMCSFitter::Config > fitter
Provides recob::Track data product.
Class storing the result of the Maximum Likelihood fit of Multiple Coulomb Scattering angles between ...
Definition: MCSFitResult.h:19
art::EDProducer::Table< Config > Parameters
fhicl::Atom< art::InputTag > inputLabel
BEGIN_PROLOG sequence::SlidingWindowTriggerPatternsOppositeWindows END_PROLOG simSlidingORM6O6 effSlidingORW output
do i e
TrajectoryMCSFitter mcsfitter
Class for Maximum Likelihood fit of Multiple Coulomb Scattering angles between segments within a Trac...