-
Notifications
You must be signed in to change notification settings - Fork 55
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 78 commits
3abd95c
4d2df24
619cc9d
8c71d0b
bb7fca3
04973a2
a8816a2
7a1e130
70ee378
9a41019
8ab2400
b2c99ca
2736872
dbcec4b
f63553b
064df71
1fbb828
90533bc
382de1d
1808514
d137623
184ba70
ae53aa5
785cf59
a23b8fe
311ee02
a36a2b5
e7951b5
1db5fd5
813ff32
d075348
3a30ea5
4b0b4c5
298f171
9c94f32
c67ed63
774ebe2
eae9be3
be7a13b
c41582b
5d1cc28
39745f4
c44a0cf
87ca9dc
e627109
c78d55d
10e4916
1b10ce5
612a577
d49df9d
33bb8a3
a4b6724
a705deb
32a391c
48ef455
2f7a877
b5e00dc
4dfcb26
bb4f59a
378d685
bc843e7
104e1ac
5ce9ad2
4502f76
6267b1e
50dba79
296d8d1
4a69c2b
1d49586
361f09e
dc54a8e
92d3f00
b93b540
37b4ba2
318787a
62286d3
25cd547
e3bb6d5
157371a
27eee18
9f2063d
f1ed77c
9bba0cd
e6fc3b5
6f191c2
aae6516
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,7 @@ namespace BlipUtils { | |||||||||||||
| pinfo.pathLength = PathLength( part, pinfo.startPoint, pinfo.endPoint); | ||||||||||||||
|
|
||||||||||||||
| // Central position of trajectory | ||||||||||||||
| pinfo.position = 0.5*(pinfo.startPoint+pinfo.endPoint); | ||||||||||||||
| pinfo.Position = geo::vect::middlePoint({ pinfo.startPoint, pinfo.endPoint }); | ||||||||||||||
|
|
||||||||||||||
| // Energy/charge deposited by this particle, found using SimEnergyDeposits | ||||||||||||||
| pinfo.depEnergy = 0; | ||||||||||||||
|
|
@@ -145,7 +145,7 @@ namespace BlipUtils { | |||||||||||||
|
|
||||||||||||||
| // If this is a new blip, initialize | ||||||||||||||
| if( !tblip.G4ChargeMap.size() ) { | ||||||||||||||
| tblip.Position = pinfo.position; | ||||||||||||||
| tblip.Position = pinfo.Position; | ||||||||||||||
| tblip.Time = pinfo.time; | ||||||||||||||
|
|
||||||||||||||
| // .. otherwise, check that the new particle | ||||||||||||||
|
|
@@ -155,7 +155,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()); | ||||||||||||||
| tblip.Time = w1*tblip.Time + w2*pinfo.time; | ||||||||||||||
| tblip.LeadCharge = pinfo.depElectrons; | ||||||||||||||
| // ... if the particle isn't a match, show's over | ||||||||||||||
|
|
@@ -196,15 +198,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 = (blip_i.Position-blip_j.Position).R(); //Size of vector spanning two blips | ||||||||||||||
| 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()); | ||||||||||||||
| 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; | ||||||||||||||
|
|
@@ -375,7 +379,7 @@ namespace BlipUtils { | |||||||||||||
| // ------------------------------------------------ | ||||||||||||||
| /// Look for valid wire intersections between | ||||||||||||||
| // central-most hits in each cluster | ||||||||||||||
| std::vector<TVector3> wirex; | ||||||||||||||
| std::vector<geo::Point_t> wirex; | ||||||||||||||
| for(size_t i=0; i<hcs.size(); i++) { | ||||||||||||||
| int pli = hcs[i].Plane; | ||||||||||||||
| auto const& planegeo = wireReadoutGeom->Get().Plane(geo::PlaneID{(unsigned int)hcs[i].Cryostat, (unsigned int)hcs[i].TPC, (unsigned int)hcs[i].Plane}); | ||||||||||||||
|
|
@@ -404,7 +408,7 @@ namespace BlipUtils { | |||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
| if( match3d ) { | ||||||||||||||
| TVector3 a(0., intsec_p.Y(), intsec_p.Z()); | ||||||||||||||
| geo::Point_t a{0., intsec_p.Y(), intsec_p.Z()}; | ||||||||||||||
| wirex.push_back(a); | ||||||||||||||
| newblip.clusters[pli] = hcs[i]; | ||||||||||||||
| newblip.clusters[plj] = hcs[j]; | ||||||||||||||
|
|
@@ -419,12 +423,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
+442
to
+444
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 +621,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 +641,7 @@ namespace BlipUtils { | |||||||||||||
| return L; | ||||||||||||||
| } | ||||||||||||||
| double PathLength(const simb::MCParticle& part){ | ||||||||||||||
| TVector3 a,b; | ||||||||||||||
| geo::Point_t a,b; | ||||||||||||||
| return PathLength(part,a,b); | ||||||||||||||
| } | ||||||||||||||
|
|
||||||||||||||
|
|
||||||||||||||
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.
As above:
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 (
MiddlePointAccumulator,StatCollector) in the outer loop, dealing withblip_i(and feeding in there the blipi), and then fill them in the inner loop:blip_iat the end of the loop: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.
At least on this one we get the weights slightly wrong doing the suggested splitting of additions to the accumulators, since we have to divide by the total charge.
Since we don't know which one blip_j will be its hard to apply the right contribution in the outer loop.
To avoid overadding blip_i after the position update i call
mpalg.clear();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.
Scratch out the last comment. I couldn't get the compiler happy with the mpalg.add calls
In file included from /cvmfs/larsoft.opensciencegrid.org/products/lardataobj/v10_03_02/include/lardataobj/RecoBase/TrackingTypes.h:5, from /cvmfs/larsoft.opensciencegrid.org/products/lardataobj/v10_03_02/include/lardataobj/RecoBase/Trajectory.h:18, from /cvmfs/larsoft.opensciencegrid.org/products/lardataobj/v10_03_02/include/lardataobj/RecoBase/TrackTrajectory.h:19, from /cvmfs/larsoft.opensciencegrid.org/products/lardataobj/v10_03_02/include/lardataobj/RecoBase/Track.h:13, from /exp/sbnd/app/users/jmclaugh/sbndcode_v10_14_00_01/srcs/sbndcode/sbndcode/BlipRecoSBND/Utils/BlipUtils.h:23, from /exp/sbnd/app/users/jmclaugh/sbndcode_v10_14_00_01/srcs/sbndcode/sbndcode/BlipRecoSBND/Utils/BlipUtils.cc:1: /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h: In instantiation of ‘void geo::vect::MiddlePointAccumulatorDim<N>::add(BeginIter, EndIter) [with BeginIter = ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*; EndIter = float; unsigned int N = 3]’: /exp/sbnd/app/users/jmclaugh/sbndcode_v10_14_00_01/srcs/sbndcode/sbndcode/BlipRecoSBND/Utils/BlipUtils.cc:159:16: required from here /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h:1420:22: error: no matching function for call to ‘for_each(ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*&, float&, geo::vect::MiddlePointAccumulatorDim<3>::add<ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float>(ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float)::<lambda(const auto:16&)>)’ 1420 | std::for_each(begin, end, [this](auto const& p) { this->add(p); }); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/functional:64, from /cvmfs/larsoft.opensciencegrid.org/products/canvas/v3_16_04/include/canvas/Persistency/Provenance/ProductID.h:9, from /cvmfs/larsoft.opensciencegrid.org/products/canvas/v3_16_04/include/canvas/Persistency/Common/RefCore.h:5, from /cvmfs/larsoft.opensciencegrid.org/products/canvas/v3_16_04/include/canvas/Persistency/Common/Ptr.h:44, from /exp/sbnd/app/users/jmclaugh/sbndcode_v10_14_00_01/srcs/sbndcode/sbndcode/BlipRecoSBND/Utils/BlipUtils.h:12: /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/bits/stl_algo.h:3781:5: note: candidate: ‘template<class _IIter, class _Funct> _Funct std::for_each(_IIter, _IIter, _Funct)’ 3781 | for_each(_InputIterator __first, _InputIterator __last, _Function __f) | ^~~~~~~~ /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/bits/stl_algo.h:3781:5: note: template argument deduction/substitution failed: /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h:1420:22: note: deduced conflicting types for parameter ‘_IIter’ (‘ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*’ and ‘float’) 1420 | std::for_each(begin, end, [this](auto const& p) { this->add(p); }); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/algorithm:73, from /cvmfs/larsoft.opensciencegrid.org/products/cetlib/v3_18_02/slf7.x86_64.e26.prof/include/cetlib/container_algorithms.h:12, from /cvmfs/larsoft.opensciencegrid.org/products/canvas/v3_16_04/include/canvas/Persistency/Common/detail/aggregate.h:5, from /cvmfs/larsoft.opensciencegrid.org/products/canvas/v3_16_04/include/canvas/Persistency/Common/Wrapper.h:18, from /cvmfs/larsoft.opensciencegrid.org/products/canvas/v3_16_04/include/canvas/Persistency/Common/Ptr.h:45: /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/pstl/glue_algorithm_defs.h:42:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator, class _Function> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::for_each(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Function)’ 42 | for_each(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Function __f); | ^~~~~~~~ /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/pstl/glue_algorithm_defs.h:42:1: note: template argument deduction/substitution failed: /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h:1420:22: note: deduced conflicting types for parameter ‘_ForwardIterator’ (‘float’ and ‘geo::vect::MiddlePointAccumulatorDim<3>::add<ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float>(ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float)::<lambda(const auto:16&)>’) 1420 | std::for_each(begin, end, [this](auto const& p) { this->add(p); }); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h: In instantiation of ‘void geo::vect::MiddlePointAccumulatorDim<N>::add(BeginIter, EndIter) [with BeginIter = const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*; EndIter = float; unsigned int N = 3]’: /exp/sbnd/app/users/jmclaugh/sbndcode_v10_14_00_01/srcs/sbndcode/sbndcode/BlipRecoSBND/Utils/BlipUtils.cc:212:20: required from here /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h:1420:22: error: no matching function for call to ‘for_each(const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*&, float&, geo::vect::MiddlePointAccumulatorDim<3>::add<const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float>(const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float)::<lambda(const auto:16&)>)’ /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/bits/stl_algo.h:3781:5: note: candidate: ‘template<class _IIter, class _Funct> _Funct std::for_each(_IIter, _IIter, _Funct)’ 3781 | for_each(_InputIterator __first, _InputIterator __last, _Function __f) | ^~~~~~~~ /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/bits/stl_algo.h:3781:5: note: template argument deduction/substitution failed: /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h:1420:22: note: deduced conflicting types for parameter ‘_IIter’ (‘const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*’ and ‘float’) 1420 | std::for_each(begin, end, [this](auto const& p) { this->add(p); }); | ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/pstl/glue_algorithm_defs.h:42:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator, class _Function> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::for_each(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, _Function)’ 42 | for_each(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, _Function __f); | ^~~~~~~~ /cvmfs/larsoft.opensciencegrid.org/products/gcc/v12_1_0/Linux64bit+3.10-2.17/include/c++/12.1.0/pstl/glue_algorithm_defs.h:42:1: note: template argument deduction/substitution failed: /cvmfs/larsoft.opensciencegrid.org/products/larcorealg/v10_00_03/include/larcorealg/Geometry/geo_vectors_utils.h:1420:22: note: deduced conflicting types for parameter ‘_ForwardIterator’ (‘float’ and ‘geo::vect::MiddlePointAccumulatorDim<3>::add<const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float>(const ROOT::Math::PositionVector3D<ROOT::Math::Cartesian3D<double>, ROOT::Math::GlobalCoordinateSystemTag>*, float)::<lambda(const auto:16&)>’) 1420 | std::for_each(begin, end, [this](auto const& p) { this->add(p); });So I reverted these to simple loops not taking advantage of new functionality of point_t classes
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.
Sloppy programming by that utility author (i.e. myself).
The compiler saw
add(tracking::Point_t, float)and it choseadd(BeginIter, EndIter)overadd(Point const&, double). Probablyposition.add(blip_i.Position, (double) weight_i)would have worked.