184 auto const* geom = lar::providerFrom<geo::Geometry>();
189 for (
auto& t : tracks.
tracks()) {
192 auto const& node0 = *(t.Track()->Nodes()[0]);
193 auto const& node1 = *(t.Track()->Nodes()[t.Track()->Nodes().size() - 1]);
197 (node0.Point3D()[hIdx] > node1.Point3D()[hIdx]) ? node0.Point3D() : node1.Point3D();
199 (node0.Point3D()[hIdx] <= node1.Point3D()[hIdx]) ? node0.Point3D() : node1.Point3D();
206 bool foundTrack =
false;
207 for (
auto const& tt : tracks.
tracks()) {
209 if ((&tt) == (&t))
continue;
212 TVector3 trkVtx = (tt.Track()->Nodes()[0])->
Point3D();
213 TVector3 trkEnd = (tt.Track()->Nodes()[tt.Track()->Nodes().size() - 1])->
Point3D();
235 std::vector<float> nSigmaPerView;
238 for (
auto const view : geom->Views()) {
241 std::map<size_t, std::vector<double>> dedx;
242 t.Track()->GetRawdEdxSequence(dedx, view);
244 std::vector<double> trk_dedx;
246 for (
int h = t.Track()->NextHit(-1, view);
h != -1;
h = t.Track()->NextHit(
h, view)) {
248 if (
h > t.Track()->PrevHit(t.Track()->size(), view))
break;
250 if (dedx[
h][5] / dedx[
h][6] <= 0 || dedx[
h][5] / dedx[
h][6] > 1e6)
continue;
251 trk_dedx.push_back(dedx[
h][5] / dedx[
h][6]);
254 if (trk_dedx.size() == 0) {
255 mf::LogInfo(
"pma::PMAlgCosmicTagger")
256 <<
"View " << view <<
" has no hits." << std::endl;
261 double mean = sum /
static_cast<double>(trk_dedx.size());
264 accum += (d -
mean) * (d - mean);
266 double stdev = sqrt(accum / static_cast<double>(trk_dedx.size() - 1));
268 mf::LogInfo(
"pma::PMAlgCosmicTagger")
269 <<
" View " << view <<
" has average dedx " << mean <<
" +/- " << stdev
270 <<
" and final dedx " << trk_dedx[trk_dedx.size() - 1] << std::endl;
272 nSigmaPerView.push_back(fabs((trk_dedx[trk_dedx.size() - 1] -
mean) / stdev));
275 bool notStopper =
true;
276 short unsigned int n2Sigma = 0;
277 short unsigned int n3Sigma = 0;
278 for (
auto const nSigma : nSigmaPerView) {
279 if (nSigma >= 2.0) ++n2Sigma;
280 if (nSigma >= 3.0) ++n3Sigma;
283 if (n3Sigma > 0) notStopper =
false;
284 if (n2Sigma == nSigmaPerView.size()) notStopper =
false;
295 mf::LogInfo(
"pma::PMAlgCosmicTagger")
296 <<
" - Tagged " << n <<
" tracks stopping in the detector after starting at the top."
::fhicl::TupleAs< Point(::geo::Length_t,::geo::Length_t,::geo::Length_t)> Point3D
Atom object for reading a 3D point or vector (centimeters).
std::vector< double > fDimensionsMin
auto end(FixedBins< T, C > const &) noexcept
short int ConvertDirToInt(const TVector3 &dir) const
std::vector< double > fDimensionsMax
auto begin(FixedBins< T, C > const &) noexcept
double mean(const std::vector< short > &wf, size_t start, size_t nsample)
double fApparentStopperMargin
std::vector< TrkCandidate > const & tracks() const