18 #include "Utilities/func/MathUtil.h" 45 xyz1[view]-xyz0[view], xyz1[2]-xyz0[2]);
56 std::vector<TVector3> p0s, p1s;
57 for(std::list<Cand>::const_iterator candIt =
fCands.begin();
58 candIt !=
fCands.end(); ++candIt){
59 double z1,
y1, z2,
y2;
60 candIt->EstimateStraightLine(z1, y1, z2, y2);
61 p0s.push_back(TVector3(0, y1, z1));
62 p1s.push_back(TVector3(0, y2, z2));
65 std::vector<TVector3> pts;
68 const double minZ =
std::max(0., p0s[0].
Z());
71 const double kZStep = 5;
72 const int stepMax =
int((maxZ-minZ)/kZStep);
75 const double z = minZ+(double(
step)/stepMax)*(maxZ-minZ);
80 for(
unsigned int pIdx = 0; pIdx < p0s.size(); ++pIdx){
81 const TVector3&
p0 = p0s[pIdx];
82 const TVector3&
p1 = p1s[pIdx];
83 const double dz = p1.Z()-p0.Z();
85 const TVector3
p = p0*((p1.Z()-
z)/dz) + p1*((z-p0.Z())/dz);
88 double weight = (z-p0.Z())/dz;
89 if(weight > 0.5) weight = 1-
weight;
91 if(weight < 0)
continue;
101 if(totweight == 0)
continue;
103 meanp *= 1/totweight;
105 pts.push_back(meanp);
113 pts.push_back(pts[0]+TVector3(0, 0, 1));
116 const TVector3
dir = pts[1]-pts[0];
120 pts[0].Y(), pts[0].Z(), dir.Y(), dir.Z());
122 for(
unsigned int n = 1;
n < pts.size(); ++
n)
123 tr.AppendTrajectoryPoint(pts[
n].Y(), pts[
n].Z());
131 std::vector<rb::Track>
ret;
133 for(std::list<Cand>::const_iterator candIt =
fCands.begin();
134 candIt !=
fCands.end(); ++candIt){
135 ret.push_back(candIt->ToTrack());
190 while(!chunks.empty() && chunks.back().AllDead()) chunks.pop_back();
192 return chunks.back().Plane();
227 for(std::list<Cand>::const_iterator
it =
fCands.begin();
230 for(
unsigned int hitIdx = 0; hitIdx < hits.
size(); ++hitIdx){
249 std::map<unsigned int, Chunk> retMap;
252 const std::list<Chunk>
chunks =
it->AllChunks();
253 for(std::list<Chunk>::const_iterator
it = chunks.begin();
it != chunks.end(); ++
it){
254 retMap[
it->Plane()] = *
it;
259 std::vector<Chunk>
ret;
260 for(std::map<unsigned int, Chunk>::iterator
it = retMap.begin();
it != retMap.end(); ++
it)
261 ret.push_back(
it->second);
270 for(
unsigned int n = 0;
n < chunks.size(); ++
n)
271 if(!chunks[
n].AllDead()) ++ret;
301 fCands.front().TrimFront();
310 fCands.begin()->PopFirstChunk();
313 while(
FirstSeg().plane <
int(plane)){
314 if(
fCands.begin()->NSegs() > 1)
315 fCands.begin()->PopFirstSeg();
322 fCands.rbegin()->PopLastChunk();
325 while(
LastSeg().plane >
int(plane)){
326 if(
fCands.rbegin()->NSegs() > 1)
327 fCands.rbegin()->PopLastSeg();
342 for(
unsigned int n = 0;
n < chunks.size(); ++
n)
343 ret[chunks[
n].Plane()].push_back(chunks[
n]);
T max(const caf::Proxy< T > &a, T b)
bool compareByLength(const Chain &a, const Chain &b)
Float_t y1[n_points_granero]
const Segment & FirstSeg() const
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
bool compareByStart(const Chain &a, const Chain &b)
unsigned short Plane() const
Sequence of contiguous hits and dead cells all on the same plane.
unsigned int FirstPlane() const
unsigned int ExtremalPlane(Direction dir) const
std::map< int, std::vector< Chunk > > ChunkMap
A rb::Prong with full reconstructed trajectory.
const Chunk & FirstChunk() const
const Segment & LastSeg() const
const PlaneGeo * Plane(unsigned int i) const
unsigned int NChunks() const
Provides efficient lookup of CellHits by plane and cell number.
unsigned int LastPlane() const
unsigned short Cell() const
std::vector< Chunk > AllChunks() const
const Segment & LastSeg() const
rb::Track ToTrack() const
Calculation and representation of a straight line passing through several "segment" windows...
void push_back(Ptr< U > const &p)
void AppendTrajectoryPoint(TVector3 pt)
const Chunk & LastChunk() const
std::vector< rb::Track > ToDebugTracks() const
int BottomHitCell() const
const Segment & FirstSeg() const
unsigned int ExtremalHitPlane(Direction dir) const
void AddFront(const Cand &c)
dt::View::ChunkMap AsChunkMap() const
const Chunk & FirstChunk() const
const Chunk & LastChunk() const
art::PtrVector< rb::CellHit > AllHits() const
unsigned int ExtremalPlane(Direction dir) const
void TrimEnds()
Remove Cands that add no actual hits. After building but before writing.
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
assert(nhit_max >=nhit_nbins)
unsigned int ExtentPlane() const
const Cand & FirstCand() const
bool CellExists(unsigned int planeIdx, unsigned int cellIdx) const
Does the map contain any cell at this position?
void Truncate(unsigned int plane, Direction end)
Window the line must pass through from (z,y0)-(z,y1)
T min(const caf::Proxy< T > &a, T b)
const Cand & ExtremalCand(Direction dir) const
const Cand & LastCand() const
bool compareByEnd(const Chain &a, const Chain &b)
void Add(const art::Ptr< rb::CellHit > &chit)