32 #include "CLHEP/Random/RandFlat.h" 33 #include <TStopwatch.h> 60 #include "larevt/CalibrationDBI/Interface/ChannelStatusService.h" 61 #include "larevt/CalibrationDBI/Interface/ChannelStatusProvider.h" 63 constexpr
double PI = M_PI;
67 #define a2 -2.652905e-4f 69 #define a4 -1.964532e-3f 70 #define a5 1.02575e-2f 71 #define a6 -9.580378e-4f 73 #define _sin(x) ((((((a6*(x) + a5)*(x) + a4)*(x) + a3)*(x) + a2)*(x) + a1)*(x) + a0) 74 #define _cos(x) _sin(TMath::Pi()*0.5 - (x)) 77 inline T
sqr(T v) {
return v * v; }
81 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
85 unchecked_add_range_max
90 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
94 unchecked_add_range_max
99 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
105 { Base_t::make_const_iterator(Base_t::counter_map.
end(), 0), current_max };
108 cend = Base_t::counter_map.end();
109 while (iCBlock != cend) {
111 for (
size_t index = 0; index < block.size(); ++index) {
112 if (block[index] >
max.second)
113 max = { Base_t::make_const_iterator(iCBlock, index), block[index] };
121 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
127 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
133 if (key_begin > key_end)
return value;
135 size_t left = key_end - key_begin;
137 if ((iIP == Base_t::counter_map.
end()) || (iIP->first != key.block)) {
139 iIP = Base_t::counter_map.insert(iIP, { key.block, {}});
142 size_t n =
std::min(left, Base_t::NCounters - key.counter);
143 block.fill(key.counter, n, value);
144 if (left -= n <= 0)
break;
152 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
157 return unchecked_set_range(key_begin, key_end, value,
158 Base_t::counter_map.lower_bound(
CounterKey_t(key_begin).block));
162 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
170 { Base_t::make_const_iterator(Base_t::counter_map.
end(), 0), min_max };
171 if (key_begin > key_end)
return max;
173 size_t left = key_end - key_begin;
175 if ((iIP == Base_t::counter_map.
end()) || (iIP->first != key.block)) {
177 iIP = Base_t::counter_map.insert(iIP, { key.block, {}});
180 size_t n =
std::min(left, Base_t::NCounters - key.counter);
184 if (value >
max.second) {
185 max = { Base_t::make_const_iterator(iIP, key.counter), value };
189 if (left <= 0)
break;
197 template <
typename K,
typename C,
size_t S,
typename A,
unsigned int SC>
203 return unchecked_add_range_max(key_begin, key_end, delta,
204 Base_t::counter_map.lower_bound(
CounterKey_t(key_begin).block), min_max);
250 std::vector<unsigned int> *fpointId_to_clusterId,
251 unsigned int clusterId,
252 unsigned int *nClusters,
253 std::vector<protoTrack> *linesFound
257 int nClustersTemp = *nClusters;
261 lariov::ChannelStatusProvider
const* channelStatus
262 = lar::providerFrom<lariov::ChannelStatusService>();
265 unsigned int wire = 0;
266 unsigned int wireMax = 0;
267 unsigned int cs=
hits[0]->WireID().Cryostat;
268 unsigned int t=
hits[0]->WireID().TPC;
276 std::vector<int> skip;
278 std::vector<double> wire_pitch(geom->
Nplanes(t, cs), 0.);
279 for (
size_t p = 0; p < wire_pitch.size(); ++p) {
284 std::vector<double> xyScale(geom->
Nplanes(t, cs), 0.);
287 double driftVelFactor = 0.001*detprop->DriftVelocity(detprop->Efield(),detprop->Temperature());
289 for(
size_t p = 0; p < xyScale.size(); ++p)
290 xyScale[p] = driftVelFactor * detprop->SamplingRate()/wire_pitch[p];
292 float tickToDist = driftVelFactor * detprop->SamplingRate();
304 const int dy = detprop->NumberTimeSamples();
306 skip.resize(
hits.size());
307 std::vector<int> listofxmax;
308 std::vector<int> listofymax;
309 std::vector<int> hitsTemp;
310 std::vector<int> sequenceHolder;
311 std::vector<int> channelHolder;
312 std::vector<int> currentHits;
313 std::vector<int> lastHits;
314 std::vector<art::Ptr<recob::Hit> > clusterHits;
315 float indcolscaling = 0.;
325 float centerofmassx = 0;
326 float centerofmassy = 0;
340 int accDx(0), accDy(0);
348 unsigned int fMaxWire = 0;
350 unsigned int fMinWire = 99999999;
371 mf::LogInfo(
"HoughBaseAlg") <<
"dealing with " <<
hits.size() <<
" hits";
388 unsigned int nLinesFound = 0;
389 std::vector<unsigned int> accumPoints(
hits.size(),0);
394 for(
auto fpointId_to_clusterIdItr = fpointId_to_clusterId->begin(); fpointId_to_clusterIdItr != fpointId_to_clusterId->end();fpointId_to_clusterIdItr++)
395 if(*fpointId_to_clusterIdItr == clusterId)
398 unsigned int randInd;
402 CLHEP::HepRandomEngine & engine = rng -> getEngine();
403 CLHEP::RandFlat flat(engine);
411 randInd = (
unsigned int)(flat.fire()*
hits.size());
416 if(fpointId_to_clusterId->at(randInd) != clusterId)
422 if(skip[randInd]==1){
427 if(accumPoints[randInd])
429 accumPoints[randInd]=1;
432 for(
auto listofxmaxItr = listofxmax.begin(); listofxmaxItr != listofxmax.end(); ++listofxmaxItr) {
433 yClearStart = listofymax[listofxmaxItr-listofxmax.begin()] -
fRhoZeroOutRange;
434 if (yClearStart < 0) yClearStart = 0;
436 yClearEnd = listofymax[listofxmaxItr-listofxmax.begin()] +
fRhoZeroOutRange;
437 if (yClearEnd >= accDy) yClearEnd = accDy - 1;
440 if (xClearStart < 0) xClearStart = 0;
443 if (xClearEnd >= accDx) xClearEnd = accDx - 1;
445 for (y = yClearStart; y <= yClearEnd; ++
y){
446 for (x = xClearStart; x <= xClearEnd; ++
x){
453 uint32_t channel =
hits[randInd]->Channel();
454 wireMax =
hits[randInd]->WireID().Wire;
501 double binomProbSum = TMath::BinomialI(1/(
double)accDx,nAccum,maxCell);
509 if( binomProbSum > 1
e-21)
520 denom = centerofmassx = centerofmassy = 0;
522 if(xMax > 0 && yMax > 0 && xMax + 1 < accDx && yMax + 1 < accDy){
523 for(
int i = -1; i < 2; ++i){
524 for(
int j = -1; j < 2; ++j){
525 denom += c.
GetCell(yMax+i,xMax+j);
526 centerofmassx += j*c.
GetCell(yMax+i,xMax+j);
527 centerofmassy += i*c.
GetCell(yMax+i,xMax+j);
530 centerofmassx /= denom;
531 centerofmassy /= denom;
533 else centerofmassx = centerofmassy = 0;
536 listofxmax.push_back(xMax);
537 listofymax.push_back(yMax);
540 c.
GetEquation(yMax+centerofmassy, xMax+centerofmassx, rho, theta);
542 <<
"Transform(II) found maximum at (d=" << rho <<
" a=" << theta <<
")" 543 " from absolute maximum " << c.
GetCell(yMax,xMax)
544 <<
" at (d=" << yMax <<
", a=" << xMax <<
")";
545 slope = -1./tan(theta);
546 intercept = (rho/sin(theta));
549 if(!std::isinf(slope) && !std::isnan(slope)){
550 channelHolder.clear();
551 sequenceHolder.clear();
557 for(
auto hitsItr =
hits.cbegin(); hitsItr !=
hits.cend(); ++hitsItr){
558 wire = (*hitsItr)->WireID().Wire;
559 if(fpointId_to_clusterId->at(hitsItr -
hits.begin()) != clusterId)
561 channel = (*hitsItr)->Channel();
562 distance = (std::abs((*hitsItr)->PeakTime()-slope*(float)((*hitsItr)->WireID().Wire)-intercept)/(std::sqrt(
sqr(xyScale[(*hitsItr)->WireID().Plane]*slope)+1.)));
563 if(distance <
fMaxDistance+(*hitsItr)->RMS()+indcolscaling && skip[hitsItr-
hits.begin()]!=1){
564 hitsTemp.push_back(hitsItr-
hits.begin());
565 sequenceHolder.push_back(wire);
566 channelHolder.push_back(channel);
570 if(hitsTemp.size() < 5)
continue;
574 currentHits.push_back(0);
575 for(
auto sequenceHolderItr = sequenceHolder.begin(); sequenceHolderItr+1 != sequenceHolder.end(); ++sequenceHolderItr) {
577 while(channelStatus->IsBad(sequenceHolderItr-sequenceHolder.begin()+j)) j++;
578 if(sequenceHolder[sequenceHolderItr-sequenceHolder.begin()+1]-sequenceHolder[sequenceHolderItr-sequenceHolder.begin()] <= j +
fMissedHits) currentHits.push_back(sequenceHolderItr-sequenceHolder.begin()+1);
579 else if(currentHits.size() > lastHits.size()) {
580 lastHits = currentHits;
583 else currentHits.clear();
585 if(currentHits.size() > lastHits.size()) lastHits = currentHits;
590 if(lastHits.size() < (
unsigned int)
fMinHits)
continue;
677 std::vector< art::Ptr<recob::Hit> > lineHits;
680 for(
auto lastHitsItr = lastHits.begin(); lastHitsItr != lastHits.end(); ++lastHitsItr) {
681 fpointId_to_clusterId->at(hitsTemp[(*lastHitsItr)]) = nClustersTemp-1;
684 totalQ +=
hits[hitsTemp[(*lastHitsItr)]]->Integral();
685 wire =
hits[hitsTemp[(*lastHitsItr)]]->WireID().Wire;
687 if(!accumPoints[hitsTemp[(*lastHitsItr)]])
690 skip[hitsTemp[(*lastHitsItr)]]=1;
692 lineHits.push_back(
hits[hitsTemp[(*lastHitsItr)]]);
696 if(accumPoints[hitsTemp[(*lastHitsItr)]])
701 iMinWire = hitsTemp[(*lastHitsItr)];
705 iMaxWire = hitsTemp[(*lastHitsItr)];
708 int pnum =
hits[iMinWire]->WireID().Plane;
709 pCornerMin[0] = (
hits[iMinWire]->WireID().Wire)*wire_pitch[pnum];
710 pCornerMin[1] =
hits[iMinWire]->PeakTime()*tickToDist;
711 pCornerMax[0] = (
hits[iMaxWire]->WireID().Wire)*wire_pitch[pnum];
712 pCornerMax[1] =
hits[iMaxWire]->PeakTime()*tickToDist;
717 protoTrackToLoad.
Init(nClustersTemp-1,
731 linesFound->push_back(protoTrackToLoad);
758 unsigned char *outPix =
new unsigned char [accDx*accDy];
760 int cell, pix = 0, maxCell = 0;
761 for (
int y = 0; y < accDy; ++
y){
762 for (
int x = 0; x < accDx; ++
x){
764 if (cell > maxCell) maxCell = cell;
767 for (
int y = 0; y < accDy; ++
y){
768 for (
int x = 0; x < accDx; ++
x){
771 pix = (int)((1500*c.
GetCell(y,x))/maxCell);
772 outPix[y*accDx +
x] = pix;
780 *nClusters=nClustersTemp;
794 return m_accum[row][
col];
803 if ((x > (
int) m_dx) || (y > (
int) m_dy) || x<0.0 || y<0.0) {
804 std::array<int, 3>
max;
808 return DoAddPointReturnMax(x, y,
false);
816 if ((x > (
int) m_dx) || (y > (
int) m_dy) || x<0.0 || y<0.0)
818 DoAddPointReturnMax(x, y,
true);
827 unsigned int numACells)
829 m_numAngleCells=numACells;
830 m_rhoResolutionFactor = rhores;
847 <std::pair<const DistancesMap_t::Key_t, DistancesMap_t::CounterBlock_t>>
855 m_numAccumulated = 0;
864 m_rowLength = (
unsigned int)(m_rhoResolutionFactor*2 * std::sqrt(dx*dx + dy*dy));
865 m_accum.resize(m_numAngleCells);
870 double angleStep =
PI/m_numAngleCells;
871 m_cosTable.resize(m_numAngleCells);
872 m_sinTable.resize(m_numAngleCells);
873 for (
size_t iAngleStep = 0; iAngleStep < m_numAngleCells; ++iAngleStep) {
874 double a = iAngleStep * angleStep;
875 m_cosTable[iAngleStep] = cos(a);
876 m_sinTable[iAngleStep] = sin(a);
883 (
float row,
float col,
float &rho,
float &theta)
const 885 theta = (TMath::Pi()*row)/m_numAngleCells;
886 rho = (col - (m_rowLength/2.))/m_rhoResolutionFactor;
893 for(
unsigned int i = 0; i < m_accum.size(); i++){
896 if (max_counter.second > maxVal) {
897 maxVal = max_counter.second;
899 ymax = max_counter.first.key();
910 (
int x,
int y,
bool bSubtract )
912 std::array<int, 3>
max;
920 const int distCenter = (int)(m_rowLength/2.);
924 int lastDist = (int)(distCenter + (m_rhoResolutionFactor*x));
930 for (
size_t iAngleStep = 1; iAngleStep < m_numAngleCells; ++iAngleStep) {
935 const int dist = (int) (distCenter + m_rhoResolutionFactor
936 * (m_cosTable[iAngleStep]*x + m_sinTable[iAngleStep]*y)
961 if(lastDist == dist) {
968 first_dist = dist > lastDist? lastDist: dist + 1;
969 end_dist = dist > lastDist? dist: lastDist + 1;
989 if (max_counter.second > max_val) {
994 max = {{ max_counter.second, max_counter.first.key(), (int) iAngleStep }};
995 max_val = max_counter.second;
1004 if (bSubtract) --m_numAccumulated;
1005 else ++m_numAccumulated;
1017 std::ofstream bmpFile(fileName, std::ios::binary);
1018 bmpFile.write(
"B", 1);
1019 bmpFile.write(
"M", 1);
1020 int bitsOffset = 54 +256*4;
1021 int size = bitsOffset + dx*dy;
1022 bmpFile.write((
const char *)&size, 4);
1024 bmpFile.write((
const char *)&reserved, 4);
1025 bmpFile.write((
const char *)&bitsOffset, 4);
1027 bmpFile.write((
const char *)&bmiSize, 4);
1028 bmpFile.write((
const char *)&dx, 4);
1029 bmpFile.write((
const char *)&dy, 4);
1031 bmpFile.write((
const char *)&planes, 2);
1033 bmpFile.write((
const char *)&bitCount, 2);
1036 bmpFile.write((
const char *)&temp, 4);
1040 for (i=0; i<256; i++)
1042 lutEntry[0] = lutEntry[1] = lutEntry[2] = i;
1043 bmpFile.write(lutEntry,
sizeof lutEntry);
1046 bmpFile.write((
const char *)pix, dx*dy);
1052 std::vector<recob::Cluster> & ccol,
1055 std::string
const& label)
1057 std::vector<int> skip;
1069 CLHEP::HepRandomEngine & engine = rng -> getEngine();
1070 CLHEP::RandFlat flat(engine);
1077 std::vector< art::Ptr<recob::Hit> >
hit;
1079 for(
auto view : geom->
Views() ){
1081 LOG_DEBUG(
"HoughBaseAlg") <<
"Analyzing view " << view;
1087 while(clusterIter != clusIn.
end()) {
1089 LOG_DEBUG(
"HoughBaseAlg") <<
"Analyzing cinctr=" << cinctr <<
" which is in view " << (*clusterIter)->View();
1093 if((*clusterIter)->View() == view) hit = fmh.at(cinctr);
1096 while(clusterIter != clusIn.
end()){
1097 if( (*clusterIter)->View() == view ){
1099 hit = fmh.at(cinctr);
1105 if(hit.size() == 0){
1113 LOG_DEBUG(
"HoughBaseAlg") <<
"We have all the hits..." << hit.size();
1369 std::vector<double> slopevec;
1370 std::vector<ChargeInfo_t> totalQvec;
1371 std::vector< art::PtrVector<recob::Hit> > planeClusHitsOut;
1372 this->
FastTransform(hit,planeClusHitsOut,slopevec,totalQvec );
1374 LOG_DEBUG(
"HoughBaseAlg") <<
"Made it through FastTransform" << planeClusHitsOut.size();
1376 for(
size_t xx = 0;
xx < planeClusHitsOut.size(); ++
xx){
1377 auto const&
hits = planeClusHitsOut.at(
xx);
1381 const unsigned int ew = LastHit.
WireID().
Wire;
1396 ClusterParamAlgo.StartCharge().value(),
1397 ClusterParamAlgo.StartAngle().value(),
1398 ClusterParamAlgo.StartOpeningAngle().value(),
1403 ClusterParamAlgo.EndCharge().value(),
1404 ClusterParamAlgo.EndAngle().value(),
1405 ClusterParamAlgo.EndOpeningAngle().value(),
1406 ClusterParamAlgo.Integral().value(),
1407 ClusterParamAlgo.IntegralStdDev().value(),
1408 ClusterParamAlgo.SummedADC().value(),
1409 ClusterParamAlgo.SummedADCStdDev().value(),
1410 ClusterParamAlgo.NHits(),
1411 ClusterParamAlgo.MultipleHitDensity(),
1412 ClusterParamAlgo.Width(),
1420 clusHitsOut.push_back(planeClusHitsOut.at(
xx));
1426 if(clusterIter != clusIn.
end()){
1444 std::vector<double> slopevec;
1445 std::vector<ChargeInfo_t> totalQvec;
1446 return FastTransform( clusIn, clusHitsOut, slopevec, totalQvec );
1455 std::vector<double> &slopevec, std::vector<ChargeInfo_t>& totalQvec )
1457 std::vector<int> skip;
1463 lariov::ChannelStatusProvider
const* channelStatus
1464 = lar::providerFrom<lariov::ChannelStatusService>();
1468 CLHEP::HepRandomEngine & engine = rng -> getEngine();
1469 CLHEP::RandFlat flat(engine);
1471 std::vector< art::Ptr<recob::Hit> >
hit;
1486 hit.push_back((*ii));
1488 if(hit.size() == 0){
1495 unsigned int cs=hit.at(0)->WireID().Cryostat;
1496 unsigned int t=hit.at(0)->WireID().TPC;
1497 unsigned int p=hit.at(0)->WireID().Plane;
1516 if(hit.size() == 0){
1524 std::vector<double> wire_pitch(geom->
Nplanes(t, cs), 0.);
1525 for (
size_t p = 0; p < wire_pitch.size(); ++p) {
1530 std::vector<double> xyScale(geom->
Nplanes(t, cs), 0.);
1533 double driftVelFactor = 0.001*detprop->DriftVelocity(detprop->Efield(),detprop->Temperature());
1535 for(
size_t p = 0; p < xyScale.size(); ++p)
1536 xyScale[p] = driftVelFactor * detprop->SamplingRate()/wire_pitch[p];
1540 const int dy = detprop->ReadOutWindowSize();
1542 skip.resize(hit.size());
1543 std::vector<int> listofxmax;
1544 std::vector<int> listofymax;
1545 std::vector<int> hitTemp;
1546 std::vector<int> sequenceHolder;
1547 std::vector<int> currentHits;
1548 std::vector<int> lastHits;
1550 float indcolscaling = 0.;
1552 float centerofmassx = 0;
1553 float centerofmassy = 0;
1562 int accDx(0), accDy(0);
1572 unsigned int count = hit.size();
1573 std::vector<unsigned int> accumPoints;
1574 accumPoints.resize(hit.size());
1576 unsigned int nLinesFound = 0;
1578 for( ; count > 0; count--){
1582 unsigned int randInd = (
unsigned int)(flat.fire()*hit.size());
1584 LOG_DEBUG(
"HoughBaseAlg") <<
"randInd=" << randInd <<
" and size is " << hit.size();
1587 if(skip.at(randInd)==1)
1591 if(accumPoints.at(randInd))
1593 accumPoints.at(randInd)=1;
1596 for(
unsigned int i = 0; i < listofxmax.size(); ++i){
1598 if (yClearStart < 0) yClearStart = 0;
1601 if (yClearEnd >= accDy) yClearEnd = accDy - 1;
1604 if (xClearStart < 0) xClearStart = 0;
1607 if (xClearEnd >= accDx) xClearEnd = accDx - 1;
1609 for (y = yClearStart; y <= yClearEnd; ++
y){
1610 for (x = xClearStart; x <= xClearEnd; ++
x){
1619 unsigned int wireMax = hit.at(randInd)->WireID().Wire;
1623 (
int)(hit.at(randInd)->PeakTime()));
1624 maxCell = max.at(0);
1634 denom = centerofmassx = centerofmassy = 0;
1636 if(xMax > 0 && yMax > 0 && xMax + 1 < accDx && yMax + 1 < accDy){
1637 for(
int i = -1; i < 2; ++i){
1638 for(
int j = -1; j < 2; ++j){
1639 int cell = c.
GetCell(yMax+i,xMax+j);
1641 centerofmassx += j*cell;
1642 centerofmassy += i*cell;
1645 centerofmassx /= denom;
1646 centerofmassy /= denom;
1648 else centerofmassx = centerofmassy = 0;
1651 listofxmax.push_back(xMax);
1652 listofymax.push_back(yMax);
1655 c.
GetEquation(yMax+centerofmassy, xMax+centerofmassx, rho, theta);
1658 <<
"Transform(I) found maximum at (d=" << rho <<
" a=" << theta <<
")" 1659 " from absolute maximum " << c.
GetCell(yMax,xMax)
1660 <<
" at (d=" << yMax <<
", a=" << xMax <<
")";
1661 slope = -1./tan(theta);
1662 intercept = (rho/sin(theta));
1679 if(!std::isinf(slope) && !std::isnan(slope)){
1680 sequenceHolder.clear();
1682 for(
size_t i = 0; i < hit.size(); ++i){
1683 distance = (TMath::Abs(hit.at(i)->PeakTime()-slope*(double)(hit.at(i)->WireID().Wire)-intercept)/(std::sqrt(pow(xyScale[hit.at(i)->WireID().Plane]*slope,2)+1)));
1685 if(distance <
fMaxDistance+hit.at(i)->RMS()+indcolscaling && skip.at(i)!=1){
1686 hitTemp.push_back(i);
1687 sequenceHolder.push_back(hit.at(i)->Channel());
1692 if(hitTemp.size() < 2)
continue;
1693 currentHits.clear();
1696 currentHits.push_back(0);
1697 for(
size_t i = 0; i + 1 < sequenceHolder.size(); ++i){
1699 while((channelStatus->IsBad(sequenceHolder.at(i)+j)) ==
true) j++;
1700 if(sequenceHolder.at(i+1)-sequenceHolder.at(i) <= j +
fMissedHits) currentHits.push_back(i+1);
1701 else if(currentHits.size() > lastHits.size()) {
1702 lastHits = currentHits;
1703 currentHits.clear();
1705 else currentHits.clear();
1709 if(currentHits.size() > lastHits.size()) lastHits = currentHits;
1719 double tickToDist = detprop->DriftVelocity(detprop->Efield(),detprop->Temperature());
1720 tickToDist *= 1.e-3 * detprop->SamplingRate();
1722 int lastHitsChannel = 0;
1723 int nHitsPerChannel = 1;
1725 LOG_DEBUG(
"HoughBaseAlg") <<
"filling the pCorner arrays around here..." 1726 <<
"\n but first, lastHits size is " << lastHits.size()
1727 <<
" and lastHitsChannel=" << lastHitsChannel;
1731 unsigned int lastChannel = hit.at(hitTemp.at(lastHits.at(0)))->Channel();
1733 for(
size_t i = 0; i < lastHits.size()-1; ++i) {
1734 bool newChannel =
false;
1736 if(hit.at(hitTemp.at(lastHits.at(i+1)))->Channel() != lastChannel){
1739 if(hit.at(hitTemp.at(lastHits.at(i+1)))->Channel() == lastChannel)
1746 if(slope > 0 || (!newChannel && nHitsPerChannel <= 1)){
1749 pCorner0[0] = (hit.at(hitTemp.at(lastHits.at(i)))->Channel())*wire_pitch[0];
1750 pCorner0[1] = hit.at(hitTemp.at(lastHits.at(i)))->PeakTime()*tickToDist;
1751 pCorner1[0] = (hit.at(hitTemp.at(lastHits.at(i+1)))->Channel())*wire_pitch[0];
1752 pCorner1[1] = hit.at(hitTemp.at(lastHits.at(i+1)))->PeakTime()*tickToDist;
1754 if(std::sqrt( pow(pCorner0[0]-pCorner1[0],2) + pow(pCorner0[1]-pCorner1[1],2)) >
fMissedHitsDistance )
1759 else if (slope < 0 && newChannel && nHitsPerChannel > 1){
1762 pCorner0[0] = (hit.at(hitTemp.at(lastHits.at(lastHitsChannel)))->Channel())*wire_pitch[0];
1763 pCorner0[1] = hit.at(hitTemp.at(lastHits.at(lastHitsChannel)))->PeakTime()*tickToDist;
1764 pCorner1[0] = (hit.at(hitTemp.at(lastHits.at(i+1)))->Channel())*wire_pitch[0];
1765 pCorner1[1] = hit.at(hitTemp.at(lastHits.at(i+1)))->PeakTime()*tickToDist;
1767 if(std::sqrt( pow(pCorner0[0]-pCorner1[0],2) + pow(pCorner0[1]-pCorner1[1],2)) >
fMissedHitsDistance )
1769 lastChannel=hit.at(hitTemp.at(lastHits.at(i)))->Channel();
1770 lastHitsChannel=i+1;
1784 clusterHits.
clear();
1785 if(lastHits.size() < 5)
continue;
1790 for(
size_t i = 0; i < lastHits.size(); ++i) {
1791 clusterHits.
push_back(hit.at(hitTemp.at(lastHits.at(i))));
1792 integralQ.
add(clusterHits.
back()->Integral());
1793 summedQ.
add(clusterHits.
back()->SummedADC());
1794 skip.at(hitTemp.at(lastHits.at(i)))=1;
1800 clusHitsOut.push_back(clusterHits);
1801 slopevec.push_back(slope);
1802 totalQvec.emplace_back(
1803 integralQ.
Sum(), integralQ.
RMS(),
1804 summedQ.
Sum(), summedQ.
RMS()
1829 int cell, pix = 0, maxCell = 0;
1830 for (y = 0; y < accDy; ++
y){
1831 for (x = 0; x < accDx; ++
x){
1833 if (cell > maxCell) maxCell = cell;
1837 std::unique_ptr<unsigned char[]> outPix(
new unsigned char [accDx*accDy]);
1838 unsigned int PicIndex = 0;
1839 for (y = 0; y < accDy; ++
y){
1840 for (x = 0; x < accDx; ++
x){
1843 pix = (int)((1500*c.
GetCell(y,x))/maxCell);
1844 outPix[PicIndex++] = pix;
1865 return clusHitsOut.size();
1883 int dx = geom->
Nwires(0);
1888 for(
unsigned int i=0;i <
hits.size(); ++i){
1903 float centerofmassx = 0.;
1904 float centerofmassy = 0.;
1907 if(xMax > 0 && yMax > 0 && xMax+1 < accDx && yMax+1 < accDy){
1908 for(
int i = -1; i < 2; ++i){
1909 for(
int j = -1; j < 2; ++j){
1910 denom += c.
GetCell(yMax+i,xMax+j);
1911 centerofmassx += j*c.
GetCell(yMax+i,xMax+j);
1912 centerofmassy += i*c.
GetCell(yMax+i,xMax+j);
1915 centerofmassx /= denom;
1916 centerofmassy /= denom;
1918 else centerofmassx = centerofmassy = 0;
1922 c.
GetEquation(yMax+centerofmassy, xMax+centerofmassx, rho, theta);
1924 <<
"Transform(III) found maximum at (d=" << rho <<
" a=" << theta <<
")" 1925 " from absolute maximum " << c.
GetCell(yMax,xMax)
1926 <<
" at (d=" << yMax <<
", a=" << xMax <<
")";
1927 slope = -1./tan(theta);
1928 intercept = rho/sin(theta);
PlaneID const & planeID() const
virtual unsigned int ReadOutWindowSize() const =0
Utilities related to art service access.
typename Traits_t::CounterBlock_t CounterBlock_t
float fRhoResolutionFactor
Factor determining the resolution in rho.
virtual void reconfigure(fhicl::ParameterSet const &pset)
Encapsulate the construction of a single cyostat.
KEY Key_t
type of counter key in the map
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
geo::WireID WireID() const
Initial tdc tick for hit.
size_t FastTransform(const std::vector< art::Ptr< recob::Cluster > > &clusIn, std::vector< recob::Cluster > &ccol, std::vector< art::PtrVector< recob::Hit > > &clusHitsOut, art::Event const &evt, std::string const &label)
Declaration of signal hit object.
std::set< geo::View_t > const & Views() const
Returns a list of possible views in the detector.
geo::View_t View() const
View for the plane of the hit.
WireID_t Wire
Index of the wire within its plane.
SigType_t SignalType(geo::PlaneID const &pid) const
Returns the type of signal on the channels of specified TPC plane.
Classes gathering simple statistics.
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.
unsigned int Nwires(unsigned int p, unsigned int tpc=0, unsigned int cstat=0) const
Returns the total number of wires in the specified plane.
static const SentryArgument_t Sentry
An instance of the sentry object.
int fMaxLines
Max number of lines that can be found.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
size_t Transform(std::vector< art::Ptr< recob::Hit > > const &hits, std::vector< unsigned int > *fpointId_to_clusterId, unsigned int clusterId, unsigned int *nClusters, std::vector< protoTrack > *protoTracks)
float fMissedHitsDistance
Distance between hits in a hough line before a hit is considered missed.
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
Enumerate the possible plane projections.
Wrapper for ClusterParamsAlgBase objects to accept diverse input.
T get(std::string const &key) const
float fMaxDistance
Max distance that a hit can be from a line to be considered part of that line.
Aggressive allocator reserving a lot of memory in advance.
CryostatGeo const & Cryostat(geo::CryostatID const &cryoid) const
Returns the specified cryostat.
float fMaxSlope
Max slope a line can have.
Wrapper for ClusterParamsAlgBase objects to accept arbitrary input.
Description of geometry of one entire detector.
Declaration of cluster object.
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.
Encapsulate the geometry of a wire.
data_t::const_iterator const_iterator
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
float PeakTime() const
Time of the signal peak, in tick units.
std::string value(boost::any const &)
Utility object to perform functions of association.
Encapsulate the construction of a single detector plane.
const TPCGeo & TPC(unsigned int itpc) const
Return the itpc'th TPC in the cryostat.
void ImportHits(Iter begin, Iter end)
Calls SetHits() with the hits in the sequence.
unsigned int Nwires() const
Number of wires in this plane.
void Init(unsigned int num=999999, unsigned int pnum=999999, float slope=999999, float intercept=999999, float totalQTemp=-999999, float Min0=999999, float Min1=999999, float Max0=-999999, float Max1=-999999, int iMinWireTemp=999999, int iMaxWireTemp=-999999, int minWireTemp=999999, int maxWireTemp=-999999, std::vector< art::Ptr< recob::Hit >> hitsTemp=std::vector< art::Ptr< recob::Hit >>())
HoughBaseAlg(fhicl::ParameterSet const &pset)
std::vector< evd::details::RawDigitInfo_t >::const_iterator end(RawDigitCacheDataClass const &cache)
float SigmaPeakTime() const
Uncertainty for the signal peak, in tick units.
PlaneGeo const & Plane(geo::View_t view) const
Return the plane in the tpc with View_t view.
2D representation of charge deposited in the TDC/wire plane
Counter_t SubCounter_t
Type of the subcounter (that is, the actual counter)
Interface to class computing cluster parameters.
int fThetaZeroOutRange
Range in theta over which to zero out area around previously found lines in the accumulator.
recob::tracking::Plane Plane
Collects statistics on a single quantity (weighted)
float fMissedHitsToLineSize
Ratio of missed hits to line size for a line to be considered a fake.
art framework interface to geometry description
Encapsulate the construction of a single detector plane.
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)