34 auto result = std::make_unique<std::vector<sim::MCTrack>>();
35 auto& mctracks = *result;
38 for(
size_t i=0; i<part_v.size(); ++i) {
39 auto const& mini_part = part_v[i];
40 if( part_v._pdg_list.find(mini_part._pdgcode) == part_v._pdg_list.end() )
continue;
44 std::vector<double>
dEdx;
45 std::vector<std::vector<double> > dQdx;
48 mini_track.
Origin ( mini_part._origin );
49 mini_track.
PdgCode ( mini_part._pdgcode );
50 mini_track.
TrackID ( mini_part._track_id );
51 mini_track.
Process ( mini_part._process );
52 mini_track.
Start ( MCStep( mini_part._start_vtx, mini_part._start_mom ) );
53 mini_track.
End ( MCStep( mini_part._end_vtx, mini_part._end_mom ) );
55 unsigned int mother_track = part_v.MotherTrackID(i);
56 unsigned int ancestor_track = part_v.AncestorTrackID(i);
60 throw cet::exception(__FUNCTION__) <<
"LOGIC ERROR: mother/ancestor track ID is invalid!";
62 MCMiniPart mother_part;
63 MCMiniPart ancestor_part;
65 unsigned int mother_index = part_v.TrackToParticleIndex(mother_track);
66 unsigned int ancestor_index = part_v.TrackToParticleIndex(ancestor_track);
68 if(mother_index !=
kINVALID_UINT) mother_part = part_v[mother_index];
69 else mother_part._track_id = mother_track;
71 if(ancestor_index !=
kINVALID_UINT) ancestor_part = part_v[ancestor_index];
72 else ancestor_part._track_id = ancestor_track;
77 mini_track.
MotherStart ( MCStep( mother_part._start_vtx, mother_part._start_mom ) );
78 mini_track.
MotherEnd ( MCStep( mother_part._end_vtx, mother_part._end_mom ) );
83 mini_track.
AncestorStart ( MCStep( ancestor_part._start_vtx, ancestor_part._start_mom ) );
84 mini_track.
AncestorEnd ( MCStep( ancestor_part._end_vtx, ancestor_part._end_mom ) );
89 for(
auto const& vtx_mom : mini_part._det_path){
90 mini_track.push_back(MCStep(vtx_mom.first,vtx_mom.second));
96 if(mini_track.size() == 0){
97 mctracks.push_back(mini_track);
101 auto const& edep_index = edep_v.TrackToEdepIndex(mini_part._track_id);
102 if(edep_index < 0 )
continue;
103 auto const& edeps = edep_v.GetEdepArrayAt(edep_index);
107 for(
auto const& step_trk : mini_track){
109 if(
int(&step_trk - &mini_track[0])+1 ==
int(mini_track.size()) ){
113 auto const& nxt_step_trk = mini_track.at(
int(&step_trk - &mini_track[0])+1);
118 double dist = sqrt(pow(step_trk.X() - nxt_step_trk.X(),2) +
119 pow(step_trk.Y() - nxt_step_trk.Y(),2) +
120 pow(step_trk.Z() - nxt_step_trk.Z(),2));
131 double a = 0, b = 0, c = 0, d = 0;
132 a = nxt_step_trk.X() - step_trk.X();
133 b = nxt_step_trk.Y() - step_trk.Y();
134 c = nxt_step_trk.Z() - step_trk.Z();
135 d = -1*(a*step_trk.X() + b*step_trk.Y() + c*step_trk.Z());
149 TVector3 B(nxt_step_trk.Position().X() - step_trk.Position().X(),
150 nxt_step_trk.Position().Y() - step_trk.Position().Y(),
151 nxt_step_trk.Position().Z() - step_trk.Position().Z());
155 double step_dedx = 0;
156 std::vector<double> step_dqdx;
160 for(
auto const& edep : edeps){
162 TVector3 x_0(edep.pos._x, edep.pos._y, edep.pos._z);
164 TVector3
A(step_trk.Position().X() - x_0.X(),
165 step_trk.Position().Y() - x_0.Y(),
166 step_trk.Position().Z() - x_0.Z());
172 LineDist = sqrt(
A.Mag2() - 2*pow(
A*B,2)/B.Mag2() + pow(
A*B,2)/B.Mag2());
180 if( (a*edep.pos._x + b*edep.pos._y + c*edep.pos._z + d)/sqrt( pow(a,2) + pow(b,2) + pow(c,2)) <= dist + 0.03 &&
181 (a*edep.pos._x + b*edep.pos._y + c*edep.pos._z + d)/sqrt( pow(a,2) + pow(b,2) + pow(c,2)) >= 0 - 0.03 &&
188 for(
auto const& pid_energy : edep.deps){
189 engy += pid_energy.energy;
198 auto const pid = edep.pid;
199 auto q_i = pindex.find(pid);
200 if(q_i != pindex.end())
201 step_dqdx[pid.Plane] += (
double)(edep.deps[pindex[pid]].charge);
210 step_dqdx[0] /=
dist;
211 step_dqdx[1] /=
dist;
212 step_dqdx[2] /=
dist;
222 dEdx.push_back(step_dedx);
223 dQdx[0].push_back(step_dqdx[0]);
224 dQdx[1].push_back(step_dqdx[1]);
225 dQdx[2].push_back(step_dqdx[2]);
232 mini_track.dEdx(dEdx);
233 mini_track.dQdx(dQdx);
236 mctracks.push_back(mini_track);
244 for(
auto const&
prof : mctracks) {
248 << Form(
" Track particle: PDG=%d : Track ID=%d Start @ (%g,%g,%g,%g) with Momentum (%g,%g,%g,%g)",
253 << Form(
" Mother particle: PDG=%d : Track ID=%d Start @ (%g,%g,%g,%g) with Momentum (%g,%g,%g,%g)",
254 prof.MotherPdgCode(),
prof.MotherTrackID(),
255 prof.MotherStart().X(),
prof.MotherStart().Y(),
prof.MotherStart().Z(),
prof.MotherStart().T(),
256 prof.MotherStart().Px(),
prof.MotherStart().Py(),
prof.MotherStart().Pz(),
prof.MotherStart().E())
258 << Form(
" Ancestor particle: PDG=%d : Track ID=%d Start @ (%g,%g,%g,%g) with Momentum (%g,%g,%g,%g)",
259 prof.AncestorPdgCode(),
prof.AncestorTrackID(),
260 prof.AncestorStart().X(),
prof.AncestorStart().Y(),
prof.AncestorStart().Z(),
prof.AncestorStart().T(),
261 prof.AncestorStart().Px(),
prof.AncestorStart().Py(),
prof.AncestorStart().Pz(),
prof.AncestorStart().E())
263 << Form(
" ... with %zu trajectory points!",
prof.size())
268 << Form(
" Start @ (%g,%g,%g,%g) with Momentum (%g,%g,%g,%g)",
272 << Form(
" End @ (%g,%g,%g,%g) with Momentum (%g,%g,%g,%g)",
273 (*
prof.rbegin()).
X(), (*
prof.rbegin()).Y(), (*
prof.rbegin()).Z(), (*
prof.rbegin()).T(),
274 (*
prof.rbegin()).Px(), (*
prof.rbegin()).Py(), (*
prof.rbegin()).Pz(), (*
prof.rbegin()).
E())
simb::Origin_t Origin() const
const std::string & AncestorProcess() const
const MCStep & MotherEnd() const
unsigned int AncestorTrackID() const
std::map< geo::PlaneID, size_t > createPlaneIndexMap()
then echo echo For and will not be changed by echo further linking echo echo B echo The symbol is in the uninitialized data multiple common symbols may appear with the echo same name If the symbol is defined the common echo symbols are treated as undefined references For more echo details on common see the discussion of warn common echo in *Note Linker see the discussion of warn common echo in *Note Linker such as a global int variable echo as opposed to a large global array echo echo I echo The symbol is an indirect reference to another symbol This echo is a GNU extension to the a out object file format which is echo rarely used echo echo N echo The symbol is a debugging symbol echo echo R echo The symbol is in a read only data section echo echo S echo The symbol is in an uninitialized data section for small echo objects echo echo T echo The symbol is in the the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo W echo The symbol is a weak symbol that has not been specifically echo tagged as a weak object symbol When a weak defined symbol echo is linked with a normal defined the normal defined echo symbol is used with no error When a weak undefined symbol echo is linked and the symbol is not the value of the echo weak symbol becomes zero with no error echo echo echo The symbol is a stabs symbol in an a out object file In echo this the next values printed are the stabs other echo the stabs desc and the stab type Stabs symbols are echo used to hold debugging information For more echo see *Note or object file format specific echo echo For Mac OS X
int AncestorPdgCode() const
const MCStep & End() const
unsigned int MotherTrackID() const
const MCStep & AncestorStart() const
float dEdx(detinfo::DetectorClocksData const &clockData, detinfo::DetectorPropertiesData const &detProp, const TCSlice &slc, TP3D &tp3d)
const MCStep & MotherStart() const
int MotherPdgCode() const
constexpr double dist(const TReal *x, const TReal *y, const unsigned int dimension)
const std::string & Process() const
const std::string & MotherProcess() const
const unsigned int kINVALID_UINT
const MCStep & Start() const
unsigned int TrackID() const
const MCStep & AncestorEnd() const
BEGIN_PROLOG could also be cout