21 for(
auto const&
id : pset.
get<std::vector<int> >(
"SavePathPDGList"))
29 _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();
30 _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();
31 _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();
32 _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();
33 _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();
34 _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();
43 unsigned int result = this->at(part_index)._mother;
45 if(!result)
return this->at(part_index)._track_id;
51 unsigned int daughter_id = this->at(part_index)._track_id;
53 for(
auto const&
part : *
this) {
55 if(
part._daughters.find(daughter_id) !=
part._daughters.end())
57 return part._track_id;
69 if((*
this)[part_index]._ancestor !=
kINVALID_UINT)
return (*
this)[part_index]._ancestor;
73 if(result == this->at(part_index)._track_id)
return result;
75 if(!result)
return this->at(part_index)._track_id;
85 if(new_result == this->at(mother_index)._track_id)
break;
92 auto const old_result = result;
93 for(
auto const& p : *
this) {
95 if(p._daughters.find(result) != p._daughters.end()) {
100 if(result == old_result)
108 (*this)[part_index]._ancestor = result;
115 const double&
z)
const 125 const std::vector<simb::Origin_t>& orig_v)
128 if(orig_v.size() != mcp_v.size())
throw cet::exception(__FUNCTION__) <<
"MCParticle and Origin_t vector size not same!";
133 for(
size_t i=0; i < mcp_v.size(); ++i) {
135 auto const& mcp = mcp_v[i];
139 _track_index.insert(std::make_pair((
size_t)(mcp.TrackId()),(
size_t)(this->size())));
143 auto& mini_mcp = (*this->rbegin());
145 for(
size_t i=0; i<(size_t)(mcp.NumberDaughters()); ++i)
146 mini_mcp._daughters.insert(mcp.Daughter(i));
148 mini_mcp._track_id = mcp.TrackId();
149 mini_mcp._pdgcode = mcp.PdgCode();
150 mini_mcp._mother = mcp.Mother();
151 mini_mcp._process = mcp.Process();
152 mini_mcp._start_vtx = mcp.Position();
153 mini_mcp._start_mom = mcp.Momentum();
154 mini_mcp._end_vtx = mcp.EndPosition();
155 mini_mcp._end_mom = mcp.EndMomentum();
156 mini_mcp._origin = orig_v[i];
159 for(
size_t i=0; i<4; ++i) {
160 mini_mcp._start_mom[i] *= 1.e3;
161 mini_mcp._end_mom[i] *= 1.e3;
174 std::set<size_t> det_path_index;
176 for(
size_t i=0; i<mcp.NumberTrajectoryPoints(); ++i) {
180 det_path_index.insert(i);
184 if(det_path_index.size()) {
185 if( (*det_path_index.begin()) )
186 det_path_index.insert( (*det_path_index.begin())-1 );
187 if( det_path_index.size()>1 ) {
188 if( ((*det_path_index.rbegin())+1) < mcp.NumberTrajectoryPoints() )
189 det_path_index.insert( (*det_path_index.rbegin())+1 );
191 mini_mcp._det_path.reserve(det_path_index.size());
192 for(
auto const& index : det_path_index) {
194 TLorentzVector vec(mcp.Momentum(index));
195 for(
size_t i=0; i<4; ++i) vec[i] *= 1.e3;
197 mini_mcp._det_path.push_back(std::make_pair(mcp.Position(index),vec));
double _z_max
z-max of volume box used to determine whether to save track information
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::map< unsigned int, unsigned int > _track_index
Track ID => Index Map.
TPC_iterator begin_TPC() const
Returns an iterator pointing to the first TPC in the detector.
double _z_min
z-min of volume box used to determine whether to save track information
unsigned int AncestorTrackID(const unsigned int part_index)
MCRecoPart(fhicl::ParameterSet const &pset)
Default constructor with fhicl parameters.
void AddParticles(const std::vector< simb::MCParticle > &mcp_v, const std::vector< simb::Origin_t > &orig_v)
T get(std::string const &key) const
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
Namespace collecting geometry-related classes utilities.
bool InDetector(const double &x, const double &y, const double &z) const
unsigned int TrackToParticleIndex(const unsigned int track_id) const
cet::coded_exception< error, detail::translate > exception
TPC_iterator end_TPC() const
Returns an iterator pointing after the last TPC in the detector.