65 {
67 LOG(warning) << "End of input file. Rewind.";
68 }
72 LOG(info) <<
"Info MuDISGenerator: MuDIS event-nr " <<
fn;
73 }
74
75 int nf =
dPart->GetEntries();
76 LOG(
debug) <<
"*********************************************************";
77 LOG(
debug) <<
"muon DIS Generator debug " <<
iMuon->GetEntries() <<
" "
78 <<
iMuon->AddrAt(0) <<
" nf " << nf <<
" fn=" <<
fn;
79
80
81 Double_t start[3] = {0., 0.,
startZ};
82 Double_t end[3] = {0., 0.,
endZ};
83
84
85 TVectorD*
mu =
dynamic_cast<TVectorD*
>(
iMuon->AddrAt(0));
86 LOG(
debug) <<
"muon DIS Generator in muon " <<
int((*mu)[0]);
87 Double_t
x = (*mu)[5] * 100.;
88 Double_t
y = (*mu)[6] * 100.;
89 Double_t
z = (*mu)[7] * 100.;
91 (*mu)[8];
92 Double_t cross_sec = (*mu)[10];
93 Double_t t_muon = (*mu)[11];
94 Double_t DIS_multiplicity = 1 / (*mu)[12];
95
96
97
98
99 Double_t txmu = (*mu)[1] / (*mu)[3];
100 Double_t tymu = (*mu)[2] / (*mu)[3];
101 start[0] =
x - (
z - start[2]) * txmu;
102 start[1] =
y - (
z - start[2]) * tymu;
103 end[0] =
x - (
z - end[2]) * txmu;
104 end[1] =
y - (
z - end[2]) * tymu;
105 LOG(
debug) <<
"MuDIS: mu xyz position " <<
x <<
", " <<
y <<
", " <<
z;
106 LOG(
debug) <<
"MuDIS: mu pxyz position " << (*mu)[1] <<
", " << (*mu)[2]
107 << ", " << (*mu)[3];
108 LOG(
debug) <<
"MuDIS: mu weight*DISmultiplicity " <<
w;
109 LOG(
debug) <<
"MuDIS: mu DIS cross section " << cross_sec;
110 LOG(
debug) <<
"MuDIS: start position " << start[0] <<
", " << start[1] <<
", "
111 << start[2];
112 LOG(
debug) <<
"MuDIS: end position " << end[0] <<
", " << end[1] <<
", "
113 << end[2];
114
115 Double_t bparam;
116 Double_t mparam[10];
118
119 Double_t prob2int = 0.;
120 Double_t xmu = 0.;
121 Double_t ymu = 0.;
122 Double_t zmu = 0.;
123 Int_t count = 0;
124 LOG(
debug) <<
"Info MuDISGenerator Start prob2int while loop, bparam= "
125 << bparam << ", " << bparam * 1.e8;
126 LOG(
debug) <<
"Info MuDISGenerator What was maximum density, mparam[7]= "
127 << mparam[7] << ", " << mparam[7] * 1.e8;
128
129 while (prob2int < gRandom->Uniform(0., 1.)) {
130 zmu = gRandom->Uniform(start[2], end[2]);
131 xmu =
x - (
z - zmu) * txmu;
132 ymu =
y - (
z - zmu) * tymu;
133
134 TGeoNode* node = gGeoManager->FindNode(xmu, ymu, zmu);
135 TGeoMaterial* mat = nullptr;
136 if (node && !gGeoManager->IsOutside())
137 mat = node->GetVolume()->GetMaterial();
138 LOG(
debug) <<
"Info MuDISGenerator: mat " << count <<
", " << mat->GetName()
139 << ", " << mat->GetDensity();
140
141
142 prob2int = mat->GetDensity() / mparam[7];
143 if (prob2int > 1.) {
144 LOG(warning) << "MuDISGenerator: prob2int > Maximum density????";
145 LOG(warning) << "prob2int: " << prob2int;
146 LOG(warning) << "maxrho: " << mparam[7];
147 LOG(warning) << "material: " << mat->GetName();
148 }
149 count += 1;
150 }
151
152 LOG(
debug) <<
"Info MuDISGenerator: prob2int " << prob2int <<
", " << count;
153 LOG(
debug) <<
"MuDIS: put position " << xmu <<
", " << ymu <<
", " << zmu;
154
155 Double_t total_mom =
156 TMath::Sqrt(TMath::Power((*mu)[1], 2) + TMath::Power((*mu)[2], 2) +
157 TMath::Power((*mu)[3], 2));
158
159 Double_t distance =
160 TMath::Sqrt(TMath::Power(x - xmu, 2) + TMath::Power(y - ymu, 2) +
161 TMath::Power(z - zmu, 2));
162
165 TMath::Sqrt(TMath::Power(total_mom, 2) + TMath::Power(
muon_mass, 2));
166 Double_t t_rmu = distance /
v;
167
168
169 if (zmu < z) {
170 t_rmu = -t_rmu;
171 }
172
173 Double_t t_DIS =
174 (t_muon + t_rmu) / 1e9;
175
176 cpg->AddTrack(static_cast<int>((*mu)[0]),
177 (*mu)[1], (*mu)[2], (*mu)[3], xmu, ymu, zmu, -1,
178 false,
179 (*mu)[4],
180 t_DIS,
181
182 w * DIS_multiplicity);
183
184
185
186
187
188 w = mparam[0] * mparam[4];
189
191 for (
auto&& particle : *
dPart) {
192 TVectorD* Part = dynamic_cast<TVectorD*>(particle);
193 LOG(
debug) <<
"muon DIS Generator out part " <<
int((*Part)[0]);
194 LOG(
debug) <<
"muon DIS Generator out part mom " << (*Part)[1] <<
" "
195 << (*Part)[2] << " " << (*Part)[3] << " " << (*Part)[4];
196 LOG(
debug) <<
"muon DIS Generator out part pos " << xmu <<
" " << ymu <<
""
197 << zmu;
198 LOG(
debug) <<
"muon DIS Generator out part w " <<
w;
199
200 if (index == 0) {
201 cpg->AddTrack(static_cast<int>((*Part)[0]), (*Part)[1], (*Part)[2],
202 (*Part)[3], xmu, ymu, zmu, 0, true, (*Part)[4], t_DIS,
203 cross_sec);
204 } else {
205 cpg->AddTrack(static_cast<int>((*Part)[0]), (*Part)[1], (*Part)[2],
206 (*Part)[3], xmu, ymu, zmu, 0, true, (*Part)[4], t_DIS, w);
207 }
209 }
210
211
213 TVectorD* SoftPart = dynamic_cast<TVectorD*>(softParticle);
214 if ((*SoftPart)[7] > zmu) {
215 continue;
216 }
217 Double_t t_soft = (*SoftPart)[8] / 1e9;
218 cpg->AddTrack(static_cast<int>((*SoftPart)[0]), (*SoftPart)[1],
219 (*SoftPart)[2], (*SoftPart)[3], (*SoftPart)[5],
220 (*SoftPart)[6], (*SoftPart)[7], 0, true, (*SoftPart)[4],
222 }
223
224 return kTRUE;
225}
double MeanMaterialBudget(std::span< const double, 3 > start, std::span< const double, 3 > end, std::span< double, 10 > mparam)