1018 std::vector<int> skip;
1021 lariov::ChannelStatusProvider
const* channelStatus =
1022 lar::providerFrom<lariov::ChannelStatusService>();
1024 CLHEP::RandFlat flat(engine);
1026 std::vector<art::Ptr<recob::Hit>>
hit;
1032 hit.push_back((*ii));
1034 if (hit.size() == 0) {
1044 if (hit.size() == 0) {
1049 auto const num_planes = wireReadoutGeom.Nplanes(tpcid);
1050 std::vector<double> wire_pitch(num_planes, 0.);
1051 for (
auto const& plane : wireReadoutGeom.Iterate<
geo::PlaneGeo>(tpcid)) {
1052 auto const p = plane.ID().Plane;
1053 wire_pitch[p] = plane.WirePitch();
1057 std::vector<double> xyScale(num_planes, 0.);
1060 double driftVelFactor = 0.001 * detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
1062 for (
size_t p = 0; p < xyScale.size(); ++p)
1063 xyScale[p] = driftVelFactor *
sampling_rate(clockData) / wire_pitch[p];
1066 int dx = wireReadoutGeom.Plane(wireid.
asPlaneID()).Nwires();
1067 const int dy = detProp.ReadOutWindowSize();
1069 skip.resize(hit.size());
1070 std::vector<int> listofxmax;
1071 std::vector<int> listofymax;
1072 std::vector<int> hitTemp;
1073 std::vector<int> sequenceHolder;
1074 std::vector<int> currentHits;
1075 std::vector<int> lastHits;
1077 float indcolscaling = 0.;
1079 float centerofmassx = 0;
1080 float centerofmassy = 0;
1082 float intercept = 0.;
1089 int accDx(0), accDy(0);
1098 unsigned int count = hit.size();
1099 std::vector<unsigned int> accumPoints;
1100 accumPoints.resize(hit.size());
1102 unsigned int nLinesFound = 0;
1104 for (; count > 0; count--) {
1107 unsigned int randInd = (
unsigned int)(flat.fire() * hit.size());
1109 MF_LOG_DEBUG(
"HoughBaseAlg") <<
"randInd=" << randInd <<
" and size is " << hit.size();
1112 if (skip.at(randInd) == 1)
continue;
1115 if (accumPoints.at(randInd))
continue;
1116 accumPoints.at(randInd) = 1;
1119 for (
unsigned int i = 0; i < listofxmax.size(); ++i) {
1121 if (yClearStart < 0) yClearStart = 0;
1124 if (yClearEnd >= accDy) yClearEnd = accDy - 1;
1127 if (xClearStart < 0) xClearStart = 0;
1130 if (xClearEnd >= accDx) xClearEnd = accDx - 1;
1132 for (
y = yClearStart;
y <= yClearEnd; ++
y) {
1133 for (x = xClearStart; x <= xClearEnd; ++
x) {
1141 unsigned int wireMax = hit.at(randInd)->WireID().Wire;
1144 std::array<int, 3> max = c.AddPointReturnMax(wireMax, (
int)(hit.at(randInd)->PeakTime()));
1145 maxCell = max.at(0);
1154 denom = centerofmassx = centerofmassy = 0;
1156 if (xMax > 0 && yMax > 0 && xMax + 1 < accDx && yMax + 1 < accDy) {
1157 for (
int i = -1; i < 2; ++i) {
1158 for (
int j = -1; j < 2; ++j) {
1159 int cell = c.GetCell(yMax + i, xMax + j);
1161 centerofmassx += j * cell;
1162 centerofmassy += i * cell;
1165 centerofmassx /= denom;
1166 centerofmassy /= denom;
1169 centerofmassx = centerofmassy = 0;
1172 listofxmax.push_back(xMax);
1173 listofymax.push_back(yMax);
1176 c.GetEquation(yMax + centerofmassy, xMax + centerofmassx, rho, theta);
1177 MF_LOG_DEBUG(
"HoughBaseAlg") <<
"Transform(I) found maximum at (d=" << rho <<
" a=" << theta
1179 " from absolute maximum " 1180 << c.GetCell(yMax, xMax) <<
" at (d=" << yMax <<
", a=" << xMax
1182 slope = -1. / tan(theta);
1183 intercept = (rho / sin(theta));
1194 if (!std::isinf(slope) && !std::isnan(slope)) {
1195 sequenceHolder.clear();
1197 for (
size_t i = 0; i < hit.size(); ++i) {
1198 distance = (TMath::Abs(hit.at(i)->PeakTime() - slope * (double)(hit.at(i)->WireID().Wire) -
1200 (std::sqrt(pow(xyScale[hit.at(i)->WireID().Plane] * slope, 2) + 1)));
1202 if (distance <
fMaxDistance + hit.at(i)->RMS() + indcolscaling && skip.at(i) != 1) {
1203 hitTemp.push_back(i);
1204 sequenceHolder.push_back(hit.at(i)->Channel());
1209 if (hitTemp.size() < 2)
continue;
1210 currentHits.clear();
1213 currentHits.push_back(0);
1214 for (
size_t i = 0; i + 1 < sequenceHolder.size(); ++i) {
1216 while ((channelStatus->IsBad(sequenceHolder.at(i) + j)) ==
true)
1218 if (sequenceHolder.at(i + 1) - sequenceHolder.at(i) <= j +
fMissedHits)
1219 currentHits.push_back(i + 1);
1220 else if (currentHits.size() > lastHits.size()) {
1221 lastHits = currentHits;
1222 currentHits.clear();
1225 currentHits.clear();
1228 if (currentHits.size() > lastHits.size()) lastHits = currentHits;
1236 double tickToDist = detProp.DriftVelocity(detProp.Efield(), detProp.Temperature());
1239 int lastHitsChannel = 0;
1240 int nHitsPerChannel = 1;
1242 MF_LOG_DEBUG(
"HoughBaseAlg") <<
"filling the pCorner arrays around here..." 1243 <<
"\n but first, lastHits size is " << lastHits.size()
1244 <<
" and lastHitsChannel=" << lastHitsChannel;
1248 unsigned int lastChannel = hit.at(hitTemp.at(lastHits.at(0)))->Channel();
1250 for (
size_t i = 0; i < lastHits.size() - 1; ++i) {
1251 bool newChannel =
false;
1253 if (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel() != lastChannel) {
1256 if (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel() == lastChannel) nHitsPerChannel++;
1262 if (slope > 0 || (!newChannel && nHitsPerChannel <= 1)) {
1264 pCorner0[0] = (hit.at(hitTemp.at(lastHits.at(i)))->Channel()) * wire_pitch[0];
1265 pCorner0[1] = hit.at(hitTemp.at(lastHits.at(i)))->PeakTime() * tickToDist;
1266 pCorner1[0] = (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel()) * wire_pitch[0];
1267 pCorner1[1] = hit.at(hitTemp.at(lastHits.at(i + 1)))->PeakTime() * tickToDist;
1268 if (std::sqrt(pow(pCorner0[0] - pCorner1[0], 2) + pow(pCorner0[1] - pCorner1[1], 2)) >
1273 else if (slope < 0 && newChannel && nHitsPerChannel > 1) {
1276 (hit.at(hitTemp.at(lastHits.at(lastHitsChannel)))->Channel()) * wire_pitch[0];
1277 pCorner0[1] = hit.at(hitTemp.at(lastHits.at(lastHitsChannel)))->PeakTime() * tickToDist;
1278 pCorner1[0] = (hit.at(hitTemp.at(lastHits.at(i + 1)))->Channel()) * wire_pitch[0];
1279 pCorner1[1] = hit.at(hitTemp.at(lastHits.at(i + 1)))->PeakTime() * tickToDist;
1280 if (std::sqrt(pow(pCorner0[0] - pCorner1[0], 2) + pow(pCorner0[1] - pCorner1[1], 2)) >
1283 lastChannel = hit.at(hitTemp.at(lastHits.at(i)))->Channel();
1284 lastHitsChannel = i + 1;
1285 nHitsPerChannel = 0;
1291 clusterHits.
clear();
1292 if (lastHits.size() < 5)
continue;
1297 for (
size_t i = 0; i < lastHits.size(); ++i) {
1298 clusterHits.
push_back(hit.at(hitTemp.at(lastHits.at(i))));
1299 integralQ.
add(clusterHits.
back()->Integral());
1300 summedQ.
add(clusterHits.
back()->ROISummedADC());
1301 skip.at(hitTemp.at(lastHits.at(i))) = 1;
1306 clusHitsOut.push_back(clusterHits);
1307 slopevec.push_back(slope);
1308 totalQvec.emplace_back(integralQ.
Sum(),
1318 if (nLinesFound > (
unsigned int)
fMaxLines)
break;
1326 int cell, pix = 0, maxCell = 0;
1327 for (
y = 0;
y < accDy; ++
y) {
1328 for (x = 0; x < accDx; ++
x) {
1329 cell = c.GetCell(
y, x);
1330 if (cell > maxCell) maxCell = cell;
1334 std::unique_ptr<unsigned char[]> outPix(
new unsigned char[accDx * accDy]);
1335 unsigned int PicIndex = 0;
1336 for (
y = 0;
y < accDy; ++
y) {
1337 for (x = 0; x < accDx; ++
x) {
1339 if (maxCell > 0) pix = (int)((1500 * c.GetCell(
y, x)) / maxCell);
1340 outPix[PicIndex++] = pix;
1351 return clusHitsOut.size();
float fRhoResolutionFactor
Factor determining the resolution in rho.
constexpr auto abs(T v)
Returns the absolute value of the argument.
cout<< "Opened file "<< fin<< " ixs= "<< ixs<< endl;if(ixs==0) hhh=(TH1F *) fff-> Get("h1")
Weight_t RMS() const
Returns the root mean square.
int fMaxLines
Max number of lines that can be found.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
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?
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
Enumerate the possible plane projections.
Geometry information for a single wire plane.The plane is represented in the geometry by a solid whic...
float fMaxDistance
Max distance that a hit can be from a line to be considered part of that line.
float fMaxSlope
Max slope a line can have.
int fRhoZeroOutRange
Range in rho over which to zero out area around previously found lines in the accumulator.
Detector simulation of raw signals on wires.
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.
constexpr TPCID const & asTPCID() const
Conversion to PlaneID (for convenience of notation).
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)
constexpr PlaneID const & asPlaneID() const
Conversion to WireID (for convenience of notation).