107 auto const showerHandle =
e.getValidHandle<std::vector<recob::Shower> >(
fShowerLabel);
108 auto const sliceHandle =
e.getValidHandle<std::vector<recob::Slice> >(
fPandoraLabel);
109 auto const pfpHandle =
e.getValidHandle<std::vector<recob::PFParticle> >(
fPandoraLabel);
112 std::vector<art::Ptr<recob::Shower> > showers;
113 art::fill_ptr_vector(showers, showerHandle);
115 std::vector<art::Ptr<recob::Slice> >
slices;
116 art::fill_ptr_vector(slices, sliceHandle);
118 std::vector<art::Ptr<recob::PFParticle> > pfps;
119 art::fill_ptr_vector(pfps, pfpHandle);
121 art::FindManyP<recob::PFParticle> fmSlicePFP(sliceHandle,
e,
fPandoraLabel);
122 if(!fmSlicePFP.isValid()){
123 throw cet::exception(
"ShowerSelectionVars") <<
"Slice-PFP association is somehow not valid. Stopping";
126 art::FindManyP<recob::Shower> fmPFPShower(pfpHandle,
e,
fShowerLabel);
127 if(!fmPFPShower.isValid()){
128 throw cet::exception(
"ShowerSelectionVars") <<
"PFP-Shower association is somehow not valid. Stopping";
131 art::FindManyP<recob::SpacePoint> fmShowerSP(showerHandle,
e,
fShowerLabel);
132 if(!fmShowerSP.isValid()){
133 throw cet::exception(
"ShowerSelectionVars") <<
"Shower-SP association is somehow not valid. Stopping";
136 art::FindManyP<recob::SpacePoint> fmTrackSP(showerHandle,
e,
fShowerLabel);
137 if(!fmTrackSP.isValid()){
138 throw cet::exception(
"TrackSelectionVars") <<
"Track-SP association is somehow not valid. Stopping";
141 art::FindManyP<recob::Track> fmShowerTrack(showerHandle,
e,
fShowerLabel);
142 if(!fmShowerTrack.isValid()){
143 throw cet::exception(
"ShowerSelectionVars") <<
"Shower-Track association is somehow not valid. Stopping";
153 std::map<size_t, art::Ptr<recob::PFParticle> > pfpMap;
154 for (
auto const& pfp: pfps) {
155 pfpMap[pfp->Self()] = pfp;
158 std::map<art::Ptr<recob::Shower>, std::vector<float> > showerResidualMap;
162 for (
auto const& slice: slices) {
163 std::vector<art::Ptr<recob::PFParticle> > slicePFPs(fmSlicePFP.at(slice.key()));
165 if (slicePFPs.empty())
168 art::Ptr<recob::PFParticle> pfpNeutrino;
169 for (
auto const& pfp: slicePFPs) {
176 if (pfpNeutrino.isNull())
179 std::vector<art::Ptr<recob::Shower>> primaryShowers;
180 for (
auto const& daughterID: pfpNeutrino->Daughters()) {
181 const auto& pfp(pfpMap[daughterID]);
182 if (pfp->PdgCode()==11) {
183 primaryShowers.push_back(fmPFPShower.at(pfp.key()).
front());
187 if (primaryShowers.size()<2)
190 for (
auto const&
shower: primaryShowers){
195 std::unique_ptr<std::vector<float> >residualCol(std::make_unique<std::vector<float> >());
196 std::unique_ptr<std::vector<sbn::ShowerDensityFit> > densityFitCol(std::make_unique<std::vector<sbn::ShowerDensityFit> >());
197 std::unique_ptr<std::vector<sbn::ShowerTrackFit> > trackFitCol(std::make_unique<std::vector<sbn::ShowerTrackFit> >());
199 std::unique_ptr<art::Assns<recob::Shower, float> >
200 residualAssns(std::make_unique<art::Assns<recob::Shower, float> >());
201 std::unique_ptr<art::Assns<recob::Shower, sbn::ShowerDensityFit> >
202 densityFitAssns(std::make_unique<art::Assns<recob::Shower, sbn::ShowerDensityFit> >());
203 std::unique_ptr<art::Assns<recob::Shower, sbn::ShowerTrackFit> >
204 trackFitAssns(std::make_unique<art::Assns<recob::Shower, sbn::ShowerTrackFit> >());
206 for (
auto const&
shower: showers){
208 for (
auto const res: showerResidualMap[
shower]) {
209 residualCol->push_back(res);
214 densityFitCol->push_back(showerDensityFit);
217 const std::vector<art::Ptr<recob::Track> > showerTrackVec(fmShowerTrack.at(shower.key()));
220 trackFitCol->push_back(showerTrackFit);
224 e.put(std::move(residualCol));
225 e.put(std::move(densityFitCol));
226 e.put(std::move(trackFitCol));
228 e.put(std::move(residualAssns));
229 e.put(std::move(densityFitAssns));
230 e.put(std::move(trackFitAssns));
const art::InputTag fShowerLabel
sbn::ShowerTrackFit TrackFinder(const recob::Shower &shower, const recob::Track &track, const std::vector< art::Ptr< recob::SpacePoint > > &sps) const
const art::InputTag fPandoraLabel
sbn::ShowerDensityFit DensityFitter(const recob::Shower &shower, const std::vector< art::Ptr< recob::SpacePoint > > &sps) const
std::vector< TCSlice > slices
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.
std::vector< float > ResidualFinder(const art::Ptr< recob::Shower > &primaryShower, const std::vector< art::Ptr< recob::Shower >> &sliceShowers) const