1037 std::vector<int> skip;
1041 lar::providerFrom<lariov::ChannelStatusService>();
1043 CLHEP::RandFlat
flat(engine);
1045 std::vector<art::Ptr<recob::Hit>>
hit;
1051 hit.push_back((*ii));
1053 if (hit.size() == 0) {
1058 unsigned int cs = hit.at(0)->WireID().Cryostat;
1059 unsigned int t = hit.at(0)->WireID().TPC;
1060 unsigned int p = hit.at(0)->WireID().Plane;
1065 if (hit.size() == 0) {
1070 std::vector<double> wire_pitch(geom->
Nplanes(t, cs), 0.);
1071 for (
size_t p = 0; p < wire_pitch.size(); ++
p) {
1076 std::vector<double> xyScale(geom->
Nplanes(t, cs), 0.);
1079 double driftVelFactor = 0.001 * detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
1081 for (
size_t p = 0; p < xyScale.size(); ++
p)
1082 xyScale[p] = driftVelFactor *
sampling_rate(clockData) / wire_pitch[
p];
1086 const int dy = detProp.ReadOutWindowSize();
1088 skip.resize(hit.size());
1089 std::vector<int> listofxmax;
1090 std::vector<int> listofymax;
1091 std::vector<int> hitTemp;
1092 std::vector<int> sequenceHolder;
1093 std::vector<int> currentHits;
1094 std::vector<int> lastHits;
1096 float indcolscaling = 0.;
1098 float centerofmassx = 0;
1099 float centerofmassy = 0;
1101 float intercept = 0.;
1108 int accDx(0), accDy(0);
1117 unsigned int count = hit.size();
1118 std::vector<unsigned int> accumPoints;
1119 accumPoints.resize(hit.size());
1121 unsigned int nLinesFound = 0;
1123 for (; count > 0; count--) {
1126 unsigned int randInd = (
unsigned int)(
flat.fire() * hit.size());
1128 MF_LOG_DEBUG(
"HoughBaseAlg") <<
"randInd=" << randInd <<
" and size is " << hit.size();
1131 if (skip.at(randInd) == 1)
continue;
1134 if (accumPoints.at(randInd))
continue;
1135 accumPoints.at(randInd) = 1;
1138 for (
unsigned int i = 0; i < listofxmax.size(); ++i) {
1140 if (yClearStart < 0) yClearStart = 0;
1143 if (yClearEnd >= accDy) yClearEnd = accDy - 1;
1146 if (xClearStart < 0) xClearStart = 0;
1149 if (xClearEnd >= accDx) xClearEnd = accDx - 1;
1151 for (
y = yClearStart;
y <= yClearEnd; ++
y) {
1152 for (x = xClearStart; x <= xClearEnd; ++
x) {
1160 unsigned int wireMax = hit.at(randInd)->WireID().Wire;
1163 std::array<int, 3>
max = c.AddPointReturnMax(wireMax, (
int)(hit.at(randInd)->PeakTime()));
1164 maxCell = max.at(0);
1173 denom = centerofmassx = centerofmassy = 0;
1175 if (xMax > 0 && yMax > 0 && xMax + 1 < accDx && yMax + 1 < accDy) {
1176 for (
int i = -1; i < 2; ++i) {
1177 for (
int j = -1; j < 2; ++j) {
1178 int cell = c.GetCell(yMax + i, xMax + j);
1180 centerofmassx += j * cell;
1181 centerofmassy += i * cell;
1184 centerofmassx /= denom;
1185 centerofmassy /= denom;
1188 centerofmassx = centerofmassy = 0;
1191 listofxmax.push_back(xMax);
1192 listofymax.push_back(yMax);
1195 c.GetEquation(yMax + centerofmassy, xMax + centerofmassx, rho, theta);
1196 MF_LOG_DEBUG(
"HoughBaseAlg") <<
"Transform(I) found maximum at (d=" << rho <<
" a=" << theta
1198 " from absolute maximum " 1199 << c.GetCell(yMax, xMax) <<
" at (d=" << yMax <<
", a=" << xMax
1201 slope = -1. / tan(theta);
1202 intercept = (rho / sin(theta));
1213 if (!std::isinf(slope) && !std::isnan(slope)) {
1214 sequenceHolder.clear();
1216 for (
size_t i = 0; i < hit.size(); ++i) {
1217 distance = (TMath::Abs(hit.at(i)->PeakTime() - slope * (double)(hit.at(i)->WireID().Wire) -
1219 (std::sqrt(
pow(xyScale[hit.at(i)->WireID().Plane] * slope, 2) + 1)));
1221 if (distance <
fMaxDistance + hit.at(i)->RMS() + indcolscaling && skip.at(i) != 1) {
1222 hitTemp.push_back(i);
1223 sequenceHolder.push_back(hit.at(i)->Channel());
1228 if (hitTemp.size() < 2)
continue;
1229 currentHits.clear();
1232 currentHits.push_back(0);
1233 for (
size_t i = 0; i + 1 < sequenceHolder.size(); ++i) {
1235 while ((channelStatus->IsBad(sequenceHolder.at(i) + j)) ==
true)
1237 if (sequenceHolder.at(i + 1) - sequenceHolder.at(i) <= j +
fMissedHits)
1238 currentHits.push_back(i + 1);
1239 else if (currentHits.size() > lastHits.size()) {
1240 lastHits = currentHits;
1241 currentHits.clear();
1244 currentHits.clear();
1247 if (currentHits.size() > lastHits.size()) lastHits = currentHits;
1255 double tickToDist = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
1258 int lastHitsChannel = 0;
1259 int nHitsPerChannel = 1;
1261 MF_LOG_DEBUG(
"HoughBaseAlg") <<
"filling the pCorner arrays around here..." 1262 <<
"\n but first, lastHits size is " << lastHits.size()
1263 <<
" and lastHitsChannel=" << lastHitsChannel;
1267 unsigned int lastChannel = hit.at(hitTemp.at(lastHits.at(0)))->Channel();
1269 for (
size_t i = 0; i < lastHits.size() - 1; ++i) {
1270 bool newChannel =
false;
1272 if (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel() != lastChannel) {
1275 if (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel() == lastChannel) nHitsPerChannel++;
1281 if (slope > 0 || (!newChannel && nHitsPerChannel <= 1)) {
1283 pCorner0[0] = (hit.at(hitTemp.at(lastHits.at(i)))->Channel()) * wire_pitch[0];
1284 pCorner0[1] = hit.at(hitTemp.at(lastHits.at(i)))->PeakTime() * tickToDist;
1285 pCorner1[0] = (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel()) * wire_pitch[0];
1286 pCorner1[1] = hit.at(hitTemp.at(lastHits.at(i + 1)))->PeakTime() * tickToDist;
1287 if (std::sqrt(
pow(pCorner0[0] - pCorner1[0], 2) +
pow(pCorner0[1] - pCorner1[1], 2)) >
1292 else if (slope < 0 && newChannel && nHitsPerChannel > 1) {
1295 (hit.at(hitTemp.at(lastHits.at(lastHitsChannel)))->Channel()) * wire_pitch[0];
1296 pCorner0[1] = hit.at(hitTemp.at(lastHits.at(lastHitsChannel)))->PeakTime() * tickToDist;
1297 pCorner1[0] = (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel()) * wire_pitch[0];
1298 pCorner1[1] = hit.at(hitTemp.at(lastHits.at(i + 1)))->PeakTime() * tickToDist;
1299 if (std::sqrt(
pow(pCorner0[0] - pCorner1[0], 2) +
pow(pCorner0[1] - pCorner1[1], 2)) >
1302 lastChannel = hit.at(hitTemp.at(lastHits.at(i)))->Channel();
1303 lastHitsChannel = i + 1;
1304 nHitsPerChannel = 0;
1310 clusterHits.
clear();
1311 if (lastHits.size() < 5)
continue;
1316 for (
size_t i = 0; i < lastHits.size(); ++i) {
1317 clusterHits.
push_back(hit.at(hitTemp.at(lastHits.at(i))));
1318 integralQ.
add(clusterHits.
back()->Integral());
1319 summedQ.
add(clusterHits.
back()->SummedADC());
1320 skip.at(hitTemp.at(lastHits.at(i))) = 1;
1325 clusHitsOut.push_back(clusterHits);
1326 slopevec.push_back(slope);
1327 totalQvec.emplace_back(integralQ.
Sum(),
1337 if (nLinesFound > (
unsigned int)
fMaxLines)
break;
1345 int cell, pix = 0, maxCell = 0;
1346 for (
y = 0;
y < accDy; ++
y) {
1347 for (x = 0; x < accDx; ++
x) {
1348 cell = c.GetCell(
y, x);
1349 if (cell > maxCell) maxCell = cell;
1353 std::unique_ptr<unsigned char[]> outPix(
new unsigned char[accDx * accDy]);
1354 unsigned int PicIndex = 0;
1355 for (
y = 0;
y < accDy; ++
y) {
1356 for (x = 0; x < accDx; ++
x) {
1358 if (maxCell > 0) pix = (
int)((1500 * c.GetCell(
y, x)) / maxCell);
1359 outPix[PicIndex++] = pix;
1370 return clusHitsOut.size();
float fRhoResolutionFactor
Factor determining the resolution in rho.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
geo::Length_t WirePitch(geo::PlaneID const &planeid) const
Returns the distance between two consecutive wires.
Weight_t RMS() const
Returns the root mean square.
int fMaxLines
Max number of lines that can be found.
float fMissedHitsDistance
Distance between hits in a hough line before a hit is considered missed.
int fNumAngleCells
that fall into the "correct" bin will be small and consistent with noise.
int fSaveAccumulator
Save bitmap image of accumulator for debugging?
unsigned int Nplanes(unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wire planes in the specified TPC.
void push_back(Ptr< U > const &p)
Signal from induction planes.
Weight_t Sum() const
Returns the weighted sum of the values.
enum geo::_plane_sigtype SigType_t
float fMaxDistance
Max distance that a hit can be from a line to be considered part of that line.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
float fMaxSlope
Max slope a line can have.
double distance(double x1, double y1, double z1, double x2, double y2, double z2)
Class providing information about the quality of channels.
static int max(int a, int b)
Description of geometry of one entire detector.
int fRhoZeroOutRange
Range in rho over which to zero out area around previously found lines in the accumulator.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
unsigned int Nwires() const
Number of wires in this plane.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
int fThetaZeroOutRange
Range in theta over which to zero out area around previously found lines in the accumulator.
double sampling_rate(DetectorClocksData const &data)
Returns the period of the TPC readout electronics clock.
Collects statistics on a single quantity (weighted)
float fMissedHitsToLineSize
Ratio of missed hits to line size for a line to be considered a fake.
void add(Data_t value, Weight_t weight=Weight_t(1.0))
Adds one entry with specified value and weight.
void HLSSaveBMPFile(char const *, unsigned char *, int, int)