16 #include "art/Framework/Core/EDProducer.h"
17 #include "art/Framework/Core/ModuleMacros.h"
18 #include "art/Framework/Principal/Event.h"
19 #include "art/Framework/Principal/Handle.h"
20 #include "art/Framework/Services/Registry/ServiceHandle.h"
21 #include "canvas/Persistency/Common/FindManyP.h"
22 #include "fhiclcpp/ParameterSet.h"
46 explicit TCShower(fhicl::ParameterSet
const&
p);
54 void produce(art::Event&
e)
override;
59 art::Ptr<recob::Slice>
const& thisslice);
78 , fTCAlg(pset.get<fhicl::ParameterSet>(
"TCAlg"))
79 , fClusterModuleLabel(pset.get<std::string>(
"ClusterModuleLabel",
"trajcluster"))
80 , fTrackModuleLabel(pset.get<std::string>(
"TrackModuleLabel",
"trajclusterKalmanTrack"))
81 , fHitModuleLabel(pset.get<std::string>(
"HitModuleLabel",
"trajcluster"))
82 , fSliceModuleLabel(pset.get<std::string>(
"SliceModuleLabel",
"dbcluster3d"))
83 , fVertexModuleLabel(pset.get<std::string>(
"VertexModuleLabel",
"trajcluster"))
84 , fCalorimetryModuleLabel(pset.get<std::string>(
"CalorimetryModuleLabel"))
86 produces<std::vector<recob::Shower>>();
87 produces<art::Assns<recob::Shower, recob::Hit>>();
88 produces<art::Assns<recob::Slice, recob::Shower>>();
96 auto showers = std::make_unique<std::vector<recob::Shower>>();
97 auto hitShowerAssociations = std::make_unique<art::Assns<recob::Shower, recob::Hit>>();
98 auto sliceShowerAssociations = std::make_unique<art::Assns<recob::Slice, recob::Shower>>();
101 art::Handle<std::vector<recob::Slice>> sliceListHandle;
102 std::vector<art::Ptr<recob::Slice>> slicelist;
103 if (evt.getByLabel(fSliceModuleLabel, sliceListHandle))
104 art::fill_ptr_vector(slicelist, sliceListHandle);
106 auto const clockData = art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
108 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
110 int foundShower = -1;
112 if (
empty(slicelist)) {
113 foundShower = getShowersWithoutSlices(evt, clockData,
detProp);
116 showers->emplace_back(fTCAlg.shwDir,
121 fTCAlg.totalEnergyErr,
126 showers->back().set_id(showers->size() - 1);
132 for (
size_t i = 0; i < slicelist.size(); ++i) {
133 std::cout <<
"---------- slice " << i <<
" ----------" << std::endl;
135 foundShower = getShowersWithSlices(evt, clockData,
detProp, slicelist[i]);
138 std::cout <<
"FOUND SHOWER " << foundShower << std::endl;
139 std::cout <<
"shower hits " << fTCAlg.showerHits.size() << std::endl;
141 showers->emplace_back(fTCAlg.shwDir,
146 fTCAlg.totalEnergyErr,
151 showers->back().set_id(showers->size() - 1);
159 evt.put(std::move(showers));
160 evt.put(std::move(hitShowerAssociations));
161 evt.put(std::move(sliceShowerAssociations));
169 art::Ptr<recob::Slice>
const& thisslice)
171 art::Handle<std::vector<recob::Hit>> hitListHandle;
172 evt.getByLabel(fHitModuleLabel, hitListHandle);
174 art::Handle<std::vector<recob::Cluster>> clusterListHandle;
175 evt.getByLabel(fClusterModuleLabel, clusterListHandle);
177 art::Handle<std::vector<recob::Track>> trackListHandle;
178 evt.getByLabel(fTrackModuleLabel, trackListHandle);
180 art::Handle<std::vector<recob::Slice>> sliceListHandle;
181 evt.getByLabel(fSliceModuleLabel, sliceListHandle);
183 art::Handle<std::vector<recob::Vertex>> vtxListHandle;
184 evt.getByLabel(fVertexModuleLabel, vtxListHandle);
186 art::Handle<std::vector<recob::PFParticle>> pfpListHandle;
187 evt.getByLabel(fHitModuleLabel, pfpListHandle);
189 art::FindManyP<recob::Hit> hitslice_fm(sliceListHandle, evt, fHitModuleLabel);
190 art::FindManyP<recob::PFParticle> pfpslice_fm(sliceListHandle, evt, fHitModuleLabel);
191 art::FindManyP<recob::Cluster> clsslice_fm(sliceListHandle, evt, fHitModuleLabel);
192 art::FindManyP<recob::Cluster> clspfp_fm(pfpListHandle, evt, fHitModuleLabel);
193 art::FindManyP<recob::Vertex> vtxpfp_fm(pfpListHandle, evt, fVertexModuleLabel);
196 std::vector<art::Ptr<recob::Hit>> hitlist;
197 std::vector<art::Ptr<recob::Cluster>> clusterlist;
198 std::vector<art::Ptr<recob::Vertex>> vertexlist;
199 std::vector<art::Ptr<recob::EndPoint2D>> vx2list;
202 hitlist = hitslice_fm.at(thisslice.key());
205 clusterlist = clsslice_fm.at(thisslice.key());
207 std::vector<art::Ptr<recob::PFParticle>> pfplist = pfpslice_fm.at(thisslice.key());
209 for (
size_t i = 0; i < pfplist.size(); ++i) {
210 std::vector<art::Ptr<recob::Vertex>> thisvtxlist = vtxpfp_fm.at(pfplist[i].key());
212 for (
size_t j = 0; j < thisvtxlist.size(); ++j) {
213 vertexlist.push_back(thisvtxlist[j]);
218 art::FindManyP<recob::Hit> cls_fm(clusterListHandle, evt, fClusterModuleLabel);
219 art::FindManyP<recob::PFParticle> hit_fm(hitListHandle, evt, fHitModuleLabel);
220 art::FindManyP<recob::Cluster> hitcls_fm(hitListHandle, evt, fClusterModuleLabel);
221 art::FindManyP<recob::Track> trkpfp_fm(pfpListHandle, evt, fTrackModuleLabel);
223 art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, evt, fCalorimetryModuleLabel);
225 return fTCAlg.makeShowers(clockData,
247 art::Handle<std::vector<recob::PFParticle>> pfpListHandle;
248 std::vector<art::Ptr<recob::PFParticle>> pfplist;
249 if (evt.getByLabel(fHitModuleLabel, pfpListHandle)) art::fill_ptr_vector(pfplist, pfpListHandle);
251 art::Handle<std::vector<recob::Hit>> hitListHandle;
252 std::vector<art::Ptr<recob::Hit>> hitlist;
253 if (evt.getByLabel(fHitModuleLabel, hitListHandle)) art::fill_ptr_vector(hitlist, hitListHandle);
255 art::Handle<std::vector<recob::Cluster>> clusterListHandle;
256 std::vector<art::Ptr<recob::Cluster>> clusterlist;
257 if (evt.getByLabel(fClusterModuleLabel, clusterListHandle))
258 art::fill_ptr_vector(clusterlist, clusterListHandle);
260 art::Handle<std::vector<recob::Vertex>> vtxListHandle;
261 std::vector<art::Ptr<recob::Vertex>> vertexlist;
262 if (evt.getByLabel(fVertexModuleLabel, vtxListHandle))
263 art::fill_ptr_vector(vertexlist, vtxListHandle);
265 art::Handle<std::vector<recob::Track>> trackListHandle;
266 evt.getByLabel(fTrackModuleLabel, trackListHandle);
269 art::FindManyP<recob::Cluster> clspfp_fm(pfpListHandle, evt, fHitModuleLabel);
270 art::FindManyP<recob::Vertex> vtxpfp_fm(pfpListHandle, evt, fVertexModuleLabel);
271 art::FindManyP<recob::Hit> cls_fm(clusterListHandle, evt, fClusterModuleLabel);
272 art::FindManyP<recob::PFParticle> hit_fm(hitListHandle, evt, fHitModuleLabel);
273 art::FindManyP<recob::Cluster> hitcls_fm(hitListHandle, evt, fClusterModuleLabel);
274 art::FindManyP<recob::Track> trkpfp_fm(pfpListHandle, evt, fTrackModuleLabel);
276 art::FindManyP<anab::Calorimetry> fmcal(trackListHandle, evt, fCalorimetryModuleLabel);
278 return fTCAlg.makeShowers(clockData,
shower::TCShowerAlg fTCAlg
int getShowersWithSlices(art::Event const &evt, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, art::Ptr< recob::Slice > const &thisslice)
int getShowersWithoutSlices(art::Event const &evt, detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp)
Declaration of signal hit object.
std::string fVertexModuleLabel
TCShower(fhicl::ParameterSet const &p)
std::string fSliceModuleLabel
TCShower & operator=(TCShower const &)=delete
std::string fTrackModuleLabel
void produce(art::Event &e) override
std::string fHitModuleLabel
std::string fClusterModuleLabel
Declaration of cluster object.
Provides recob::Track data product.
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.
Contains all timing reference information for the detector.
std::string fCalorimetryModuleLabel
bool empty(FixedBins< T, C > const &) noexcept
BEGIN_PROLOG could also be cout