-
Notifications
You must be signed in to change notification settings - Fork 54
Feature/adding blip to caf #871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
3abd95c
4d2df24
619cc9d
8c71d0b
bb7fca3
04973a2
a8816a2
7a1e130
70ee378
9a41019
8ab2400
b2c99ca
2736872
dbcec4b
f63553b
064df71
1fbb828
1031a78
90533bc
382de1d
1808514
d137623
184ba70
ae53aa5
785cf59
a23b8fe
311ee02
a36a2b5
e7951b5
1db5fd5
813ff32
d075348
cbcb056
d7ca349
794d240
f886d99
3a30ea5
4b0b4c5
298f171
9c94f32
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -55,7 +55,9 @@ namespace BlipUtils { | |||||||||||||||||||||||||||||
| pinfo.pathLength = PathLength( part, pinfo.startPoint, pinfo.endPoint); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| // Central position of trajectory | ||||||||||||||||||||||||||||||
| pinfo.position = 0.5*(pinfo.startPoint+pinfo.endPoint); | ||||||||||||||||||||||||||||||
| pinfo.position.SetXYZ(0.5*(pinfo.startPoint.X()+pinfo.endPoint.X()), | ||||||||||||||||||||||||||||||
| 0.5*(pinfo.startPoint.Y()+pinfo.endPoint.Y()), | ||||||||||||||||||||||||||||||
| 0.5*(pinfo.startPoint.Z()+pinfo.endPoint.Z()) ); | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
Comment on lines
+58
to
61
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an unweighted middle point, so:
Suggested change
( |
||||||||||||||||||||||||||||||
| // Energy/charge deposited by this particle, found using SimEnergyDeposits | ||||||||||||||||||||||||||||||
| pinfo.depEnergy = 0; | ||||||||||||||||||||||||||||||
|
|
@@ -155,7 +157,9 @@ namespace BlipUtils { | |||||||||||||||||||||||||||||
| float totE = tblip.Energy + pinfo.depEnergy; | ||||||||||||||||||||||||||||||
| float w1 = tblip.Energy/totE; | ||||||||||||||||||||||||||||||
| float w2 = pinfo.depEnergy/totE; | ||||||||||||||||||||||||||||||
| tblip.Position = w1*tblip.Position + w2*pinfo.position; | ||||||||||||||||||||||||||||||
| tblip.Position.SetXYZ( w1*tblip.Position.X() + w2*pinfo.position.X(), | ||||||||||||||||||||||||||||||
| w1*tblip.Position.Y() + w2*pinfo.position.Y(), | ||||||||||||||||||||||||||||||
| w1*tblip.Position.Z() + w2*pinfo.position.Z()); | ||||||||||||||||||||||||||||||
|
Comment on lines
+160
to
+162
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the hardest one, being weighted. I would use the accumulator directly:
Suggested change
( |
||||||||||||||||||||||||||||||
| tblip.Time = w1*tblip.Time + w2*pinfo.time; | ||||||||||||||||||||||||||||||
| tblip.LeadCharge = pinfo.depElectrons; | ||||||||||||||||||||||||||||||
| // ... if the particle isn't a match, show's over | ||||||||||||||||||||||||||||||
|
|
@@ -196,15 +200,17 @@ namespace BlipUtils { | |||||||||||||||||||||||||||||
| // check that the times are similar (we don't want to merge | ||||||||||||||||||||||||||||||
| // together a blip that happened much later but in the same spot) | ||||||||||||||||||||||||||||||
| if( fabs(blip_i.Time - blip_j.Time) > 5 ) continue; | ||||||||||||||||||||||||||||||
| float d = (blip_i.Position-blip_j.Position).Mag(); | ||||||||||||||||||||||||||||||
| float d = TMath::Sqrt((blip_i.Position-blip_j.Position).Mag2()); | ||||||||||||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can directly use
Suggested change
Also note that for determining the closest point, you don't really need to take the square root of the square distance, because the minimum distance is also the minimum distance square, so you can look for the latter and save a tiny bit of computing time. |
||||||||||||||||||||||||||||||
| if( d < dmin ) { | ||||||||||||||||||||||||||||||
| isGrouped.at(j) = true; | ||||||||||||||||||||||||||||||
| //float totE = blip_i.Energy + blip_j.Energy; | ||||||||||||||||||||||||||||||
| float totQ = blip_i.DepElectrons + blip_j.DepElectrons; | ||||||||||||||||||||||||||||||
| float w1 = blip_i.DepElectrons/totQ; | ||||||||||||||||||||||||||||||
| float w2 = blip_j.DepElectrons/totQ; | ||||||||||||||||||||||||||||||
| blip_i.Energy += blip_j.Energy; | ||||||||||||||||||||||||||||||
| blip_i.Position = w1*blip_i.Position + w2*blip_j.Position; | ||||||||||||||||||||||||||||||
| blip_i.Position.SetXYZ( w1*blip_i.Position.X() + w2*blip_j.Position.X(), | ||||||||||||||||||||||||||||||
| w1*blip_i.Position.Y() + w2*blip_j.Position.Y(), | ||||||||||||||||||||||||||||||
| w1*blip_i.Position.Z() + w2*blip_j.Position.Z()); | ||||||||||||||||||||||||||||||
|
Comment on lines
+211
to
+213
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above:
Suggested change
However, here we are in a loop context, so I recommend that the accumulation is done first, and then the results saved. You can declare your accumulators (
|
||||||||||||||||||||||||||||||
| blip_i.DriftTime = w1*blip_i.DriftTime+ w2*blip_j.DriftTime; | ||||||||||||||||||||||||||||||
| blip_i.Time = w1*blip_i.Time + w2*blip_j.Time; | ||||||||||||||||||||||||||||||
| blip_i.DepElectrons += blip_j.DepElectrons; | ||||||||||||||||||||||||||||||
|
|
@@ -419,12 +425,16 @@ namespace BlipUtils { | |||||||||||||||||||||||||||||
| // YZ-plane, as well as the mean difference between intersection points. | ||||||||||||||||||||||||||||||
| newblip.Position.SetXYZ(0,0,0); | ||||||||||||||||||||||||||||||
| if( wirex.size() == 1 ) { | ||||||||||||||||||||||||||||||
| newblip.Position= wirex[0]; | ||||||||||||||||||||||||||||||
| newblip.Position = wirex[0]; | ||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||
| newblip.SigmaYZ = 0; | ||||||||||||||||||||||||||||||
| double fact = 1./wirex.size(); | ||||||||||||||||||||||||||||||
| for(auto& v : wirex ) newblip.Position += v * fact; | ||||||||||||||||||||||||||||||
| for(auto& v : wirex ) newblip.SigmaYZ += (v-newblip.Position).Mag() * fact; | ||||||||||||||||||||||||||||||
| for(auto& v : wirex ) newblip.Position.SetXYZ( newblip.Position.X() + v.X() * fact, | ||||||||||||||||||||||||||||||
| newblip.Position.Y() + v.Y() * fact, | ||||||||||||||||||||||||||||||
| newblip.Position.Z() + v.Z() * fact); | ||||||||||||||||||||||||||||||
|
Comment on lines
+432
to
+434
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should work:
Suggested change
I think this will work, still, given the following, it would be better having |
||||||||||||||||||||||||||||||
| for(auto& v : wirex ) newblip.SigmaYZ += TMath::Sqrt( pow(v.X()-newblip.Position.X(), 2) + | ||||||||||||||||||||||||||||||
| pow(v.Y()-newblip.Position.Y(), 2) + | ||||||||||||||||||||||||||||||
| pow(v.Z()-newblip.Position.Z(), 2)) * fact; | ||||||||||||||||||||||||||||||
| // Ensure that difference between intersection points is | ||||||||||||||||||||||||||||||
| // consistent with the maximal wire extent | ||||||||||||||||||||||||||||||
| if( newblip.SigmaYZ > std::max(1.,0.5*newblip.dYZ) ) return newblip; | ||||||||||||||||||||||||||||||
|
|
@@ -613,7 +623,7 @@ namespace BlipUtils { | |||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
| //============================================================================= | ||||||||||||||||||||||||||||||
| // Length of particle trajectory | ||||||||||||||||||||||||||||||
| double PathLength(const simb::MCParticle& part, TVector3& start, TVector3& end) | ||||||||||||||||||||||||||||||
| double PathLength(const simb::MCParticle& part, geo::Point_t& start, geo::Point_t& end) | ||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||
| int n = part.NumberTrajectoryPoints(); | ||||||||||||||||||||||||||||||
| if( n <= 1 ) return 0.; | ||||||||||||||||||||||||||||||
|
|
@@ -633,7 +643,7 @@ namespace BlipUtils { | |||||||||||||||||||||||||||||
| return L; | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
| double PathLength(const simb::MCParticle& part){ | ||||||||||||||||||||||||||||||
| TVector3 a,b; | ||||||||||||||||||||||||||||||
| geo::Point_t a,b; | ||||||||||||||||||||||||||||||
| return PathLength(part,a,b); | ||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Conversion
geo::Point_t→TVector3:(
#include "larcorealg/Geometry/geo_vectors_utils_TVector.h"); or using the more genericconvertTo():(for this one:
#include "larcorealg/Geometry/geo_vectors_utils.h").