67 B2FATAL(
"Missing mcparticles list for MC");
74 const size_t nPart = particleList->getListSize();
75 for (
size_t iPart = 0; iPart < nPart; iPart++) {
76 auto particle = particleList->getParticle(iPart);
83 std::vector< std::pair<MCParticle*, bool> > primaryMCParticles;
84 for (
int i = 0; i < mcparticles.
getEntries(); i++) {
85 auto mcPart = mcparticles[i];
86 if (mcPart->isPrimaryParticle() && abs(mcPart->getPDG()) ==
m_mcPDG) {
87 bool AddInefficiency = (gRandom->Uniform() >
m_effcorr);
88 primaryMCParticles.push_back(std::pair(mcPart, AddInefficiency));
92 const size_t nMCPart = primaryMCParticles.size();
102 const size_t nPart = particleList->getListSize();
103 for (
size_t iPart = 0; iPart < nPart; iPart++) {
105 auto particle = particleList->getParticle(iPart);
106 auto bestMatch = Variable::particleClusterBestMCPDGCode(particle);
112 const ECLCluster* eclcluster = particle->getECLCluster();
113 if (!eclcluster)
continue;
116 std::vector< std::pair <double, bool> > distances;
117 distances.resize(nMCPart);
120 for (
size_t iMCPart = 0; iMCPart < nMCPart; iMCPart++) {
122 auto mcPart = primaryMCParticles[iMCPart].first;
124 auto vtx = mcPart->getProductionVertex();
125 auto momentum = mcPart->getMomentum();
128 double R = eclcluster->
getR();
129 double phi = eclcluster->
getPhi();
130 double theta = eclcluster->
getTheta();
131 double zcl =
R /
tan(theta);
132 double xcl =
R * cos(phi);
133 double ycl =
R * sin(phi);
136 double z = vtx.Z() + rECL /
tan(momentum.Theta());
137 double x = vtx.X() + rECL * cos(momentum.Phi());
138 double y = vtx.Y() + rECL * sin(momentum.Phi());
140 double dist =
sqrt((x - xcl) * (x - xcl) + (y - ycl) * (y - ycl) + (z - zcl) * (z - zcl));
141 distances[iMCPart] = std::pair(dist, primaryMCParticles[iMCPart].second);
144 auto it_distMin = std::min_element(distances.begin(), distances.end(),
145 [](
const auto & a,
const auto & b) { return a.first < b.first;});
146 double distMin = (*it_distMin).first;
147 bool AddInefficiency = (*it_distMin).second;
148 if ((distMin <
m_distance) && AddInefficiency)
154 particle->setExtraInfo(
m_matchedId, primaryMCParticles[std::distance(distances.begin(), it_distMin)].first->getArrayIndex());