37 double Min_X = std::min_element(tstart, tend, [](
auto &lhs,
auto &rhs) {
return lhs.MinX() < rhs.MinX(); })->MinX();
38 double Min_Y = std::min_element(tstart, tend, [](
auto &lhs,
auto &rhs) {
return lhs.MinY() < rhs.MinY(); })->MinY();
39 double Min_Z = std::min_element(tstart, tend, [](
auto &lhs,
auto &rhs) {
return lhs.MinZ() < rhs.MinZ(); })->MinZ();
41 double Max_X = std::max_element(tstart, tend, [](
auto &lhs,
auto &rhs) {
return lhs.MaxX() < rhs.MaxX(); })->MaxX();
42 double Max_Y = std::max_element(tstart, tend, [](
auto &lhs,
auto &rhs) {
return lhs.MaxY() < rhs.MaxY(); })->MaxY();
43 double Max_Z = std::max_element(tstart, tend, [](
auto &lhs,
auto &rhs) {
return lhs.MaxZ() < rhs.MaxZ(); })->MaxZ();
60 if(calos.size()==0)
return -99999;
64 art::Ptr<anab::Calorimetry>
calo = calos[0];
65 for(
size_t i = calos.size(); i > 0; i--){
66 if(calos[i-1]->
dEdx().size() > nhits*1.5){
67 nhits = calos[i-1]->dEdx().size();
73 if(calo->XYZ().size() != nhits || nhits < 1)
return -99999;
76 double distStart = (calo->XYZ()[0] -
end).Mag2();
77 double distEnd = (calo->XYZ()[nhits-1] -
end).Mag2();
80 double resrgStart = 0;
81 std::vector<double> v_resrg;
82 std::vector<double> v_dedx;
84 for(
size_t i = 0; i < nhits; i++){
85 double dedx = calo->dEdx()[i];
86 double resrg = calo->ResidualRange()[i];
89 if(distStart < distEnd && calo->ResidualRange()[0] > calo->ResidualRange()[nhits-1]) resrg = calo->ResidualRange()[0] - calo->ResidualRange()[i];
90 if(distStart > distEnd && calo->ResidualRange()[0] < calo->ResidualRange()[nhits-1]) resrg = calo->ResidualRange()[nhits-1] - calo->ResidualRange()[i];
93 if(resrg < fResRangeMin && dedx > maxDedx && dedx <
fDEdxMax){
101 for(
size_t i = 0; i < nhits; i++){
102 double dedx = calo->dEdx()[i];
103 double resrg = calo->ResidualRange()[i];
106 if(distStart < distEnd && calo->ResidualRange()[0] > calo->ResidualRange()[nhits-1]) resrg = calo->ResidualRange()[0] - calo->ResidualRange()[i];
107 if(distStart > distEnd && calo->ResidualRange()[0] < calo->ResidualRange()[nhits-1]) resrg = calo->ResidualRange()[nhits-1] - calo->ResidualRange()[i];
111 v_resrg.push_back(resrg);
112 v_dedx.push_back(dedx);
117 if(v_dedx.size() < 10)
return -99999;
120 TGraph *gdedx =
new TGraph(v_dedx.size(), &v_resrg[0], &v_dedx[0]);
121 try{ gdedx->Fit(
"pol0",
"Q"); }
catch(...){
delete gdedx;
return -99999; }
122 TF1* polfit = gdedx->GetFunction(
"pol0");
123 double polchi2 = polfit->GetChisquare();
126 try{ gdedx->Fit(
"expo",
"Q"); }
catch(...){
delete gdedx;
return -99999; }
127 TF1* expfit = gdedx->GetFunction(
"expo");
128 double expchi2 = expfit->GetChisquare();
133 return polchi2/expchi2;
153 if (vol.ContainsPosition(point))
return true;
170 if((startStops && !endInFiducial && track.
End().Y() > track.
Vertex().Y())
171 || (endStops && !startInFiducial && track.
Vertex().Y() > track.
End().Y())){
fhicl::Atom< double > DEdxMax
fhicl::Table< Containment > ContainmentCuts
void reconfigure(const core::ProviderManager &manager, const Config &config)
process_name use argoneut_mc_hitfinder track
process_name opflashCryoW ana
const geo::GeometryCore * GetGeometryProvider() const
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC in the detector.
process_name can override from command line with o or output calo
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Interface to LArSoft services.
StoppingParticleCosmicIdAlg(const core::ProviderManager &manager, const Config &config)
bool InFiducial(geo::Point_t point)
Point_t const & Vertex() const
auto end(FixedBins< T, C > const &) noexcept
double fStoppingChi2Limit
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
std::vector< geo::BoxBoundedGeo > fFiducialVolumes
IteratorBox< cryostat_iterator,&GeometryCore::begin_cryostat,&GeometryCore::end_cryostat > IterateCryostats() const
Enables ranged-for loops on all cryostats of the detector.
~StoppingParticleCosmicIdAlg()
double StoppingChiSq(geo::Point_t end, std::vector< art::Ptr< anab::Calorimetry >> calos)
A base class aware of world box coordinatesAn object describing a simple shape can inherit from this ...
bool StoppingEnd(geo::Point_t end, std::vector< art::Ptr< anab::Calorimetry >> calos)
fhicl::Atom< double > ResRangeMin
Point_t const & End() const
fhicl::Atom< double > ResRangeMax
fhicl::Atom< double > StoppingChi2Limit
Forward iterator browsing all geometry elements in the detector.
ROOT::Math::PositionVector3D< ROOT::Math::Cartesian3D< double >, ROOT::Math::GlobalCoordinateSystemTag > Point_t
Type for representation of position in physical 3D space.
bool StoppingParticleCosmicId(recob::Track track, std::vector< art::Ptr< anab::Calorimetry >> calos)
Track from a non-cascading particle.A recob::Track consists of a recob::TrackTrajectory, plus additional members relevant for a "fitted" track:
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.