72 pset.
get<
std::
string>(
"InitialTrackSpacePointsOutputLabel"))
76 <<
"Shower2DLinearRegressionTrackHitFinderEMShower: fNfithits and fToler need to have size " 92 <<
"Start position not set, returning " <<
std::endl;
98 <<
"Direction not set, returning " <<
std::endl;
102 TVector3 ShowerStartPosition = {-999, -999, -999};
105 TVector3 ShowerDirection = {-999, -999, -999};
114 const art::FindManyP<recob::Cluster>& fmc =
116 std::vector<art::Ptr<recob::Cluster>> clusters = fmc.at(pfparticle.
key());
118 if (clusters.size() < 2) {
121 <<
"Not enough clusters: " << clusters.size() <<
std::endl;
126 const art::FindManyP<recob::Hit>& fmhc =
128 std::map<geo::PlaneID, std::vector<art::Ptr<recob::Hit>>> plane_clusters;
130 for (
auto const&
cluster : clusters) {
133 std::vector<art::Ptr<recob::Hit>> hits = fmhc.at(
cluster.key());
135 for (
auto hit : hits) {
138 plane_clusters[plane].push_back(
hit);
146 auto const clockData =
151 std::vector<art::Ptr<recob::Hit>> InitialTrackHits;
153 for (
auto const&
cluster : plane_clusters) {
156 std::vector<art::Ptr<recob::Hit>> hits =
cluster.second;
160 detProp, hits, ShowerStartPosition, ShowerDirection);
165 InitialTrackHits.insert(InitialTrackHits.end(), trackhits.begin(), trackhits.end());
173 auto const hitHandle = Event.getValidHandle<std::vector<recob::Hit>>(
fHitLabel);
176 const art::FindManyP<recob::SpacePoint>& fmsp =
180 std::vector<art::Ptr<recob::SpacePoint>> intitaltrack_sp;
181 for (
auto const&
hit : InitialTrackHits) {
182 std::vector<art::Ptr<recob::SpacePoint>> sps = fmsp.at(
hit.key());
183 for (
auto const sp : sps) {
184 intitaltrack_sp.push_back(sp);
192 std::vector<art::Ptr<recob::Hit>>
198 std::vector<art::Ptr<recob::Hit>> trackHits;
202 std::vector<double> wfit;
203 std::vector<double> tfit;
204 std::vector<double> cfit;
209 unsigned int nhits = 0;
210 for (
auto&
hit : hits) {
217 (
std::abs((coord.Y() - (parm[0] + coord.X() * parm[1])) *
218 std::cos(std::atan(parm[1]))) <
fToler[i - 1]) ||
222 wfit.push_back(coord.X());
223 tfit.push_back(coord.Y());
229 if (i == fNfitpass - 1) { trackHits.push_back(
hit); }
233 if (i < fNfitpass - 1 && wfit.size()) {
234 fitok =
WeightedFit(wfit.size(), &wfit[0], &tfit[0], &cfit[0], &parm[0]);
266 for (Int_t i = 0; i <
n; i++) {
268 sumx2 += x[i] * x[i] * w[i];
270 sumy2 += y[i] * y[i] * w[i];
271 sumxy += x[i] * y[i] * w[i];
275 if (sumx2 * sumw - sumx * sumx == 0.)
return 1;
276 if (sumx2 - sumx * sumx / sumw == 0.)
return 1;
278 parm[0] = (sumy * sumx2 - sumx * sumxy) / (sumx2 * sumw - sumx * sumx);
279 parm[1] = (sumxy - sumx * sumy / sumw) / (sumx2 - sumx * sumx / sumw);
281 eparm[0] = sumx2 * (sumx2 * sumw - sumx * sumx);
282 eparm[1] = (sumx2 - sumx * sumx / sumw);
284 if (eparm[0] < 0. || eparm[1] < 0.)
return 1;
286 eparm[0] = sqrt(eparm[0]) / (sumx2 * sumw - sumx * sumx);
287 eparm[1] = sqrt(eparm[1]) / (sumx2 - sumx * sumx / sumw);
auto coord(Vector &v, unsigned int n) noexcept
Returns an object to manage the coordinate n of a vector.
The data type to uniquely identify a Plane.
void SetElement(T &dataproduct, const std::string &Name, bool checktag=false)
Set of hits with a 2D structure.
const art::FindManyP< T1 > & GetFindManyP(const art::ValidHandle< std::vector< T2 > > &handle, const art::Event &evt, const art::InputTag &moduleTag)
MaybeLogger_< ELseverityLevel::ELsev_error, false > LogError
Cluster finding and building.
key_type key() const noexcept
ValidHandle< PROD > getValidHandle(InputTag const &tag) const
bool CheckElement(const std::string &Name) const
constexpr PlaneID const & asPlaneID() const
Conversion to PlaneID (for convenience of notation).
int GetElement(const std::string &Name, T &Element) const
Detector simulation of raw signals on wires.
cet::coded_exception< errors::ErrorCodes, ExceptionDetail::translate > Exception
TVector2 HitCoordinates(detinfo::DetectorPropertiesData const &detProp, art::Ptr< recob::Hit > const &hit) const
2D representation of charge deposited in the TDC/wire plane
auto const & get(AssnsNode< L, R, D > const &r)
QTextStream & endl(QTextStream &s)
void OrderShowerHits(detinfo::DetectorPropertiesData const &detProp, std::vector< art::Ptr< recob::Hit >> &hits, TVector3 const &ShowerDirection, TVector3 const &ShowerPosition) const