File indexing completed on 2024-06-26 07:05:37
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include "eicsmear/smear/Tracker.h"
0011
0012 #include <algorithm>
0013 #include <cmath>
0014 #include <limits>
0015 #include <list>
0016
0017 #include <TMath.h>
0018
0019 namespace {
0020
0021
0022 struct NoIntersection {
0023 bool operator()(const TVector3& v) const {
0024 return TMath::IsNaN(v.z());
0025 }
0026 };
0027
0028 }
0029
0030 namespace Smear {
0031
0032 Tracker::Tracker(double magneticField, double nRadiationLengths,
0033 double resolution)
0034 : mFactor(720)
0035 , mMagField(magneticField)
0036 , mNRadLengths(nRadiationLengths)
0037 , mSigmaRPhi(resolution) {
0038 }
0039
0040 Tracker::~Tracker() {
0041 }
0042
0043 double Tracker::MultipleScatteringContribution(
0044 const erhic::VirtualParticle& p) const {
0045
0046
0047 double val = 0.016 / 0.3 * p.GetP() * sqrt(mNRadLengths) / LPrime(p) /
0048 p.Get4Vector().Beta() / mMagField;
0049 if (TMath::IsNaN(val)) {
0050 std::cerr << "MS nan!" << std::endl;
0051 }
0052 return val;
0053 }
0054
0055 double Tracker::IntrinsicContribution(
0056 const erhic::VirtualParticle& p) const {
0057
0058
0059
0060
0061
0062
0063 double val = sqrt(mFactor * pow(NPoints(p), 3.)) / 0.3 * pow(p.GetP(), 2.)
0064 * mSigmaRPhi / mMagField / pow(LPrime(p), 2.)
0065 / sqrt((NPoints(p)-1)*(NPoints(p)+1)*(NPoints(p)+2)*(NPoints(p)+3));
0066 if (TMath::IsNaN(val)) {
0067 std::cerr << "Intrinsic nan!" << std::endl;
0068 }
0069 return val;
0070 }
0071
0072 double Tracker::Resolution(const erhic::VirtualParticle& p) const {
0073
0074
0075 if (!Accepts(p)) {
0076 return 0.;
0077 }
0078 return sqrt(pow(MultipleScatteringContribution(p), 2.) +
0079 pow(IntrinsicContribution(p), 2.));
0080 }
0081
0082 void Tracker::Smear(const erhic::VirtualParticle& pIn,
0083 ParticleMCS& pOut) {
0084 if (Accepts(pIn) && Accept.Is(pIn)) {
0085 double y = GetVariable(pIn, kP);
0086
0087
0088 pOut.SetVariable(Distribution.Generate(y, Resolution(pIn)), kP);
0089
0090 pOut.HandleBogusValues(kP);
0091 if (pOut.GetP() < 0.) {
0092 std::cerr << "p " << pOut.GetP() << std::endl;
0093 }
0094 if (TMath::IsNaN(pOut.GetP())) {
0095 std::cerr << "p nan" << std::endl;
0096 }
0097 }
0098 }
0099
0100 void Tracker::SetVertexConstraint(bool constrain) {
0101 if (constrain) {
0102 mFactor = 320;
0103 } else {
0104 mFactor = 720;
0105 }
0106 }
0107
0108 }