All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | Protected Attributes | List of all members
sim::MCRecoPart Class Reference

#include <MCRecoPart.h>

Inheritance diagram for sim::MCRecoPart:

Public Member Functions

 MCRecoPart (fhicl::ParameterSet const &pset)
 Default constructor with fhicl parameters. More...
 
virtual ~MCRecoPart ()
 Default destructor. More...
 
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 AncestorTrackID (const unsigned int part_index)
 
unsigned int MotherTrackID (const unsigned int part_index) const
 
unsigned int TrackToParticleIndex (const unsigned int track_id) const
 
bool InDetector (const double &x, const double &y, const double &z) const
 

Public Attributes

std::map< unsigned int,
unsigned int > 
_track_index
 Track ID => Index Map. More...
 
std::set< int > _pdg_list
 PDG code list for which particle's trajectory within the detector is saved. More...
 
- Public Attributes inherited from std::vector< T >
elements
 STL member. More...
 

Protected Attributes

double _x_max
 x-max of volume box used to determine whether to save track information More...
 
double _x_min
 x-min of volume box used to determine whether to save track information More...
 
double _y_max
 y-max of volume box used to determine whether to save track information More...
 
double _y_min
 y-min of volume box used to determine whether to save track information More...
 
double _z_max
 z-max of volume box used to determine whether to save track information More...
 
double _z_min
 z-min of volume box used to determine whether to save track information More...
 

Detailed Description

Definition at line 108 of file MCRecoPart.h.

Constructor & Destructor Documentation

sim::MCRecoPart::MCRecoPart ( fhicl::ParameterSet const &  pset)

Default constructor with fhicl parameters.

Definition at line 19 of file MCRecoPart.cxx.

21  {
22  this->clear();
23  _track_index.clear();
24  _pdg_list.clear();
25  for(auto const& id : pset.get<std::vector<int> >("SavePathPDGList"))
26 
27  _pdg_list.insert(id);
28 
29  art::ServiceHandle<geo::Geometry const> geo;
30  // Build "Fiducial" Volume Definition:
31  //
32  // Iterate over all TPC's to get bounding box that covers volumes of each individual TPC in the detector
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();
39  }
double _z_max
z-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:156
double _y_max
y-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:154
double _y_min
y-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:155
std::map< unsigned int, unsigned int > _track_index
Track ID =&gt; Index Map.
Definition: MCRecoPart.h:144
double _z_min
z-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:157
double _x_max
x-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:152
double _x_min
x-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:153
std::set< int > _pdg_list
PDG code list for which particle&#39;s trajectory within the detector is saved.
Definition: MCRecoPart.h:148
virtual sim::MCRecoPart::~MCRecoPart ( )
inlinevirtual

Default destructor.

Definition at line 116 of file MCRecoPart.h.

116 {};

Member Function Documentation

void sim::MCRecoPart::AddParticles ( const std::vector< simb::MCParticle > &  mcp_v,
const std::vector< simb::Origin_t > &  orig_v,
const std::vector< sim::MCParticleLite > &  mcmp_v = {} 
)

Definition at line 128 of file MCRecoPart.cxx.

132  {
133  if(orig_v.size() != mcp_v.size()) throw cet::exception(__FUNCTION__) << "MCParticle and Origin_t vector size not same!";
134 
135  this->clear();
136  _track_index.clear();
137 
138  for(size_t i=0; i < mcp_v.size(); ++i) {
139 
140  auto const& mcp = mcp_v[i];
141 
142  //std::cout<<" Track ID : "<<mcp.TrackId()<<" ... Index : " <<this->size()<<std::endl;
143 
144  _track_index.insert(std::make_pair((size_t)(mcp.TrackId()),(size_t)(this->size())));
145 
146  // Change units to LArSoft (MeV, cm, us)
147  // (done inside constructor of MCMiniPart)
148  this->push_back(MCMiniPart(mcp));
149 
150  auto& mini_mcp = (*this->rbegin());
151 
152  for(size_t i=0; i<(size_t)(mcp.NumberDaughters()); ++i) {
153  mini_mcp.AddDaughter( mcp.Daughter(i) );
154  }
155  mini_mcp._origin = orig_v[i];
156 
157  if(_pdg_list.find(mcp.PdgCode()) != _pdg_list.end()) {
158 
159  std::set<size_t> det_path_index;
160 
161  for(size_t i=0; i<mcp.NumberTrajectoryPoints(); ++i) {
162 
163  if(InDetector(mcp.Vx(i),mcp.Vy(i),mcp.Vz(i)))
164 
165  det_path_index.insert(i);
166 
167  }
168 
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 );
175  }
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) {
179 
180  TLorentzVector vec(mcp.Momentum(index));
181  for(size_t i=0; i<4; ++i) vec[i] *= 1.e3;
182 
183  det_path.emplace_back(mcp.Position(index), vec);
184 
185  }
186  mini_mcp._det_path = std::move(det_path);
187  }
188  } // end if in _pdg_list
189  } // end for loop over mcp_v
190 
191  // Now loop over dropped particles
192  for(auto const& mcmp : mcmp_v) {
193 
194  _track_index.try_emplace(mcmp.TrackID(), this->size());
195 
196  this->push_back(sim::MCMiniPart(mcmp));
197 
198  } // end for loop over mcmp_v
199  } // end AddParticles
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
std::map< unsigned int, unsigned int > _track_index
Track ID =&gt; Index Map.
Definition: MCRecoPart.h:144
std::set< int > _pdg_list
PDG code list for which particle&#39;s trajectory within the detector is saved.
Definition: MCRecoPart.h:148
bool InDetector(const double &x, const double &y, const double &z) const
Definition: MCRecoPart.cxx:117
unsigned int sim::MCRecoPart::AncestorTrackID ( const unsigned int  part_index)

