27 : fView(view), fUp(up),
28 fAllMMax(+1e10), fAllMMin(-1e10),
29 fAllCMax(+1e10), fAllCMin(-1e10),
30 fNChunks(0), fNDeadChunks(0),
88 if(
fSegs.size() < rhs.
fSegs.size())
return true;
89 if(
fSegs.size() > rhs.
fSegs.size())
return false;
111 double& mmax,
double& mmin,
112 double&
cmax,
double& cmin)
const 114 const double dz = segj.
z-segi.
z;
128 double& mmax,
double& mmin,
129 double&
cmax,
double& cmin)
const 131 const double dz = segj.
zL-segi.
zL;
162 for(std::list<Segment>::iterator
it =
fSegs.begin();
it !=
fSegs.end(); ++
it){
168 double mmax, mmin,
cmax, cmin;
170 newAllMMax =
std::min(mmax, newAllMMax);
171 newAllMMin =
std::max(mmin, newAllMMin);
172 newAllCMax =
std::min(cmax, newAllCMax);
173 newAllCMin =
std::max(cmin, newAllCMin);
175 if(newAllMMax <= newAllMMin ||
176 newAllCMax <= newAllCMin)
return false;
182 if((
fUp && newAllMMax < 0) || (!
fUp && newAllMMin > 0))
return false;
187 fSegs.push_back(seg);
189 fSegs.push_front(seg);
236 if(
fSegs.size() == 1){
246 bool needRecalc =
false;
247 for(std::list<Segment>::iterator
it =
fSegs.begin();
it !=
fSegs.end(); ++
it){
250 double mmax, mmin,
cmax, cmin;
253 mmax, mmin, cmax, cmin);
264 if(!needRecalc)
return;
269 std::list<Segment> segs =
fSegs;
277 for(std::list<Segment>::iterator
it = segs.begin();
it != segs.end(); ++
it){
285 double& z2,
double&
y2)
const 294 const int prevPlane =
fSegs.front().left ? geom->NextPlaneInView(firstPlane, -1) : firstPlane;
297 const int nextPlane =
fSegs.back().left ? lastPlane : geom->NextPlaneInView(lastPlane, +1);
301 geom->Plane(prevPlane)->Cell(0)->GetCenter(a);
302 geom->Plane(firstPlane)->Cell(0)->GetCenter(b);
306 z1 =
fSegs.front().zL;
311 geom->Plane(lastPlane)->Cell(0)->GetCenter(a);
312 geom->Plane(nextPlane)->Cell(0)->GetCenter(b);
316 z2 =
fSegs.back().zR;
321 if(!
fSegs.front().left){
323 if(newz1 <
fSegs.front().zL) z1 = newz1;
327 if(
fSegs.back().left){
329 if(newz2 >
fSegs.back().zR) z2 = newz2;
332 const double cavg =
CAvg();
333 const double mavg =
MAvg();
346 if(!
it->AllDead()) ++ret;
367 return fSegs.front();
389 fChunks.begin()->SetShowerChunk();
392 const std::pair<Segment, Segment> segs =
fChunks.begin()->GetSegs();
401 fChunks.rbegin()->SetShowerChunk();
404 const std::pair<Segment, Segment> segs =
fChunks.rbegin()->GetSegs();
418 if(!
it->IsShowerChunk())
return false;
438 if(
it->IsShowerChunk() ||
445 for(
unsigned int m = 0;
m < chunkHits.
size(); ++
m)
455 double z1,
y1, z2,
y2;
458 fView, y1, z1, y2-y1, z2-z1);
461 ret.
Add(
it->AllHits());
471 double bestL = left ? +1e10 : -1e10;
472 double bestZ = -1e10;
477 for(
unsigned int n = 0;
n < allhits.
size(); ++
n){
485 const TVector3 orig(0,
CAvg(), 0);
486 const TVector3
dir(0,
MAvg(), 1);
492 const double L = (start-orig).
Dot(dir);
494 if((left && L < bestL) ||
495 (!left && L > bestL)){
512 if(!
fChunks.front().AllDead())
return;
525 if(!
fChunks.back().AllDead())
return;
556 const std::pair<Segment, Segment> segs = chunk.
GetSegs();
590 if(
fUp != rhs.
fUp)
return false;
T max(const caf::Proxy< T > &a, T b)
void GetCenter(double *xyz, double localz=0.0) const
Cand(geo::View_t view, bool up)
float Dot(const Proxy &v) const
Float_t y1[n_points_granero]
void PopSegHelper(const Segment &segi, Direction end)
bool operator<(const Cand &rhs) const
std::pair< Segment, Segment > GetSegs() const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
Sequence of contiguous hits and dead cells all on the same plane.
std::list< Segment > fSegs
const CellGeo * Cell(int icell) const
const Segment & ExtremalSeg(Direction dir) const
double ClosestToEndCell(bool left) const
Z position.
A rb::Prong with full reconstructed trajectory.
const Chunk & FirstChunk() const
const Segment & LastSeg() const
const PlaneGeo * Plane(unsigned int i) const
bool operator==(const Cand &rhs) const
void EstimateStraightLine(double &z1, double &y1, double &z2, double &y2) const
virtual void Add(const art::Ptr< rb::CellHit > &cell, double weight=1)
Calculation and representation of a straight line passing through several "segment" windows...
bool TryAddSegOutOfOrder(const Segment &seg)
void push_back(Ptr< U > const &p)
static constexpr double L
void AppendTrajectoryPoint(TVector3 pt)
rb::Track ToTrack() const
Collect Geo headers and supply basic geometry functions.
art::PtrVector< rb::CellHit > AllHits() const
const Segment & FirstSeg() const
Cand MaybeFlip(bool &ok) const
Just the upstream or downstream part, just coordinates.
bool IsExtremalChunkComplete(Direction dir) const
void MarkExtremalChunkShower(Direction dir)
const Chunk & LastChunk() const
constexpr auto const & left(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
bool TryAddSeg(const Segment &seg, Direction dir, bool check=true)
Appends seg to fSegs and updates internal state reflecting limits on the possible straight lines...
double ClosestApproach(const double point[], const double intercept[], const double slopes[], double closest[])
Find the distance of closest approach between point and line.
void AddChunk(const Chunk &chunk, Direction dir)
Simply store the chunk in the list. Need to call AddSeg too.
void MinMaxLines(const Segment &segi, const Segment &segj, double &mmax, double &mmin, double &cmax, double &cmin) const
Helper for TryAddSeg.
assert(nhit_max >=nhit_nbins)
Window the line must pass through from (z,y0)-(z,y1)
T min(const caf::Proxy< T > &a, T b)
void ShortenOne(Direction dir)
Encapsulate the cell geometry.
SubSeg GetSubSeg(Direction dir) const
std::list< Chunk > fChunks
Encapsulate the geometry of one entire detector (near, far, ndos)
art::PtrVector< rb::CellHit > fAllHits
Always access via AllHits.
bool FindChunk(int plane, Chunk &chunk) const