17 #include "messagefacility/MessageLogger/MessageLogger.h"
28 for (
unsigned int i = 0; i < 3; i++)
39 for (
size_t i = 0; i < fAssignedHits.size(); i++)
40 if (fAssignedHits[i]->IsEnabled() &&
41 ((view ==
geo::kUnknown) || (view == fAssignedHits[i]->View2D()))) n++;
52 fAssignedPoints.clear();
53 fAssignedHits.clear();
59 std::vector< pma::Hit3D* > hitsColl, hitsInd1, hitsInd2;
60 for (
size_t i = 0; i < 3; ++i) fNThisHitsEnabledAll = 0;
61 for (
auto h : fAssignedHits)
63 if (
h->IsEnabled()) fNThisHitsEnabledAll++;
66 case geo::kZ: hitsColl.push_back(
h);
break;
67 case geo::kV: hitsInd2.push_back(
h);
break;
68 case geo::kU: hitsInd1.push_back(
h);
break;
71 fNThisHits[0] = hitsInd1.size();
72 fNThisHits[1] = hitsInd2.size();
73 fNThisHits[2] = hitsColl.size();
77 for (
size_t b = 0; b < chain->
NextCount(); b++)
85 case geo::kZ: hitsColl.push_back(
h);
break;
86 case geo::kV: hitsInd2.push_back(
h);
break;
87 case geo::kU: hitsInd1.push_back(
h);
break;
98 case geo::kZ: hitsColl.push_back(
h);
break;
99 case geo::kV: hitsInd2.push_back(
h);
break;
100 case geo::kU: hitsInd1.push_back(
h);
break;
107 if (r > fHitsRadius) fHitsRadius =
r;
109 if (r > fHitsRadius) fHitsRadius =
r;
111 float amp, sigmaMax = 0.0F;
112 fSumHitsQ[0] = 0.0; fNHits[0] = hitsInd1.size();
113 for (
size_t i = 0; i < hitsInd1.size(); i++)
115 amp = hitsInd1[i]->GetAmplitude();
116 if (amp > sigmaMax) sigmaMax = amp;
119 for (
size_t i = 0; i < hitsInd1.size(); i++)
123 amp = hitsInd1[i]->GetAmplitude();
125 hitsInd1[i]->SetSigmaFactor((
float)sqrt(amp / sigmaMax));
126 else hitsInd1[i]->SetSigmaFactor(0.01
F);
128 else hitsInd1[i]->SetSigmaFactor(1.0
F);
132 fSumHitsQ[1] = 0.0; fNHits[1] = hitsInd2.size();
133 for (
size_t i = 0; i < hitsInd2.size(); i++)
135 amp = hitsInd2[i]->GetAmplitude();
136 if (amp > sigmaMax) sigmaMax = amp;
139 for (
size_t i = 0; i < hitsInd2.size(); i++)
143 amp = hitsInd2[i]->GetAmplitude();
145 hitsInd2[i]->SetSigmaFactor((
float)sqrt(amp / sigmaMax));
146 else hitsInd2[i]->SetSigmaFactor(0.01
F);
148 else hitsInd2[i]->SetSigmaFactor(1.0
F);
152 fSumHitsQ[2] = 0.0; fNHits[2] = hitsColl.size();
153 for (
size_t i = 0; i < hitsColl.size(); i++)
155 amp = hitsColl[i]->SummedADC();
156 if (amp > sigmaMax) sigmaMax = amp;
159 for (
size_t i = 0; i < hitsColl.size(); i++)
163 amp = hitsColl[i]->SummedADC();
165 hitsColl[i]->SetSigmaFactor((
float)sqrt(amp / sigmaMax));
166 else hitsColl[i]->SetSigmaFactor(0.01
F);
168 else hitsColl[i]->SetSigmaFactor(1.0
F);
176 if (!fAssignedHits.empty()) mf::LogWarning(
"pma::Element3D") <<
"Hits assigned to TPC-crossing element.";
180 double hit_sum = SumDist2Hits();
182 if (fAssignedPoints.size())
184 double d, ref_sum = 0.0F;
185 for (
auto p : fAssignedPoints)
187 d = sqrt( GetDistance2To(*
p) ) - 0.5;
188 if (d > 0.0) ref_sum += d * d;
190 if (fAssignedHits.size())
192 ref_sum *= 0.2 * fAssignedHits.size() / fAssignedPoints.size();
204 if (!fAssignedHits.empty()) mf::LogWarning(
"pma::Element3D") <<
"Hits assigned to TPC-crossing element.";
208 double hit_sum = 0.0F;
209 for (
auto h : fAssignedHits)
213 unsigned int hitView =
h->View2D();
216 hit_sum += OptFactor(hitView) *
217 h->GetSigmaFactor() *
218 GetDistance2To(
h->Point2D(), hitView);
229 if (!fAssignedHits.empty()) mf::LogWarning(
"pma::Element3D") <<
"Hits assigned to TPC-crossing element.";
233 TVector3 mean3D(0, 0, 0);
235 for (
auto h : fAssignedHits)
236 if (
h->View2D() == view)
237 { mean3D +=
h->Point3D(); nHits++; }
238 if (!nHits)
return 0.0;
239 mean3D *= (1.0 / nHits);
241 double r2, maxR2 = 0.0;
242 for (
auto h : fAssignedHits)
243 if (
h->View2D() == view)
246 if (r2 > maxR2) maxR2 = r2;
253 if (!nmax_per_view) {
return SelectAllHits(); }
256 for (
size_t i = 0; i < 3; ++i) nhits[i] = NHits(i);
260 for (
size_t i = 0; i < 3; ++i)
262 if (nhits[i] >= 2 * nmax_per_view)
264 m[i] = nhits[i] / nmax_per_view;
267 else if (nhits[i] > nmax_per_view)
269 m[i] = nhits[i] / (nhits[i] - nmax_per_view);
272 else { m[i] = 0; state[i] =
false; }
277 bool b, changed =
false;
278 for (
auto h : fAssignedHits)
282 size_t view =
h->View2D();
285 if (count[view] % m[view] == 0)
h->SetEnabled(state[view]);
286 else h->SetEnabled(!(state[view]));
290 else h->SetEnabled(
true);
292 changed |= (b !=
h->IsEnabled());
299 bool changed =
false;
300 for (
auto h : fAssignedHits)
302 changed |= !(
h->IsEnabled());
double GetHitsRadius2D(const std::vector< pma::Hit3D * > &hits, bool exact=false)
double Dist2(const TVector2 &v1, const TVector2 &v2)
Planes which measure Z direction.
tuple m
now if test mode generate materials, CRT shell, world, gdml header else just generate CRT shell for u...
double HitsRadius3D(unsigned int view) const
virtual void ClearAssigned(pma::Track3D *trk=0)
Implementation of the Projection Matching Algorithm.
virtual unsigned int NextCount(void) const
std::vector< pma::Hit3D * > fAssignedHits
Implementation of the Projection Matching Algorithm.
static float fOptFactors[3]
double SumDist2(void) const
bool SelectRndHits(size_t nmax_per_view)
size_t fNThisHitsEnabledAll
void UpdateHitParams(void)
std::size_t count(Cont const &cont)
virtual pma::SortedObjectBase * Prev(void) const
virtual pma::SortedObjectBase * Next(unsigned int index=0) const
size_t NEnabledHits(unsigned int view=geo::kUnknown) const
Implementation of the Projection Matching Algorithm.