Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 14 additions & 31 deletions TrackDigi/TPCDigi/src/TPCDigiProcessor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1343,12 +1343,9 @@ double TPCDigiProcessor::getPadPhi(CLHEP::Hep3Vector* thisPoint, CLHEP::Hep3Vect

double padPhi = fabs(pointPhi - localPhi);

// check that the value returned is reasonable
if (std::isnan(padPhi) || std::isinf(padPhi)) {
std::stringstream errorMsg;
errorMsg << "\nProcessor: TPCDigiProcessor \n"
<< "padPhi = " << padPhi << "\n";
throw Exception(errorMsg.str());
streamlog_out(WARNING) << "Failed to calculate theta. Setting the default value of pi/2." << std::endl;
return twopi / 4.0;
}

return padPhi;
Expand Down Expand Up @@ -1382,37 +1379,23 @@ double TPCDigiProcessor::getPadTheta(CLHEP::Hep3Vector* firstPoint, CLHEP::Hep3V
}

Circle theCircle(&firstPointRPhi, &middlePointRPhi, &lastPointRPhi);
double D = 2.0 * theCircle.GetRadius();

double deltaPhi = firstPoint->deltaPhi(*lastPoint);

double pathlength = fabs(deltaPhi) * theCircle.GetRadius();

double padTheta = atan(pathlength / fabs(lastPoint->z() - firstPoint->z()));
double dx12 = middlePointRPhi.x() - firstPointRPhi.x();
double dy12 = middlePointRPhi.y() - firstPointRPhi.y();
double dr12 = std::sqrt(dx12 * dx12 + dy12 * dy12);
double pathlength1 = dr12 / D < 1.0 ? D * std::asin(dr12 / D) : D * std::asin(1.0);

double pathlength1 =
2.0 *
asin((sqrt((middlePointRPhi.x() - firstPointRPhi.x()) * (middlePointRPhi.x() - firstPointRPhi.x()) +
(middlePointRPhi.y() - firstPointRPhi.y()) * (middlePointRPhi.y() - firstPointRPhi.y())) /
2.0) /
theCircle.GetRadius()) *
theCircle.GetRadius();
double dx23 = lastPointRPhi.x() - middlePointRPhi.x();
double dy23 = lastPointRPhi.y() - middlePointRPhi.y();
double dr23 = std::sqrt(dx23 * dx23 + dy23 * dy23);
double pathlength2 = dr23 / D < 1.0 ? D * std::asin(dr23 / D) : D * std::asin(1.0);

double pathlength2 =
2.0 *
asin((sqrt((lastPointRPhi.x() - middlePointRPhi.x()) * (lastPointRPhi.x() - middlePointRPhi.x()) +
(lastPointRPhi.y() - middlePointRPhi.y()) * (lastPointRPhi.y() - middlePointRPhi.y())) /
2.0) /
theCircle.GetRadius()) *
theCircle.GetRadius();
double padTheta = std::atan((std::fabs(pathlength1 + pathlength2)) / (std::fabs(lastPoint->z() - firstPoint->z())));

padTheta = atan((fabs(pathlength1 + pathlength2)) / (fabs(lastPoint->z() - firstPoint->z())));

// check that the value returned is reasonable
if (std::isnan(padTheta) || std::isinf(padTheta)) {
std::stringstream errorMsg;
errorMsg << "\nProcessor: TPCDigiProcessor \n"
<< "padTheta = " << padTheta << "\n";
throw Exception(errorMsg.str());
streamlog_out(WARNING) << "Failed to calculate theta. Setting the default value of pi/2." << std::endl;
return twopi / 4.0;
}

return padTheta;
Expand Down
Loading