38 #include "art/Framework/Services/Registry/ServiceHandle.h"
39 #include "canvas/Persistency/Common/Ptr.h"
40 #include "fhiclcpp/ParameterSet.h"
61 verbose = pset.get<
bool>(
"Verbose");
75 fWirePitch = geom->WirePitch();
77 fWiretoCm = fWirePitch;
78 fTimetoCm = fTimeTick * fDriftVelocity;
79 fWireTimetoCmCm = (fTimeTick * fDriftVelocity) / fWirePitch;
81 ClearandResizeVectors();
84 if (allHits.size() == 0) {
89 art::Ptr<recob::Hit> theHit;
92 for (
std::vector<art::Ptr<recob::Hit>>::iterator HitIter = allHits.begin();
93 HitIter != allHits.end();
96 unsigned int p(0),
w(0), t(0), cs(0);
97 GetPlaneAndTPC(*HitIter,
p, cs, t,
w);
99 hitlistbyplane[
p].push_back(theHit);
112 for (
unsigned int ip = 0; ip < fNPlanes; ip++) {
113 hitlistrefined[ip] = CreateHighHitlist(gser, hitlistbyplane[ip], hitlistleftover[ip]);
117 std::cout <<
"At plane " << ip <<
", found " << hitlistrefined[ip].size() <<
" hits with "
118 << hitlistleftover[ip].size() <<
" leftover" << std::endl;
149 for (
unsigned int iplane = 0; iplane < fNPlanes; iplane++) {
151 if (hitlistrefined[iplane].
size() == 0)
continue;
156 std::vector<art::Ptr<recob::Hit>> splittingVector = hitlistrefined[iplane];
158 while (splittingVector.size() != 0) {
166 std::vector<int> index;
167 std::vector<art::Ptr<recob::Hit>> thiscluster;
173 art::Ptr<recob::Hit> theHit = splittingVector.front();
175 double time = theHit->PeakTime();
176 unsigned int plane(0), cstat(0), tpc(0), wire(0);
177 GetPlaneAndTPC(theHit, plane, cstat, tpc, wire);
179 SelectLocalHitlist(gser, splittingVector, thiscluster, wire, time, fRadiusSizePar, index);
182 std::cout <<
"Done writing " << thiscluster.size() <<
" hits to cluster with ID "
183 << plane * 100 + i << std::endl;
185 smallClustList[plane].push_back(thiscluster);
188 while (index.size() != 0) {
189 splittingVector.erase(splittingVector.begin() + (index.back()));
202 smallClustList.clear();
203 hitlistbyplane.clear();
204 hitlistrefined.clear();
205 hitlistleftover.clear();
206 smallClustList.resize(fNPlanes);
207 hitlistbyplane.resize(fNPlanes);
208 hitlistrefined.resize(fNPlanes);
209 hitlistleftover.resize(fNPlanes);
223 double radlimit)
const
226 for (
std::vector<art::Ptr<recob::Hit>>::const_iterator hitIter = hitlist.begin();
227 hitIter != hitlist.end();
229 art::Ptr<recob::Hit> theHit = (*hitIter);
230 double time = theHit->PeakTime();
231 unsigned int plane, cstat, tpc, wire;
232 GetPlaneAndTPC(theHit, plane, cstat, tpc, wire);
236 double linear_dist = gser.
Get2DDistance(wire, time, wire_start, time_start);
238 if (linear_dist < radlimit) hitlistlocal.push_back(theHit);
253 std::vector<int>& index)
const
257 for (
std::vector<art::Ptr<recob::Hit>>::const_iterator hitIter = hitlist.begin();
258 hitIter != hitlist.end();
260 art::Ptr<recob::Hit> theHit = (*hitIter);
261 double time = theHit->PeakTime();
262 unsigned int plane, cstat, tpc, wire;
263 GetPlaneAndTPC(theHit, plane, cstat, tpc, wire);
267 double linear_dist = gser.
Get2DDistance(wire, time, wire_start, time_start);
269 if (linear_dist < radlimit) {
270 hitlistlocal.push_back(theHit);
279 std::sort(index.begin(), index.end());
287 std::vector<art::Ptr<recob::Hit>>
291 std::vector<art::Ptr<recob::Hit>>& leftovers)
const
294 std::vector<art::Ptr<recob::Hit>>
297 std::vector<art::Ptr<recob::Hit>> hitlistlocal;
299 for (
unsigned int ix = 0; ix < hitlist.size(); ix++) {
301 art::Ptr<recob::Hit>
const& theHit = hitlist[ix];
303 double time = theHit->PeakTime();
304 unsigned int plane(0), cstat(0), tpc(0), wire(0);
306 GetPlaneAndTPC(theHit, plane, cstat, tpc, wire);
311 SelectLocalHitlist(gser, hitlist, hitlistlocal, (
double)wire, time, fRadiusSizePar);
313 if (hitlistlocal.size() < fNHitsInClust) {
314 hitlist_total.push_back(theHit);
316 std::cout <<
" adding hit @ w,t " << wire <<
" " << time <<
" on plane " << plane
321 leftovers.push_back(theHit);
324 hitlistlocal.clear();
333 return hitlist_total;
341 unsigned int&
w)
const
343 art::ServiceHandle<geo::Geometry const> geom;
344 unsigned int channel =
a->Channel();
345 geom->ChannelToWire(channel);
346 p =
a->WireID().Plane;
348 w =
a->WireID().Wire;
354 std::vector<std::vector<art::Ptr<recob::Hit>>>
357 if (iPlane < fNPlanes)
358 return smallClustList[iPlane];
360 std::vector<std::vector<art::Ptr<recob::Hit>>> vec;
365 std::vector<art::Ptr<recob::Hit>>
368 if (iPlane < fNPlanes)
369 return hitlistleftover[iPlane];
371 std::vector<art::Ptr<recob::Hit>> vec;
std::vector< art::Ptr< recob::Hit > > CreateHighHitlist(util::GeometryUtilities const &gser, std::vector< art::Ptr< recob::Hit >> const &hitlist, std::vector< art::Ptr< recob::Hit >> &hitlistleftover) const
Utilities related to art service access.
Double_t Get2DDistance(Double_t wire1, Double_t time1, Double_t wire2, Double_t time2) const
Declaration of signal hit object.
void ClearandResizeVectors()
double Temperature() const
In kelvin.
std::size_t size(FixedBins< T, C > const &) noexcept
void FindSmallClusters(util::GeometryUtilities const &gser, detinfo::DetectorClocksData const &dataClocks, detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> allHits)
int GetPlaneAndTPC(art::Ptr< recob::Hit > a, unsigned int &plane, unsigned int &cryostat, unsigned int &time, unsigned int &wire) const
void SelectLocalHitlist(util::GeometryUtilities const &gser, std::vector< art::Ptr< recob::Hit >> hitlist, std::vector< art::Ptr< recob::Hit >> &hitlistlocal, double wire_start, double time_start, double radlimit) const
double Efield(unsigned int planegap=0) const
kV/cm
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< art::Ptr< recob::Hit > > GetLeftoversByPlane(unsigned int iPlane)
double DriftVelocity(double efield=0., double temperature=0.) const
cm/us
Definition of data types for geometry description.
Contains all timing reference information for the detector.
std::vector< std::vector< art::Ptr< recob::Hit > > > GetSmallClustersByPlane(unsigned int iPlane)
art::ServiceHandle< geo::Geometry const > geom
SmallClusterFinderAlg(fhicl::ParameterSet const &pset)
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
art framework interface to geometry description
BEGIN_PROLOG could also be cout