13 #include "art/Framework/Core/EDProducer.h"
14 #include "art/Framework/Core/ModuleMacros.h"
15 #include "art/Framework/Principal/Event.h"
16 #include "art_root_io/TFileService.h"
17 #include "canvas/Persistency/Common/FindManyP.h"
18 #include "canvas/Utilities/InputTag.h"
19 #include "fhiclcpp/ParameterSet.h"
58 explicit TrajCluster(fhicl::ParameterSet
const& pset);
67 void GetHits(
const std::vector<recob::Hit>& inputHits,
70 void GetHits(
const std::vector<recob::Hit>& inputHits,
72 const std::vector<recob::Slice>& inputSlices,
73 art::FindManyP<recob::Hit>& hitFromSlc,
75 std::vector<int>& slcIDs);
98 #include "art/Framework/Principal/Handle.h"
99 #include "canvas/Persistency/Common/Assns.h"
100 #include "canvas/Persistency/Common/FindManyP.h"
101 #include "canvas/Utilities/Exception.h"
137 : EDProducer{pset}, fTCAlg{pset.get<fhicl::ParameterSet>(
"TrajClusterAlg")}
139 fHitModuleLabel =
"NA";
140 if (pset.has_key(
"HitModuleLabel")) fHitModuleLabel = pset.get<art::InputTag>(
"HitModuleLabel");
141 fSliceModuleLabel =
"NA";
142 if (pset.has_key(
"SliceModuleLabel"))
143 fSliceModuleLabel = pset.get<art::InputTag>(
"SliceModuleLabel");
144 fMaxSliceHits = UINT_MAX;
145 if (pset.has_key(
"MaxSliceHits")) fMaxSliceHits = pset.get<
unsigned int>(
"MaxSliceHits");
146 fSpacePointModuleLabel =
"NA";
147 if (pset.has_key(
"SpacePointModuleLabel"))
148 fSpacePointModuleLabel = pset.get<art::InputTag>(
"SpacePointModuleLabel");
149 fSpacePointHitAssnLabel =
"NA";
150 if (pset.has_key(
"SpacePointHitAssnLabel"))
151 fSpacePointHitAssnLabel = pset.get<art::InputTag>(
"SpacePointHitAssnLabel");
152 fDoWireAssns = pset.get<
bool>(
"DoWireAssns",
true);
153 fDoRawDigitAssns = pset.get<
bool>(
"DoRawDigitAssns",
true);
154 fSaveAll2DVertices =
false;
155 if (pset.has_key(
"SaveAll2DVertices")) fSaveAll2DVertices = pset.get<
bool>(
"SaveAll2DVertices");
161 producesCollector(),
"", fDoWireAssns, fDoRawDigitAssns);
163 produces<std::vector<recob::Cluster>>();
164 produces<std::vector<recob::Vertex>>();
165 produces<std::vector<recob::EndPoint2D>>();
166 produces<std::vector<recob::Seed>>();
167 produces<std::vector<recob::Shower>>();
168 produces<art::Assns<recob::Cluster, recob::Hit>>();
169 produces<art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>>();
170 produces<art::Assns<recob::Cluster, recob::Vertex, unsigned short>>();
171 produces<art::Assns<recob::Shower, recob::Hit>>();
173 produces<std::vector<recob::PFParticle>>();
174 produces<art::Assns<recob::PFParticle, recob::Cluster>>();
175 produces<art::Assns<recob::PFParticle, recob::Shower>>();
176 produces<art::Assns<recob::PFParticle, recob::Vertex>>();
177 produces<art::Assns<recob::PFParticle, recob::Seed>>();
179 produces<art::Assns<recob::Slice, recob::Cluster>>();
180 produces<art::Assns<recob::Slice, recob::PFParticle>>();
181 produces<art::Assns<recob::Slice, recob::Hit>>();
183 produces<std::vector<anab::CosmicTag>>();
184 produces<art::Assns<recob::PFParticle, anab::CosmicTag>>();
187 produces<art::Assns<recob::SpacePoint, recob::Hit>>();
194 art::ServiceHandle<art::TFileService const>
tfs;
196 showertree = tfs->make<TTree>(
"showervarstree",
"showerVarsTree");
206 if (fAlgBitNames.size() != fAlgModCount.size())
return;
207 mf::LogVerbatim myprt(
"TC");
208 myprt <<
"TrajCluster algorithm counts\n";
209 unsigned short icol = 0;
210 for (
unsigned short ib = 0; ib < fAlgModCount.size(); ++ib) {
213 << fAlgModCount[ib] <<
" ";
236 std::vector<art::Ptr<recob::Slice>>
slices;
237 std::vector<int> slcIDs;
238 unsigned int nInputHits = 0;
241 auto inputHits = art::Handle<std::vector<recob::Hit>>();
243 throw cet::exception(
"TrajClusterModule")
244 <<
"Failed to get a handle to hit collection '" <<
fHitModuleLabel.label() <<
"'\n";
245 nInputHits = (*inputHits).size();
247 throw cet::exception(
"TrajClusterModule")
248 <<
"Failed to process hits from '" <<
fHitModuleLabel.label() <<
"'\n";
253 auto sourceHits = art::Handle<std::vector<recob::Hit>>();
254 art::InputTag sourceModuleLabel(
"gaushit");
259 auto inputSlices = art::Handle<std::vector<recob::Slice>>();
263 throw cet::exception(
"TrajClusterModule") <<
"Failed to get a inputSlices";
267 auto InputSpts = art::Handle<std::vector<recob::SpacePoint>>();
270 throw cet::exception(
"TrajClusterModule") <<
"Failed to get a handle to SpacePoints\n";
271 tca::evt.
sptHits.resize((*InputSpts).size(), {{UINT_MAX, UINT_MAX, UINT_MAX}});
276 if (!hitsFromSpt.isValid())
277 throw cet::exception(
"TrajClusterModule")
278 <<
"Failed to get a handle to SpacePoint -> Hit assns\n";
280 auto& firstHit = hitsFromSpt.at(0)[0];
281 if (firstHit.id() != inputHits.id())
282 throw cet::exception(
"TrajClusterModule")
283 <<
"The SpacePoint -> Hit assn doesn't reference the input hit collection\n";
284 tca::evt.
sptHits.resize((*InputSpts).size(), {{UINT_MAX, UINT_MAX, UINT_MAX}});
285 for (
unsigned int isp = 0; isp < (*InputSpts).size(); ++isp) {
286 auto& hits = hitsFromSpt.at(isp);
287 for (
unsigned short iht = 0; iht < hits.size(); ++iht) {
288 unsigned short plane = hits[iht]->WireID().Plane;
294 if (nInputHits > 0) {
295 auto const clockData =
296 art::ServiceHandle<detinfo::DetectorClocksService const>()->DataFor(evt);
298 art::ServiceHandle<detinfo::DetectorPropertiesService const>()->DataFor(evt, clockData);
299 auto const* geom = lar::providerFrom<geo::Geometry>();
300 for (
const auto& tpcid : geom->IterateTPCIDs()) {
302 if (geom->TPC(tpcid).DriftDistance() < 25.0)
continue;
305 std::vector<std::vector<unsigned int>> sltpcHits;
306 if (inputSlices.isValid()) {
309 GetHits(*inputHits, tpcid, *inputSlices, hitFromSlc, sltpcHits, slcIDs);
314 GetHits(*inputHits, tpcid, sltpcHits);
318 if (sltpcHits.empty())
continue;
319 for (
unsigned short isl = 0; isl < sltpcHits.size(); ++isl) {
320 auto& tpcHits = sltpcHits[isl];
321 if (tpcHits.empty())
continue;
325 std::vector<HitLoc> sortVec(tpcHits.size());
326 for (
unsigned int indx = 0; indx < tpcHits.size(); ++indx) {
327 auto&
hit = (*inputHits)[tpcHits[indx]];
328 sortVec[indx].index = indx;
330 sortVec[indx].wire =
hit.WireID().Wire;
331 sortVec[indx].tick =
hit.StartTick();
332 sortVec[indx].localIndex =
hit.LocalIndex();
334 std::sort(sortVec.begin(), sortVec.end(),
SortHits);
336 for (
unsigned int ii = 0; ii < tpcHits.size(); ++ii)
337 tpcHits[ii] = tmp[sortVec[ii].index];
344 for (
unsigned short indx = 0; indx < tpcHits.size(); ++indx) {
345 auto&
hit = (*inputHits)[tpcHits[indx]];
350 std::cout <<
"Debug hit " << tpcHits[indx] <<
" found in slice ID " << slcIDs[isl];
369 std::vector<recob::Hit> hitCol;
370 std::vector<recob::Cluster> clsCol;
371 std::vector<recob::PFParticle> pfpCol;
372 std::vector<recob::Vertex> vx3Col;
373 std::vector<recob::EndPoint2D> vx2Col;
374 std::vector<recob::Seed> sedCol;
375 std::vector<recob::Shower> shwCol;
376 std::vector<anab::CosmicTag> ctCol;
378 std::vector<unsigned int> newIndex(nInputHits, UINT_MAX);
382 std::unique_ptr<art::Assns<recob::Cluster, recob::Hit>> cls_hit_assn(
383 new art::Assns<recob::Cluster, recob::Hit>);
385 std::unique_ptr<art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>> cls_vx2_assn(
386 new art::Assns<recob::Cluster, recob::EndPoint2D, unsigned short>);
387 std::unique_ptr<art::Assns<recob::Cluster, recob::Vertex, unsigned short>> cls_vx3_assn(
388 new art::Assns<recob::Cluster, recob::Vertex, unsigned short>);
390 std::unique_ptr<art::Assns<recob::Shower, recob::Hit>> shwr_hit_assn(
391 new art::Assns<recob::Shower, recob::Hit>);
393 std::unique_ptr<art::Assns<recob::PFParticle, recob::Cluster>> pfp_cls_assn(
394 new art::Assns<recob::PFParticle, recob::Cluster>);
395 std::unique_ptr<art::Assns<recob::PFParticle, recob::Shower>> pfp_shwr_assn(
396 new art::Assns<recob::PFParticle, recob::Shower>);
397 std::unique_ptr<art::Assns<recob::PFParticle, recob::Vertex>> pfp_vx3_assn(
398 new art::Assns<recob::PFParticle, recob::Vertex>);
399 std::unique_ptr<art::Assns<recob::PFParticle, anab::CosmicTag>> pfp_cos_assn(
400 new art::Assns<recob::PFParticle, anab::CosmicTag>);
401 std::unique_ptr<art::Assns<recob::PFParticle, recob::Seed>> pfp_sed_assn(
402 new art::Assns<recob::PFParticle, recob::Seed>);
404 std::unique_ptr<art::Assns<recob::Slice, recob::Cluster>> slc_cls_assn(
405 new art::Assns<recob::Slice, recob::Cluster>);
406 std::unique_ptr<art::Assns<recob::Slice, recob::PFParticle>> slc_pfp_assn(
407 new art::Assns<recob::Slice, recob::PFParticle>);
408 std::unique_ptr<art::Assns<recob::Slice, recob::Hit>> slc_hit_assn(
409 new art::Assns<recob::Slice, recob::Hit>);
411 std::unique_ptr<art::Assns<recob::SpacePoint, recob::Hit>> sp_hit_assn(
412 new art::Assns<recob::SpacePoint, recob::Hit>);
417 unsigned short slIndx;
419 unsigned short vxColIndx;
421 std::vector<slcVxStruct> vx2StrList;
423 std::vector<slcVxStruct> vx3StrList;
425 if (nInputHits > 0) {
428 unsigned int hitColBeginIndex = 0;
429 for (
unsigned short isl = 0; isl < nSlices; ++isl) {
430 unsigned short slcIndex = 0;
431 if (!slices.empty()) {
432 for (slcIndex = 0; slcIndex < slices.size(); ++slcIndex)
433 if (slices[slcIndex]->ID() == slcIDs[isl])
break;
434 if (slcIndex == slices.size())
continue;
438 if (!slc.isValid)
continue;
440 for (
auto& vx2 : slc.vtxs) {
441 if (vx2.ID <= 0)
continue;
443 if (!fSaveAll2DVertices && vx2.Vx3ID != 0)
continue;
444 unsigned int vtxID = vx2.UID;
445 unsigned int wire = std::nearbyint(vx2.Pos[0]);
460 tmp.vxColIndx = vx2Col.size() - 1;
461 vx2StrList.push_back(tmp);
465 for (
auto& vx3 : slc.vtx3s) {
466 if (vx3.ID <= 0)
continue;
468 if (vx3.Wire >= 0)
continue;
469 unsigned int vtxID = vx3.UID;
474 vx3Col.emplace_back(xyz, vtxID);
479 tmp.vxColIndx = vx3Col.size() - 1;
480 vx3StrList.push_back(tmp);
483 for (
auto& tj : slc.tjs) {
485 hitColBeginIndex = hitCol.size();
486 for (
unsigned short ipt = tj.EndPt[0]; ipt <= tj.EndPt[1]; ++ipt) {
487 auto& tp = tj.Pts[ipt];
488 if (tp.Chg <= 0)
continue;
490 std::vector<unsigned int> tpHits;
491 for (
unsigned short ii = 0; ii < tp.Hits.size(); ++ii) {
492 if (!tp.UseHit[ii])
continue;
493 if (tp.Hits[ii] > slc.slHits.size() - 1) {
break; }
494 unsigned int allHitsIndex = slc.slHits[tp.Hits[ii]].allHitsIndex;
495 if (allHitsIndex > nInputHits - 1) {
break; }
496 tpHits.push_back(allHitsIndex);
497 if (newIndex[allHitsIndex] != UINT_MAX) {
498 std::cout <<
"Bad Slice " << isl <<
" tp.Hits " << tp.Hits[ii] <<
" allHitsIndex "
500 std::cout <<
" old newIndex " << newIndex[allHitsIndex];
501 auto& oldhit = (*inputHits)[allHitsIndex];
502 std::cout <<
" old " << oldhit.WireID().Plane <<
":" << oldhit.WireID().Wire <<
":"
503 << (int)oldhit.PeakTime();
504 auto& newhit = hitCol[newIndex[allHitsIndex]];
505 std::cout <<
" new " << newhit.WireID().Plane <<
":" << newhit.WireID().Wire <<
":"
506 << (int)newhit.PeakTime();
507 std::cout <<
" hitCol size " << hitCol.size();
518 for (
auto iht : tpHits) {
519 hitCol.push_back((*inputHits)[iht]);
520 newIndex[iht] = hitCol.size() - 1;
527 if (hitCol.empty())
continue;
531 for (
unsigned int indx = hitColBeginIndex; indx < hitCol.size(); ++indx) {
532 auto&
hit = hitCol[indx];
533 sumChg +=
hit.Integral();
534 sumADC +=
hit.SummedADC();
535 if (!slices.empty() &&
536 !
util::CreateAssn(*
this, evt, hitCol, slices[slcIndex], *slc_hit_assn, indx)) {
537 throw art::Exception(art::errors::ProductRegistrationFailure)
538 <<
"Failed to associate hits with Slice";
541 geo::View_t view = hitCol[hitColBeginIndex].View();
542 auto& firstTP = tj.Pts[tj.EndPt[0]];
543 auto& lastTP = tj.Pts[tj.EndPt[1]];
548 unsigned int nclhits = hitCol.size() - hitColBeginIndex + 1;
549 clsCol.emplace_back(firstTP.Pos[0],
576 *
this, evt, clsCol, hitCol, *cls_hit_assn, hitColBeginIndex, hitCol.size())) {
577 throw art::Exception(art::errors::ProductRegistrationFailure)
578 <<
"Failed to associate hits with cluster ID " << tj.UID;
581 if (!slices.empty()) {
582 if (!
util::CreateAssn(*
this, evt, clsCol, slices[slcIndex], *slc_cls_assn)) {
583 throw art::Exception(art::errors::ProductRegistrationFailure)
584 <<
"Failed to associate slice with PFParticle";
588 for (
unsigned short end = 0;
end < 2; ++
end) {
589 if (tj.VtxID[
end] <= 0)
continue;
590 for (
auto& vx2str : vx2StrList) {
591 if (vx2str.slIndx != isl)
continue;
592 if (vx2str.ID != tj.VtxID[
end])
continue;
594 *
this, evt, *cls_vx2_assn, clsCol.size() - 1, vx2str.vxColIndx,
end)) {
595 throw art::Exception(art::errors::ProductRegistrationFailure)
596 <<
"Failed to associate cluster " << tj.UID <<
" with EndPoint2D";
598 auto& vx2 = slc.vtxs[tj.VtxID[
end] - 1];
600 for (
auto vx3str : vx3StrList) {
601 if (vx3str.slIndx != isl)
continue;
602 if (vx3str.ID != vx2.Vx3ID)
continue;
604 *
this, evt, *cls_vx3_assn, clsCol.size() - 1, vx3str.vxColIndx,
end)) {
605 throw art::Exception(art::errors::ProductRegistrationFailure)
606 <<
"Failed to associate cluster " << tj.UID <<
" with Vertex";
617 for (
auto& ss3 : slc.showers) {
618 if (ss3.ID <= 0)
continue;
626 TVector3
dir = {ss3.Dir[0], ss3.Dir[1], ss3.Dir[2]};
628 TVector3 dirErr = {ss3.DirErr[0], ss3.DirErr[1], ss3.DirErr[2]};
630 TVector3 pos = {ss3.Start[0], ss3.Start[1], ss3.Start[2]};
632 TVector3 posErr = {ss3.StartErr[0], ss3.StartErr[1], ss3.StartErr[2]};
638 shwCol.push_back(shower);
640 std::vector<unsigned int> shwHits(ss3.Hits.size());
641 for (
unsigned int iht = 0; iht < ss3.Hits.size(); ++iht)
642 shwHits[iht] = newIndex[ss3.Hits[iht]];
644 *
this, evt, *shwr_hit_assn, shwCol.size() - 1, shwHits.begin(), shwHits.end())) {
645 throw art::Exception(art::errors::ProductRegistrationFailure)
646 <<
"Failed to associate hits with Shower";
652 for (
unsigned short isl = 0; isl < nSlices; ++isl) {
653 unsigned short slcIndex = 0;
654 if (!slices.empty()) {
655 for (slcIndex = 0; slcIndex < slices.size(); ++slcIndex)
656 if (slices[slcIndex]->ID() == slcIDs[isl])
break;
657 if (slcIndex == slices.size())
continue;
661 if (!slc.isValid)
continue;
663 for (
size_t ipfp = 0; ipfp < slc.pfps.size(); ++ipfp) {
664 auto& pfp = slc.
pfps[ipfp];
665 if (pfp.ID <= 0)
continue;
667 size_t self = pfpCol.size();
668 size_t offset =
self - ipfp;
669 size_t parentIndex = UINT_MAX;
670 if (pfp.ParentUID > 0) parentIndex = pfp.ParentUID + offset - 1;
671 std::vector<size_t> dtrIndices(pfp.DtrUIDs.size());
672 for (
unsigned short idtr = 0; idtr < pfp.DtrUIDs.size(); ++idtr)
673 dtrIndices[idtr] = pfp.DtrUIDs[idtr] + offset - 1;
674 pfpCol.emplace_back(pfp.PDGCode,
self, parentIndex, dtrIndices);
677 double sp[] = {pos[0], pos[1], pos[2]};
678 double sd[] = {
dir[0],
dir[1], dir[2]};
679 double spe[] = {0., 0., 0.};
680 double sde[] = {0., 0., 0.};
681 sedCol.emplace_back(sp, sd, spe, sde);
683 std::vector<unsigned int> clsIndices;
684 for (
auto tuid : pfp.TjUIDs) {
685 unsigned int clsIndex = 0;
686 for (clsIndex = 0; clsIndex < clsCol.size(); ++clsIndex)
687 if (
abs(clsCol[clsIndex].ID()) == tuid)
break;
688 if (clsIndex == clsCol.size())
continue;
689 clsIndices.push_back(clsIndex);
697 throw art::Exception(art::errors::ProductRegistrationFailure)
698 <<
"Failed to associate clusters with PFParticle";
701 if (pfp.Vx3ID[0] > 0) {
702 for (
auto vx3str : vx3StrList) {
703 if (vx3str.slIndx != isl)
continue;
704 if (vx3str.ID != pfp.Vx3ID[0])
continue;
705 std::vector<unsigned short> indx(1, vx3str.vxColIndx);
707 *
this, evt, *pfp_vx3_assn, pfpCol.size() - 1, indx.begin(), indx.end())) {
708 throw art::Exception(art::errors::ProductRegistrationFailure)
709 <<
"Failed to associate PFParticle " << pfp.UID <<
" with Vertex";
715 if (!sedCol.empty()) {
723 pfpCol.size() - 1)) {
724 throw art::Exception(art::errors::ProductRegistrationFailure)
725 <<
"Failed to associate seed with PFParticle";
729 if (!slices.empty()) {
730 if (!
util::CreateAssn(*
this, evt, pfpCol, slices[slcIndex], *slc_pfp_assn)) {
731 throw art::Exception(art::errors::ProductRegistrationFailure)
732 <<
"Failed to associate slice with PFParticle";
736 if (pfp.PDGCode == 1111) {
737 std::vector<unsigned short> shwIndex(1, 0);
738 for (
auto& ss3 : slc.showers) {
739 if (ss3.ID <= 0)
continue;
740 if (ss3.PFPIndex == ipfp)
break;
743 if (shwIndex[0] < shwCol.size()) {
750 throw art::Exception(art::errors::ProductRegistrationFailure)
751 <<
"Failed to associate shower with PFParticle";
757 std::vector<float> tempPt1, tempPt2;
758 tempPt1.push_back(-999);
759 tempPt1.push_back(-999);
760 tempPt1.push_back(-999);
761 tempPt2.push_back(-999);
762 tempPt2.push_back(-999);
763 tempPt2.push_back(-999);
766 *
this, evt, pfpCol, ctCol, *pfp_cos_assn, ctCol.size() - 1, ctCol.size())) {
767 throw art::Exception(art::errors::ProductRegistrationFailure)
768 <<
"Failed to associate CosmicTag with PFParticle";
777 auto inputSlices = evt.getValidHandle<std::vector<recob::Slice>>(
fSliceModuleLabel);
779 for (
unsigned int allHitsIndex = 0; allHitsIndex < nInputHits; ++allHitsIndex) {
780 if (newIndex[allHitsIndex] != UINT_MAX)
continue;
781 std::vector<unsigned int> oneHit(1, allHitsIndex);
785 for (
size_t isl = 0; isl < slices.size(); ++isl) {
786 auto& hit_in_slc = hitFromSlc.at(isl);
787 for (
auto&
hit : hit_in_slc) {
788 if (
hit.key() != allHitsIndex)
continue;
792 throw art::Exception(art::errors::ProductRegistrationFailure)
793 <<
"Failed to associate old Hit with Slice";
803 for (
unsigned int allHitsIndex = 0; allHitsIndex < nInputHits; ++allHitsIndex) {
804 if (newIndex[allHitsIndex] != UINT_MAX)
continue;
805 std::vector<unsigned int> oneHit(1, allHitsIndex);
812 if (nInputHits > 0) {
817 for (
unsigned int allHitsIndex = 0; allHitsIndex < nInputHits; ++allHitsIndex) {
818 if (newIndex[allHitsIndex] == UINT_MAX)
820 auto& sp_from_hit = spFromHit.at(allHitsIndex);
821 for (
auto& sp : sp_from_hit) {
823 if (!
util::CreateAssn(*
this, evt, hitCol, sp, *sp_hit_assn, newIndex[allHitsIndex])) {
824 throw art::Exception(art::errors::ProductRegistrationFailure)
825 <<
"Failed to associate new Hit with SpacePoint";
836 std::unique_ptr<std::vector<recob::Hit>> hcol(
new std::vector<recob::Hit>(std::move(hitCol)));
837 std::unique_ptr<std::vector<recob::Cluster>> ccol(
838 new std::vector<recob::Cluster>(std::move(clsCol)));
839 std::unique_ptr<std::vector<recob::EndPoint2D>> v2col(
840 new std::vector<recob::EndPoint2D>(std::move(vx2Col)));
841 std::unique_ptr<std::vector<recob::Vertex>> v3col(
842 new std::vector<recob::Vertex>(std::move(vx3Col)));
843 std::unique_ptr<std::vector<recob::PFParticle>> pcol(
844 new std::vector<recob::PFParticle>(std::move(pfpCol)));
845 std::unique_ptr<std::vector<recob::Seed>> sdcol(
846 new std::vector<recob::Seed>(std::move(sedCol)));
847 std::unique_ptr<std::vector<recob::Shower>> scol(
848 new std::vector<recob::Shower>(std::move(shwCol)));
849 std::unique_ptr<std::vector<anab::CosmicTag>> ctgcol(
850 new std::vector<anab::CosmicTag>(std::move(ctCol)));
863 evt.put(std::move(ccol));
864 evt.put(std::move(cls_hit_assn));
865 evt.put(std::move(v2col));
866 evt.put(std::move(v3col));
867 evt.put(std::move(scol));
868 evt.put(std::move(sdcol));
869 evt.put(std::move(shwr_hit_assn));
870 evt.put(std::move(cls_vx2_assn));
871 evt.put(std::move(cls_vx3_assn));
872 evt.put(std::move(pcol));
873 evt.put(std::move(pfp_cls_assn));
874 evt.put(std::move(pfp_shwr_assn));
875 evt.put(std::move(pfp_vx3_assn));
876 evt.put(std::move(pfp_sed_assn));
877 evt.put(std::move(slc_cls_assn));
878 evt.put(std::move(slc_pfp_assn));
879 evt.put(std::move(slc_hit_assn));
880 evt.put(std::move(ctgcol));
881 evt.put(std::move(pfp_cos_assn));
882 evt.put(std::move(sp_hit_assn));
893 unsigned int tpc = tpcid.
TPC;
895 for (
size_t iht = 0; iht < inputHits.size(); ++iht) {
896 auto&
hit = inputHits[iht];
897 if (
hit.WireID().TPC == tpc) tpcHits[0].push_back(iht);
905 const std::vector<recob::Slice>& inputSlices,
906 art::FindManyP<recob::Hit>& hitFromSlc,
908 std::vector<int>& slcIDs)
913 if (!hitFromSlc.isValid())
return;
915 unsigned int tpc = tpcid.
TPC;
917 for (
size_t isl = 0; isl < inputSlices.size(); ++isl) {
918 auto& hit_in_slc = hitFromSlc.at(isl);
919 if (hit_in_slc.size() < 3)
continue;
920 int slcID = inputSlices[isl].ID();
921 for (
auto&
hit : hit_in_slc) {
922 if (
hit->WireID().TPC != tpc)
continue;
923 unsigned short indx = 0;
924 for (indx = 0; indx < slcIDs.size(); ++indx)
925 if (slcID == slcIDs[indx])
break;
926 if (indx == slcIDs.size()) {
927 slcIDs.push_back(slcID);
928 tpcHits.resize(tpcHits.size() + 1);
930 tpcHits[indx].push_back(
hit.key());
void PrintAll(detinfo::DetectorPropertiesData const &detProp, std::string someText)
void ClearResults()
Deletes all the results.
bool CreateAssnD(art::Event &evt, art::Assns< T, U, D > &assn, size_t first_index, size_t second_index, typename art::Assns< T, U, D >::data_t &&data)
Creates a single one-to-one association with associated data.
void set_start_point_err(const TVector3 &xyz_e)
then if[["$THISISATEST"==1]]
void set_dedx_err(const std::vector< double > &q)
void set_direction_err(const TVector3 &dir_e)
BEGIN_PROLOG TPC Trig offset(g4 rise time) ProjectToHeight
Utilities related to art service access.
tca::TrajClusterAlg fTCAlg
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Declaration of signal hit object.
The data type to uniquely identify a Plane.
void set_total_energy(const std::vector< double > &q)
void RunTrajClusterAlg(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, std::vector< unsigned int > &hitsInSlice, int sliceID)
art::InputTag fSliceModuleLabel
CryostatID_t Cryostat
Index of cryostat.
void set_total_MIPenergy_err(const std::vector< double > &q)
Point3_t PosAtEnd(const PFPStruct &pfp, unsigned short end)
std::vector< std::string > const & GetAlgBitNames() const
bool SortHits(HitLoc const &h1, HitLoc const &h2)
std::vector< std::array< unsigned int, 3 > > sptHits
SpacePoint -> Hits assns by plane.
static void declare_products(art::ProducesCollector &collector, std::string instance_name="", bool doWireAssns=true, bool doRawDigitAssns=true)
Declares the hit products we are going to fill.
void set_total_energy_err(const std::vector< double > &q)
static const SentryArgument_t Sentry
An instance of the sentry object.
void set_id(const int id)
bool SetInputHits(std::vector< recob::Hit > const &inputHits, unsigned int run, unsigned int event)
void DefineShTree(TTree *t)
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
unsigned int Hit
set to the hit index in evt.allHits if a Plane:Wire:Tick match is found
Helper functions to create a hit.
art::InputTag fHitModuleLabel
void set_direction(const TVector3 &dir)
void use_hits(std::unique_ptr< std::vector< recob::Hit >> &&srchits)
Uses the specified collection as data product.
int Wire
Select hit Wire for debugging.
float unitsPerTick
scale factor from Tick to WSE equivalent units
IDparameter< geo::WireID > WireID
Member type of validated geo::WireID parameter.
void put_into(art::Event &)
Moves the data into the event.
unsigned short GetSlicesSize() const
void set_length(const double &l)
auto end(FixedBins< T, C > const &) noexcept
void set_open_angle(const double &a)
A class handling a collection of hits and its associations.
const geo::GeometryCore * geom
The data type to uniquely identify a TPC.
PlaneID_t Plane
Index of the plane within its TPC.
Declaration of cluster object.
void set_total_best_plane(const int q)
View_t View(geo::PlaneID const &pid) const
Returns the view (wire orientation) on the channels of specified TPC plane.
Definition of data types for geometry description.
void set_total_MIPenergy(const std::vector< double > &q)
std::vector< TCSlice > slices
TCSlice const & GetSlice(unsigned short sliceIndex) const
art::InputTag fSpacePointModuleLabel
void GetHits(const std::vector< recob::Hit > &inputHits, const geo::TPCID &tpcid, std::vector< std::vector< unsigned int >> &tpcHits)
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.
int Tick
Select hit PeakTime for debugging (< 0 for vertex finding)
geo::PlaneID DecodeCTP(CTP_t CTP)
Produces clusters by the TrajCluster algorithm.
void produce(art::Event &evt) override
CTP_t EncodeCTP(unsigned int cryo, unsigned int tpc, unsigned int plane)
unsigned int fMaxSliceHits
void MergeTPHits(std::vector< unsigned int > &tpHits, std::vector< recob::Hit > &newHitCol, std::vector< unsigned int > &newHitAssns) const
void SetSourceHits(std::vector< recob::Hit > const &srcHits)
std::vector< PFPStruct > pfps
art::ServiceHandle< art::TFileService > tfs
void set_start_point(const TVector3 &xyz)
TPCID_t TPC
Index of the TPC within its cryostat.
void SetInputSpts(std::vector< recob::SpacePoint > const &sptHandle)
Vector3_t DirAtEnd(const PFPStruct &pfp, unsigned short end)
short recoSlice
only reconstruct the slice with ID (0 = all)
BEGIN_PROLOG could also be cout
art::InputTag fSpacePointHitAssnLabel
void set_dedx(const std::vector< double > &q)
std::vector< unsigned int > const & GetAlgModCount() const
TrajCluster(fhicl::ParameterSet const &pset)