14 #include "art_root_io/TFileService.h" 15 #include "art_root_io/TFileDirectory.h" 27 #include "nug4/ParticleNavigation/EmEveIdCalculator.h" 60 Pt2D(
double _x,
double _y,
double _q,
bool _isSig,
int _idx) :
x(_x),
y(_y), q(_q), isSig(_isSig), idx(_idx) {}
75 std::vector<int> regionQuery(
const std::vector<Pt2D>&
D,
const Pt2D&
p)
const;
77 void expandCluster(
const std::vector<Pt2D>& D,
79 std::vector<int> neiPts,
int C,
80 std::vector<bool>& visited,
81 std::vector<int>& inClust)
const;
83 std::vector<std::vector<Pt2D>> DBSCAN(
const std::vector<Pt2D>& D)
const;
115 geom(*lar::providerFrom<geo::Geometry>()),
117 produces<std::vector<sn::SNSlice>>();
122 fEps = pset.
get<
double>(
"Eps");
123 fMinPts = pset.
get<
int>(
"MinPts");
127 std::vector<int> SNSlicer::regionQuery(
const std::vector<Pt2D>&
D,
const Pt2D&
p)
const 129 std::vector<int> ret;
130 for(
unsigned int i = 0; i < D.size(); ++i){
131 if((D[i].
x-p.x)*(D[i].x-p.x) + (D[i].
y-p.y)*(D[i].y-p.y) < fEps*fEps)
138 std::vector<int> Join(
const std::vector<int>
a,
const std::vector<int>
b)
140 std::set<int>
s(a.begin(), a.end());
143 return std::vector<int>(
s.begin(),
s.end());
147 void SNSlicer::expandCluster(
const std::vector<Pt2D>& D,
149 std::vector<int> neiPts,
int C,
150 std::vector<bool>& visited,
151 std::vector<int>& inClust)
const 158 for(
unsigned int iNP = 0; iNP < neiPts.size(); ++iNP){
159 if(inClust[neiPts[iNP]] == -1){
160 inClust[neiPts[iNP]] = C;
163 if(!visited[neiPts[iNP]]){
164 visited[neiPts[iNP]] =
true;
165 std::vector<int> neiPts2 = regionQuery(D, D[neiPts[iNP]]);
168 const int Q = neiPts2.size();
170 neiPts = Join(neiPts, neiPts2);
180 std::vector<std::vector<Pt2D>> SNSlicer::DBSCAN(
const std::vector<Pt2D>& D)
const 182 std::vector<bool> visited(D.size(),
false);
184 std::vector<int> inclust(D.size(), -1);
187 for(
unsigned int iD = 0; iD < D.size(); ++iD){
188 if(visited[iD])
continue;
191 std::vector<int> neiPts = regionQuery(D, D[iD]);
194 const int Q = neiPts.size();
200 expandCluster(D, iD, neiPts, C, visited, inclust);
204 std::vector<std::vector<Pt2D>> ret(C+1);
205 for(
unsigned int i = 0; i < D.size(); ++i){
206 if(inclust[i] >= 0) ret[inclust[i]].push_back(D[i]);
214 std::unique_ptr<std::vector<sn::SNSlice>> slicecol(
new std::vector<sn::SNSlice>);
219 auto hits = evt.
getHandle<std::vector<recob::Hit>>(
"gaushit");
265 std::vector<Pt2D> pts;
268 const double driftVel = dp.DriftVelocity() * dp.SamplingRate() / 1000;
276 for(
unsigned int hitIdx = 0; hitIdx < hits->size(); ++hitIdx){
299 const double t = hit.
PeakTime() * dp.SamplingRate() / 1000;
304 pts.push_back(Pt2D(xyz[2], t*driftVel, q, isSig, hitIdx));
305 if(isSig) totTrueQ += q;
308 std::vector<std::vector<Pt2D>>
slices = DBSCAN(pts);
310 for(
const std::vector<Pt2D>& slice: slices){
311 if(slice.empty())
continue;
319 for(
const Pt2D& p: slice){
320 prod.
meanT += p.q * p.y / driftVel;
321 prod.
meanZ += p.q * p.x;
330 slicecol->push_back(prod);
Geometry description of a TPC wireThe wire is a single straight segment on a wire plane...
Handle< PROD > getHandle(SelectorBase const &) const
geo::WireID WireID() const
Planes which measure Z direction.
float Integral() const
Integral under the calibrated signal waveform of the hit, in tick x ADC units.
geo::View_t View() const
View for the plane of the hit.
art framework interface to geometry description
#define DEFINE_ART_MODULE(klass)
T get(std::string const &key) const
ProductID put(std::unique_ptr< PROD > &&edp, std::string const &instance={})
Description of geometry of one entire detector.
QCString & insert(uint index, const char *s)
std::vector< TCSlice > slices
Detector simulation of raw signals on wires.
float PeakTime() const
Time of the signal peak, in tick units.
Declaration of signal hit object.
std::vector< art::Ptr< recob::Hit > > hits
Access the description of detector geometry.
Declaration of basic channel signal object.
2D representation of charge deposited in the TDC/wire plane
void GetCenter(double *xyz, double localz=0.0) const
Fills the world coordinate of a point on the wire.