22 fTree->Branch(
"mct_run",&
fRun,
"mct_run/i");
64 const std::vector<sim::MCTrack>& mctVec)
69 fNMCTracks = mctVec.size();
70 fCollectionEnergy = 0;
85 std::vector<double> y_vals;
86 std::vector<double> z_vals;
87 std::vector<double> x_vals;
88 std::vector<double> stepL_vals;
90 std::vector<double> mct_length(mctVec.size(),0);
92 for(
size_t i_p=0; i_p<mctVec.size(); i_p++){
95 fCollectionEnergy += mctVec[i_p].Start().E();
101 for(
size_t i_s=1; i_s < mctVec[i_p].size(); i_s++){
103 TVector3
const& vec1 = mctVec[i_p][i_s-1].Position().Vect();
104 TVector3
const& vec2 = mctVec[i_p][i_s].Position().Vect();
105 double stepL = (vec2-vec1).Mag();
107 double thisy = 0.5*(vec1.Y() + vec2.Y());
108 double thisz = 0.5*(vec1.Z() + vec2.Z());
109 double thisx = 0.5*(vec1.X() + vec2.X());
111 y_vals.push_back(thisy);
112 z_vals.push_back(thisz);
113 x_vals.push_back(thisx);
114 stepL_vals.push_back(stepL);
116 mct_length[i_p] += stepL;
118 if(thisy > fMaxY) fMaxY = thisy;
119 if(thisy < fMinY) fMinY = thisy;
120 if(thisz > fMaxZ) fMaxZ = thisz;
121 if(thisz < fMinZ) fMinZ = thisz;
122 if(thisx > fMaxX) fMaxX = thisx;
123 if(thisx < fMinX) fMinX = thisx;
128 double totalL = std::accumulate(mct_length.begin(),mct_length.end(),0.0);
130 fDParticle =
std::distance(mct_length.begin(),std::max_element(mct_length.begin(),mct_length.end()));
131 fDParticleFraction = mct_length.at(fDParticle) / totalL;
132 FillDominantParticleInfo(mctVec.at(fDParticle));
134 double sumy=0,sumz=0,sumx=0;
135 for(
size_t i_step=0; i_step<stepL_vals.size(); i_step++){
136 sumy += stepL_vals[i_step]*y_vals[i_step];
137 sumz += stepL_vals[i_step]*z_vals[i_step];
138 sumx += stepL_vals[i_step]*x_vals[i_step];
141 fCollectionY = sumy/totalL;
142 fCollectionZ = sumz/totalL;
143 fCollectionX = sumx/totalL;
145 double sumy2=0,sumz2=0,sumx2=0;
146 for(
size_t i_step=0; i_step<stepL_vals.size(); i_step++){
147 sumy2 += stepL_vals[i_step]*(y_vals[i_step]-fCollectionY)*(y_vals[i_step]-fCollectionY);
148 sumz2 += stepL_vals[i_step]*(z_vals[i_step]-fCollectionZ)*(z_vals[i_step]-fCollectionZ);
149 sumx2 += stepL_vals[i_step]*(x_vals[i_step]-fCollectionX)*(x_vals[i_step]-fCollectionX);
152 fCollectionRMSY = std::sqrt(sumy2/totalL);
153 fCollectionRMSZ = std::sqrt(sumz2/totalL);
154 fCollectionRMSX = std::sqrt(sumx2/totalL);
156 if(fFillTree) fTree->Fill();
161 size_t nsteps = mctrack.size();
163 fDParticleOrigin = mctrack.
Origin();
164 fDParticlePdgCode = mctrack.
PdgCode();
165 fDParticleTrackId = mctrack.
TrackID();
166 fDParticleStartY = mctrack[0].Y();
167 fDParticleStartZ = mctrack[0].Z();
168 fDParticleStartX = mctrack[0].X();
169 fDParticleStartE = mctrack[0].E();
170 fDParticleEndY = mctrack[nsteps-1].Y();
171 fDParticleEndZ = mctrack[nsteps-1].Z();
172 fDParticleEndX = mctrack[nsteps-1].X();
173 fDParticleEndE = mctrack[nsteps-1].E();
simb::Origin_t Origin() const
void SetOutputTree(TTree *, bool fill=true)
unsigned int AncestorTrackID() const
void FillTree(unsigned int, unsigned int, const std::vector< sim::MCTrack > &)
int AncestorPdgCode() const
unsigned int MotherTrackID() const
double distance(geo::Point_t const &point, CathodeDesc_t const &cathode)
Returns the distance of a point from the cathode.
void fill(const art::PtrVector< recob::Hit > &hits, int only_plane)
Class def header for mctrack data container.
unsigned int fDParticleAncestorTrackId
int MotherPdgCode() const
int fDParticleAncestorPdgCode
unsigned int fDParticleMotherTrackId
int fDParticleMotherPdgCode
unsigned int TrackID() const
unsigned int fDParticleTrackId
void FillDominantParticleInfo(const sim::MCTrack &)