7 #include "art/Framework/Services/Registry/ServiceHandle.h"
8 #include "fhiclcpp/ParameterSet.h"
12 #include "nusimdata/SimulationBase/MCParticle.h"
25 for(
auto const&
id : pset.get<std::vector<int> >(
"SavePathPDGList"))
29 art::ServiceHandle<geo::Geometry const> geo;
33 _x_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](
auto const &lhs,
auto const &rhs){
return lhs.BoundingBox().MinX() < rhs.BoundingBox().MinX();})->MinX();
34 _y_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](
auto const &lhs,
auto const &rhs){
return lhs.BoundingBox().MinY() < rhs.BoundingBox().MinY();})->MinY();
35 _z_min = std::min_element(geo->begin_TPC(), geo->end_TPC(), [](
auto const &lhs,
auto const &rhs){
return lhs.BoundingBox().MinZ() < rhs.BoundingBox().MinZ();})->MinZ();
36 _x_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](
auto const &lhs,
auto const &rhs){
return lhs.BoundingBox().MaxX() < rhs.BoundingBox().MaxX();})->MaxX();
37 _y_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](
auto const &lhs,
auto const &rhs){
return lhs.BoundingBox().MaxY() < rhs.BoundingBox().MaxY();})->MaxY();
38 _z_max = std::max_element(geo->begin_TPC(), geo->end_TPC(), [](
auto const &lhs,
auto const &rhs){
return lhs.BoundingBox().MaxZ() < rhs.BoundingBox().MaxZ();})->MaxZ();
47 unsigned int result = this->at(part_index)._mother;
49 if(!result)
return this->at(part_index)._track_id;
55 unsigned int daughter_id = this->at(part_index)._track_id;
57 for(
auto const& part : *
this) {
59 if(part.HasDaughter(daughter_id) )
61 return part._track_id;
73 if((*
this)[part_index]._ancestor !=
kINVALID_UINT)
return (*
this)[part_index]._ancestor;
77 if(result == this->at(part_index)._track_id)
return result;
79 if(!result)
return this->at(part_index)._track_id;
89 if(new_result == this->at(mother_index)._track_id)
break;
96 auto const old_result = result;
97 for(
auto const&
p : *
this) {
99 if(
p.HasDaughter(result)) {
100 result =
p._track_id;
104 if(result == old_result)
112 (*this)[part_index]._ancestor = result;
119 const double&
z)
const
122 return !(
x > _x_max ||
x < _x_min ||
123 z > _z_max ||
z < _z_min ||
124 y > _y_max ||
y < _y_min );
129 const std::vector<simb::Origin_t>& orig_v,
130 const std::vector<sim::MCParticleLite>& mcmp_v)
133 if(orig_v.size() != mcp_v.size())
throw cet::exception(__FUNCTION__) <<
"MCParticle and Origin_t vector size not same!";
138 for(
size_t i=0; i < mcp_v.size(); ++i) {
140 auto const& mcp = mcp_v[i];
144 _track_index.insert(std::make_pair((
size_t)(mcp.TrackId()),(
size_t)(this->
size())));
150 auto& mini_mcp = (*this->rbegin());
152 for(
size_t i=0; i<(size_t)(mcp.NumberDaughters()); ++i) {
153 mini_mcp.AddDaughter( mcp.Daughter(i) );
155 mini_mcp._origin = orig_v[i];
159 std::set<size_t> det_path_index;
161 for(
size_t i=0; i<mcp.NumberTrajectoryPoints(); ++i) {
165 det_path_index.insert(i);
169 if(det_path_index.size()) {
170 if( (*det_path_index.begin()) )
171 det_path_index.insert( (*det_path_index.begin())-1 );
172 if( det_path_index.size()>1 ) {
173 if( ((*det_path_index.rbegin())+1) < mcp.NumberTrajectoryPoints() )
174 det_path_index.insert( (*det_path_index.rbegin())+1 );
176 std::vector<std::pair<TLorentzVector,TLorentzVector>> det_path;
177 det_path.reserve(det_path_index.size());
178 for(
auto const& index : det_path_index) {
180 TLorentzVector vec(mcp.Momentum(index));
181 for(
size_t i=0; i<4; ++i) vec[i] *= 1.e3;
183 det_path.emplace_back(mcp.Position(index), vec);
186 mini_mcp._det_path = std::move(det_path);
192 for(
auto const& mcmp : mcmp_v) {
process_name opflash particleana ie ie ie z
double _z_max
z-max of volume box used to determine whether to save track information
process_name opflash particleana ie x
void AddParticles(const std::vector< simb::MCParticle > &mcp_v, const std::vector< simb::Origin_t > &orig_v, const std::vector< sim::MCParticleLite > &mcmp_v={})
unsigned int MotherTrackID(const unsigned int part_index) const
double _y_max
y-max of volume box used to determine whether to save track information
double _y_min
y-min of volume box used to determine whether to save track information
std::size_t size(FixedBins< T, C > const &) noexcept
std::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
Access the description of detector geometry.
double _z_min
z-min of volume box used to determine whether to save track information
unsigned int AncestorTrackID(const unsigned int part_index)
process_name opflash particleana ie ie y
MCRecoPart(fhicl::ParameterSet const &pset)
Default constructor with fhicl parameters.
double _x_max
x-max of volume box used to determine whether to save track information
double _x_min
x-min of volume box used to determine whether to save track information
std::set< int > _pdg_list
PDG code list for which particle's trajectory within the detector is saved.
const unsigned int kINVALID_UINT
bool InDetector(const double &x, const double &y, const double &z) const
unsigned int TrackToParticleIndex(const unsigned int track_id) const
art framework interface to geometry description