13 #include "art/Framework/Core/EDProducer.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "art/Framework/Principal/Handle.h"
17 #include "art/Framework/Principal/Run.h"
18 #include "art/Framework/Principal/SubRun.h"
19 #include "canvas/Utilities/InputTag.h"
20 #include "fhiclcpp/ParameterSet.h"
22 #include "messagefacility/MessageLogger/MessageLogger.h"
43 void produce(art::Event&
e)
override;
55 , fTrackLabel(
p.get<std::string>(
"TrackLabel"))
56 , fCaloLabel(
p.get<std::string>(
"CaloLabel"))
57 , fMinTrackLength(
p.get<
float>(
"MinTrackLength"))
58 , fTrackStoppingChi2Alg(
p)
60 produces<std::vector<StoppingChi2Fit>>();
61 produces<art::Assns<recob::Track, StoppingChi2Fit>>();
62 produces<art::Assns<anab::Calorimetry, StoppingChi2Fit>>();
68 auto const trackHandle(e.getValidHandle<std::vector<recob::Track>>(
fTrackLabel));
70 std::vector<art::Ptr<recob::Track>>
tracks;
71 art::fill_ptr_vector(tracks, trackHandle);
73 art::FindManyP<anab::Calorimetry> fmTrackCalo(trackHandle, e,
fCaloLabel);
75 auto fitVec = std::make_unique<std::vector<StoppingChi2Fit>>();
76 auto trackAssns = std::make_unique<art::Assns<recob::Track, StoppingChi2Fit>>();
77 auto caloAssns = std::make_unique<art::Assns<anab::Calorimetry, StoppingChi2Fit>>();
79 for (
auto const&
track : tracks) {
84 const std::vector<art::Ptr<anab::Calorimetry>> caloVec(fmTrackCalo.at(
track.key()));
86 if (caloVec.size() != 3)
90 const unsigned int maxHits(std::max({ caloVec[0]->dEdx().size(), caloVec[1]->dEdx().size(), caloVec[2]->dEdx().size() }));
91 const int bestPlane((caloVec[2]->
dEdx().
size() == maxHits) ? 2 : (caloVec[0]->
dEdx().
size() == maxHits) ? 0 : (caloVec[1]->
dEdx().
size() == maxHits) ? 1 : -1);
101 fitVec->push_back(thisFit);
106 e.put(std::move(fitVec));
107 e.put(std::move(trackAssns));
108 e.put(std::move(caloAssns));
ClusterModuleLabel join with tracks
const art::InputTag fCaloLabel
std::size_t size(FixedBins< T, C > const &) noexcept
process_name use argoneut_mc_hitfinder track
sbn::TrackStoppingChi2Alg fTrackStoppingChi2Alg
const float fMinTrackLength
TrackStoppingChi2Fitter(fhicl::ParameterSet const &p)
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
Provides recob::Track data product.
TrackStoppingChi2Fitter & operator=(TrackStoppingChi2Fitter const &)=delete
bool CreateAssn(art::Event &evt, std::vector< T > const &a, art::Ptr< U > const &b, art::Assns< U, T > &assn, std::string a_instance, size_t index=UINT_MAX)
Creates a single one-to-one association.
StoppingChi2Fit RunFit(const std::vector< float > &dEdxVec, const std::vector< float > &resRangeVec) const
void produce(art::Event &e) override
const art::InputTag fTrackLabel