10 #include "messagefacility/MessageLogger/MessageLogger.h"
19 unsigned int plane = src->WireID().
Plane;
20 unsigned int tpc = src->WireID().TPC;
21 unsigned int cryo = src->WireID().Cryostat;
29 globalWire = geom->
WireCoordinate(wireCentre[1], wireCentre[2], plane, 0, cryo);
33 globalWire = geom->
WireCoordinate(wireCentre[1], wireCentre[2], plane, 1, cryo);
44 fHits2D.push_back(hit);
46 fSize = fHits2D.size();
53 return std::sort(fHits2D.begin(), fHits2D.end(),
bDistCentMore2D(fCenter2D));
59 return std::sort(fHits2D.begin(), fHits2D.end(),
bDistCentLess2D(fCenter2D));
62 std::vector<art::Ptr<recob::Hit>>
66 std::vector<art::Ptr<recob::Hit>> vec;
67 for (
unsigned int i = 0; i < fHits2D.size(); i++) {
68 if (
pma::Dist2(fHits2D[i]->GetPointCm(), fCenter2D) < radius * radius) {
69 vec.push_back(fHits2D[i]->GetHitPtr());
70 if (vec.size() == nhits)
break;
78 : fCenter2D(center), fPoints2D(hits), fNbins(nbins)
81 for (
unsigned int i = 0; i <
fNbins; i++) {
97 TVector2 vstart(0, 1);
99 unsigned int saveid = 0;
101 for (
unsigned int i = 0; i < fPoints2D.size(); i++) {
102 if (fPoints2D[i]->GetHitPtr().key() != fCenter2D.GetHitPtr().key()) {
103 TVector2 pos(fPoints2D[i]->GetPointCm());
104 TVector2 centre(fCenter2D.GetPointCm());
105 TVector2 vecp = pos - centre;
106 float sinsign = (vstart.X() * vecp.Y()) - (vstart.Y() * vecp.X());
107 float cosine = (vstart * vecp) / vecp.Mod();
108 float theta = 180.0F * (std::acos(cosine)) / TMath::Pi();
111 double bin = double(360.0) / double(fNbins);
114 id = int(theta / bin);
115 else if (sinsign < 0)
116 id = int(theta / bin) + (fNbins / 2);
117 if (
id > (fNbins - 1))
id = (fNbins - 1);
119 fBins[id].Add(fPoints2D[i]);
120 fBins[(
id + 1) % fNbins].Add(fPoints2D[i]);
129 for (
unsigned int id = 0;
id < fNbins;
id++)
130 fBins[
id].Add(fPoints2D[saveid]);
137 unsigned int saveid = 0;
138 for (
unsigned int i = 0; i < fNbins; i++)
139 if (
fBins[i].Size() && (fMaxCharge <
fBins[i].GetTotCharge())) {
140 fMaxCharge =
fBins[i].GetTotCharge();
144 fMaxChargeIdBin = saveid;
151 if (fNbins == 0)
return;
153 unsigned int iprev, inext;
155 if (fMaxChargeIdBin > 0)
156 iprev = fMaxChargeIdBin - 1;
160 inext = (fMaxChargeIdBin + 1) % fNbins;
162 double sumcharge = 0.0;
163 for (
unsigned int i = 0; i < fNbins; i++)
164 if ((i != fMaxChargeIdBin) && (i != iprev) && (i != inext))
165 sumcharge +=
fBins[i].GetTotCharge();
167 fMeanCharge = sumcharge / double(fNbins);
173 if ((fMaxCharge + fMeanCharge) == 0)
return 0.0;
174 return ((fMaxCharge - fMeanCharge) / (fMaxCharge + fMeanCharge));
181 : fNbins(nbins), fIdCl(idcl), fCandidateID(0), fIsCandidateIDset(
false)
185 for (
unsigned int i = 0; i < src.size(); i++) {
192 for (
unsigned int i = 0; i <
fNbins; i++)
209 for (
unsigned int i = 0; i < fPoints2D.size(); i++) {
210 nomx += fPoints2D[i]->GetPointCm().X() * fPoints2D[i]->GetCharge();
211 nomy += fPoints2D[i]->GetPointCm().Y() * fPoints2D[i]->GetCharge();
212 denom += fPoints2D[i]->GetCharge();
215 double bx = nomx / denom;
216 double by = nomy / denom;
217 fBaryCenter.Set(bx, by);
223 TVector2 vstart(0, 1);
225 for (
unsigned int i = 0; i < fPoints2D.size(); i++) {
226 TVector2 pos(fPoints2D[i]->GetPointCm().
X(), fPoints2D[i]->GetPointCm().Y());
227 TVector2 vecp = pos - fBaryCenter;
228 float sinsign = (vstart.X() * vecp.Y()) - (vstart.Y() * vecp.X());
229 float cosine = (vstart * vecp) / (vstart.Mod() * vecp.Mod());
230 float theta = 180.0F * (std::acos(cosine)) / TMath::Pi();
233 double bin = double(360.0) / double(fNbins);
236 id = int(theta / bin);
237 else if (sinsign < 0)
238 id = int(theta / bin) + (fNbins / 2);
239 if (
id > (fNbins - 1))
id = (fNbins - 1);
241 fBins[id].Add(fPoints2D[i]);
244 for (
unsigned int id = 0;
id <
fBins.size();
id++)
251 double maxdist2 = 0.0;
253 for (
unsigned int id = 0;
id <
fBins.size();
id++) {
255 if (!
fBins[
id].Size())
continue;
257 Hit2D* candidate =
fBins[id].GetHits2D().front();
260 if (dist2 > maxdist2) { maxdist2 = dist2; }
264 fNormDist = std::sqrt(maxdist2);
270 float rad = 0.5F * fNormDist;
271 unsigned int nbins = fNbins * 4;
272 for (
unsigned int id = 0;
id < fNbins;
id++) {
274 if (!
fBins[
id].Size())
continue;
276 std::vector<Hit2D*> points;
277 Hit2D* candidate2D =
fBins[id].GetHits2D().front();
279 for (
unsigned int i = 0; i < fPoints2D.size(); i++) {
283 if ((distnorm > 0.5) && (dist2 < rad * rad)) points.push_back(fPoints2D[i]);
286 if (
fBins[
id].Size() > 1) {
287 EndPoint ep(*candidate2D, points, nbins);
288 fCandidates.push_back(ep);
291 if (fCandidates.size())
301 for (
unsigned int i = 0; i < fCandidates.size(); i++) {
302 if (fCandidates[i].GetMaxCharge() > fNormCharge) {
303 fNormCharge = fCandidates[i].GetMaxCharge();
311 double max_asymmetry = 0.0;
312 unsigned int saveid = 0;
315 double maxdist2 = 0.0;
316 double maxcharge = 0.0;
317 unsigned int idmaxdist = 0;
318 unsigned int idmaxcharge = 0;
320 for (
unsigned int i = 0; i < fCandidates.size(); i++) {
321 double dist2 =
pma::Dist2(fCandidates[i].GetPosition(), fBaryCenter);
322 double charge = fCandidates[i].GetMaxCharge();
323 if (dist2 > maxdist2) {
327 if (charge > maxcharge) {
334 unsigned int idmaxdistb = 0;
335 for (
size_t i = 0; i < fCandidates.size(); i++) {
336 if ((i == idmaxdist) || (i == idmaxcharge))
continue;
338 double dist2 =
pma::Dist2(fCandidates[i].GetPosition(), fCandidates[idmaxdist].GetPosition());
339 if (dist2 > maxdist2) {
345 if (fCandidates.size() > 2) {
346 for (
unsigned int i = 0; i < fCandidates.size(); i++) {
347 double asymmetry = fCandidates[i].GetAsymmetry();
349 if ((i == idmaxdist) || (i == idmaxcharge) || (i == idmaxdistb)) {
350 if (asymmetry > max_asymmetry) {
351 max_asymmetry = asymmetry;
359 for (
unsigned int i = 0; i < fCandidates.size(); i++) {
360 double asymmetry = fCandidates[i].GetAsymmetry();
362 if ((i == idmaxdist) || (i == idmaxdistb)) {
363 if (asymmetry > max_asymmetry) {
364 max_asymmetry = asymmetry;
373 mf::LogError(
"DirOfGamma") << fCandidates.size() <<
"DirOfGamma - Find Initial Part problem.";
375 fStartHit = fCandidates[saveid].GetHit();
376 fStartPoint = fCandidates[saveid].GetPosition();
377 fIniHits = fCandidates[saveid].MaxChargeBin().GetIniHits();
378 fCandidateID = saveid;
geo::Length_t WireCoordinate(double YPos, double ZPos, geo::PlaneID const &planeid) const
Returns the index of the nearest wire to the specified position.
DirOfGamma(const detinfo::DetectorPropertiesData &detProp, const std::vector< art::Ptr< recob::Hit >> &src, unsigned int nbins, unsigned int idcl)
Utilities related to art service access.
PlaneGeo const & Plane(unsigned int const p, unsigned int const tpc=0, unsigned int const cstat=0) const
Returns the specified wire.
process_name opflash particleana ie x
double Dist2(const TVector2 &v1, const TVector2 &v2)
std::vector< art::Ptr< recob::Hit > > fHits
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
constexpr details::BinObj< T > bin(T value)
Returns a wrapper to print the specified data in binary format.
art::Ptr< recob::Hit > const & GetHitPtr() const
std::vector< Bin2D > fBins
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
Hit2D(detinfo::DetectorPropertiesData const &detProp, art::Ptr< recob::Hit > src)
EndPoint(const Hit2D ¢er, const std::vector< Hit2D * > &hits, unsigned int nbins)
Description of geometry of one entire detector.
std::vector< art::Ptr< recob::Hit > > GetIniHits(const double radius=10.0, const unsigned int nhits=10) const
Encapsulate the geometry of a wire.
double ConvertTicksToX(double ticks, int p, int t, int c) const
TVector2 const & GetPointCm() const
double GetAsymmetry() const
std::vector< Bin2D > fBins
art framework interface to geometry description
std::vector< Hit2D * > fPoints2D
WireGeo const & WireIDToWireGeo(geo::WireID const &wireid) const
Bin2D(const TVector2 ¢er)