25 #include "cetlib_except/exception.h" 36 #include "boost/multi_array.hpp" 57 <<
"Time difference must be greater than zero.";
61 <<
"Z-coordinate difference must be greater than zero.";
65 <<
"Y-coordinate difference must be greater than zero.";
89 unsigned int nwires_u = geom->
Nwires(uplane_id);
90 unsigned int nwires_v = geom->
Nwires(vplane_id);
91 unsigned int nwires_y = geom->
Nwires(zplane_id);
97 for (
unsigned int iu = 0; iu < nwires_u; iu++) {
98 for (
unsigned int iv = 0; iv < nwires_v; iv++) {
104 for (
unsigned int iy = 0; iy < nwires_y; iy++) {
121 std::unique_ptr<std::vector<recob::SpacePoint>>& spptCollection,
127 <<
"Time offsets not set before createSpacePoints call!" 128 <<
"\nYou should call SpacePointAlg_TimeSort::setTimeOffsets() in beginRun()!" 129 <<
"\nWill be set now, but you should modify your code!";
134 <<
"Coordinate arrays not filled before createSpacePoints call!" 135 <<
"\nYou should call SpacePointAlg_TimeSort::fillCoordinateArrays() in beginRun()!" 136 <<
"\nWill be filled now, but you should modify your code!";
146 <<
"Sorted " << hitVec_U.size() <<
" u hits, " << hitVec_V.size() <<
" v hits, " 147 << hitVec_Y.size() <<
" y hits.";
150 std::vector<art::Ptr<recob::Hit>>
::iterator ihitu = hitVec_U.begin();
151 std::vector<art::Ptr<recob::Hit>>
::iterator ihitv = hitVec_V.begin();
152 std::vector<art::Ptr<recob::Hit>>
::iterator ihity = hitVec_Y.begin();
153 std::vector<art::Ptr<recob::Hit>>
::iterator ihitv_inner, ihity_inner;
157 double time_hitv_inner, time_hity_inner;
158 while (ihitu != hitVec_U.end()) {
162 <<
"Hit times (u,v,y)=(" << time_hitu <<
"," << time_hitv <<
"," << time_hity <<
")";
167 if (ihitv == hitVec_V.end())
break;
170 if (ihitv == hitVec_V.end())
break;
175 if (ihity == hitVec_Y.end())
break;
178 if (ihity == hitVec_Y.end())
break;
193 mf::LogInfo(
"SpacePointAlg_TimeSort") <<
"Matching hit times (u,v,y)=(" << time_hitu <<
"," 194 << time_hitv <<
"," << time_hity <<
")";
199 time_hitv_inner = (*ihitv_inner)->PeakTime() +
TIME_OFFSET_V;
201 time_hity_inner = (*ihity_inner)->PeakTime() +
TIME_OFFSET_Y;
206 unsigned int uwire = (*ihitu)->WireID().Wire;
207 unsigned int vwire = (*ihitv_inner)->WireID().Wire;
208 unsigned int ywire = (*ihity_inner)->WireID().Wire;
228 xyz[2] = (
coordinates_UV_z[vwire][uwire] + coordinates_UY_z[ywire][uwire]) * 0.5;
231 double t_val = (time_hitu + time_hitv_inner + time_hity_inner) / 3.;
232 double t_err = 0.5 * std::sqrt((time_hitu - t_val) * (time_hitu - t_val) +
233 (time_hitv_inner - t_val) * (time_hitv_inner - t_val) +
234 (time_hity_inner - t_val) * (time_hity_inner - t_val));
240 spptCollection->push_back(spt);
243 std::vector<art::Ptr<recob::Hit>> myhits = {*ihitu, *ihitv_inner, *ihity_inner};
244 spptAssociatedHits->push_back(myhits);
248 if (time_hitv_inner <= time_hity_inner) {
250 if (ihitv_inner == hitVec_V.end())
break;
251 time_hitv_inner = (*ihitv_inner)->PeakTime() +
TIME_OFFSET_V;
255 if (ihity_inner == hitVec_Y.end())
break;
256 time_hity_inner = (*ihity_inner)->PeakTime() +
TIME_OFFSET_Y;
264 <<
"Finished with " << spptCollection->size() <<
" spacepoints.";
271 std::sort(hitVec.begin(), hitVec.end(), HitTimeComparison);
void sortHitsByTime(std::vector< art::Ptr< recob::Hit >> &hits_handle) const
SpacePointAlg_TimeSort(fhicl::ParameterSet const &pset)
float fYDiffMax
Maximum allowed time difference.
void setTimeOffsets(detinfo::DetectorPropertiesData const &detProp)
double GetXTicksCoefficient(int t, int c) const
MaybeLogger_< ELseverityLevel::ELsev_info, false > LogInfo
double GetXTicksOffset(int p, int t, int c) const
Declaration of signal hit object.
The data type to uniquely identify a Plane.
constexpr auto abs(T v)
Returns the absolute value of the argument.
boost::multi_array< double, 2 > coordinates_UV_y
Planes which measure Z direction.
float fZDiffMax
Maximum allowed y-coordinate difference.
boost::multi_array< double, 2 > coordinates_UY_z
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
bool TIME_OFFSET_SET
Maximum allowed z-coordinate difference.
T get(std::string const &key) const
The data type to uniquely identify a TPC.
Definition of data types for geometry description.
float PeakTime() const
Time of the signal peak, in tick units.
boost::multi_array< double, 2 > coordinates_UY_y
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
void fillCoordinatesArrays()
unsigned int Nwires(PlaneID const &planeid) const
Returns the total number of wires in the specified plane.
void createSpacePoints(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> &hitVec_U, std::vector< art::Ptr< recob::Hit >> &hitVec_V, std::vector< art::Ptr< recob::Hit >> &hitVec_Y, std::unique_ptr< std::vector< recob::SpacePoint >> &spptCollection, std::unique_ptr< std::vector< std::vector< art::Ptr< recob::Hit >>>> &spptAssociatedHits)
bool IntersectionPoint(WireID const &wid1, WireID const &wid2, double &y, double &z) const
Returns the intersection point of two wires.
art framework interface to geometry description
cet::coded_exception< error, detail::translate > exception
boost::multi_array< double, 2 > coordinates_UV_z