Definition at line 68 of file MCRecoPart.cxx.

70  {
71  if(part_index >= this->size()) return kINVALID_UINT;
72 
73  if((*this)[part_index]._ancestor != kINVALID_UINT) return (*this)[part_index]._ancestor;
74 
75  auto result = MotherTrackID(part_index);
76 
77  if(result == this->at(part_index)._track_id) return result;
78 
79  if(!result) return this->at(part_index)._track_id;
80 
81  auto mother_index = TrackToParticleIndex(result);
82 
83  while(1) {
84 
85  if(mother_index != kINVALID_UINT) {
86 
87  auto const new_result = MotherTrackID(mother_index);
88 
89  if(new_result == this->at(mother_index)._track_id) break;
90 
91  result = new_result;
92 
93  }else{
94 
95  // Look for a particle that has a daughter = this mother
96  auto const old_result = result;
97  for(auto const& p : *this) {
98 
99  if(p.HasDaughter(result)) {
100  result = p._track_id;
101  break;
102  }
103  }
104  if(result == old_result)
105  break;
106  }
107 
108  mother_index = TrackToParticleIndex(result);
109 
110  }
111 
112  (*this)[part_index]._ancestor = result;
113  return result;
114  }
pdgs p
Definition: selectors.fcl:22
unsigned int MotherTrackID(const unsigned int part_index) const
Definition: MCRecoPart.cxx:42
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
unsigned int TrackToParticleIndex(const unsigned int track_id) const
Definition: MCRecoPart.h:130
bool sim::MCRecoPart::InDetector ( const double &  x,
const double &  y,
const double &  z 
) const

Definition at line 117 of file MCRecoPart.cxx.

121  {
122  return !( x > _x_max || x < _x_min ||
123  z > _z_max || z < _z_min ||
124  y > _y_max || y < _y_min );
125  }
process_name opflash particleana ie ie ie z
double _z_max
z-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:156
process_name opflash particleana ie x
double _y_max
y-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:154
double _y_min
y-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:155
double _z_min
z-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:157
process_name opflash particleana ie ie y
double _x_max
x-max of volume box used to determine whether to save track information
Definition: MCRecoPart.h:152
double _x_min
x-min of volume box used to determine whether to save track information
Definition: MCRecoPart.h:153
unsigned int sim::MCRecoPart::MotherTrackID ( const unsigned int  part_index) const

Definition at line 42 of file MCRecoPart.cxx.

44  {
45  if(this->size() <= part_index) return ::sim::kINVALID_UINT;
46 
47  unsigned int result = this->at(part_index)._mother;
48 
49  if(!result) return this->at(part_index)._track_id;
50 
51  if(TrackToParticleIndex(result) != ::sim::kINVALID_UINT) return result;
52 
53  //std::cout<< "\033[95mWarning:\033[00m Mother particle not in the particle list!"<<std::endl;
54  // Do brute search
55  unsigned int daughter_id = this->at(part_index)._track_id;
56 
57  for(auto const& part : *this) {
58 
59  if(part.HasDaughter(daughter_id) )
60 
61  return part._track_id;
62 
63  }
64  return result;
65  }
std::size_t size(FixedBins< T, C > const &) noexcept
Definition: FixedBins.h:561
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14
unsigned int TrackToParticleIndex(const unsigned int track_id) const
Definition: MCRecoPart.h:130
unsigned int sim::MCRecoPart::TrackToParticleIndex ( const unsigned int  track_id) const
inline

Definition at line 130 of file MCRecoPart.h.

131  {
132  auto const iter (_track_index.find(track_id));
133  if(iter==_track_index.end()) return kINVALID_UINT;
134  return (*iter).second;
135  }
std::map< unsigned int, unsigned int > _track_index
Track ID =&gt; Index Map.
Definition: MCRecoPart.h:144
const unsigned int kINVALID_UINT
Definition: MCLimits.h:14

Member Data Documentation

std::set<int> sim::MCRecoPart::_pdg_list

PDG code list for which particle's trajectory within the detector is saved.

Definition at line 148 of file MCRecoPart.h.

std::map<unsigned int, unsigned int> sim::MCRecoPart::_track_index

Track ID => Index Map.

Definition at line 144 of file MCRecoPart.h.

double sim::MCRecoPart::_x_max
protected

x-max of volume box used to determine whether to save track information

Definition at line 152 of file MCRecoPart.h.

double sim::MCRecoPart::_x_min
protected

x-min of volume box used to determine whether to save track information

Definition at line 153 of file MCRecoPart.h.

double sim::MCRecoPart::_y_max
protected

y-max of volume box used to determine whether to save track information

Definition at line 154 of file MCRecoPart.h.

double sim::MCRecoPart::_y_min
protected

y-min of volume box used to determine whether to save track information

Definition at line 155 of file MCRecoPart.h.

double sim::MCRecoPart::_z_max
protected

z-max of volume box used to determine whether to save track information

Definition at line 156 of file MCRecoPart.h.

double sim::MCRecoPart::_z_min
protected

z-min of volume box used to determine whether to save track information

Definition at line 157 of file MCRecoPart.h.


The documentation for this class was generated from the following files: