99 {
101 LOG(warning) << "End of input file. Rewind.";
102 }
106 LOG(info) <<
"Info MuDISGenerator: MuDIS event-nr " <<
fn;
107 }
108
109 int nf =
dPart->GetEntries();
110 LOG(
debug) <<
"*********************************************************";
111 LOG(
debug) <<
"muon DIS Generator debug " <<
iMuon->GetEntries() <<
" "
112 <<
iMuon->AddrAt(0) <<
" nf " << nf <<
" fn=" <<
fn;
113
114
115 Double_t start[3] = {0., 0.,
startZ};
116 Double_t end[3] = {0., 0.,
endZ};
117
118
119
120
121 TVectorD*
mu =
dynamic_cast<TVectorD*
>(
iMuon->AddrAt(0));
122 LOG(
debug) <<
"muon DIS Generator in muon " <<
int((*mu)[0]);
123 Double_t
x = (*mu)[5] * 100.;
124 Double_t
y = (*mu)[6] * 100.;
125 Double_t
z = (*mu)[7] * 100.;
127 (*mu)[8];
128 Double_t cross_sec = (*mu)[10];
129 Double_t t_muon = (*mu)[11];
130 Double_t DIS_multiplicity = 1 / (*mu)[12];
131
132
133
134
135 Double_t txmu = (*mu)[1] / (*mu)[3];
136 Double_t tymu = (*mu)[2] / (*mu)[3];
137 start[0] =
x - (
z - start[2]) * txmu;
138 start[1] =
y - (
z - start[2]) * tymu;
139 end[0] =
x - (
z - end[2]) * txmu;
140 end[1] =
y - (
z - end[2]) * tymu;
141 LOG(
debug) <<
"MuDIS: mu xyz position " <<
x <<
", " <<
y <<
", " <<
z;
142 LOG(
debug) <<
"MuDIS: mu pxyz position " << (*mu)[1] <<
", " << (*mu)[2]
143 << ", " << (*mu)[3];
144 LOG(
debug) <<
"MuDIS: mu weight*DISmultiplicity " <<
w;
145 LOG(
debug) <<
"MuDIS: mu DIS cross section " << cross_sec;
146 LOG(
debug) <<
"MuDIS: start position " << start[0] <<
", " << start[1] <<
", "
147 << start[2];
148 LOG(
debug) <<
"MuDIS: end position " << end[0] <<
", " << end[1] <<
", "
149 << end[2];
150
151 Double_t bparam;
152 Double_t mparam[10];
154
155 Double_t prob2int = 0.;
156 Double_t xmu = 0.;
157 Double_t ymu = 0.;
158 Double_t zmu = 0.;
159 Int_t count = 0;
160 LOG(
debug) <<
"Info MuDISGenerator Start prob2int while loop, bparam= "
161 << bparam << ", " << bparam * 1.e8;
162 LOG(
debug) <<
"Info MuDISGenerator What was maximum density, mparam[7]= "
163 << mparam[7] << ", " << mparam[7] * 1.e8;
164
165 while (prob2int < gRandom->Uniform(0., 1.)) {
167 zmu = gRandom->Uniform(start[2], end[2]);
168 xmu =
x - (
z - zmu) * txmu;
169 ymu =
y - (
z - zmu) * tymu;
170
171 TGeoNode* node = gGeoManager->FindNode(xmu, ymu, zmu);
172 TGeoMaterial* mat = nullptr;
173 if (node && !gGeoManager->IsOutside()) {
174 mat = node->GetVolume()->GetMaterial();
175 LOG(
debug) <<
"Info MuDISGenerator: mat " << count <<
", "
176 << mat->GetName() << ", " << mat->GetDensity();
177
178
179 prob2int = mat->GetDensity() / mparam[7];
180 if (prob2int > 1.) {
181 LOG(warning) << "MuDISGenerator: prob2int > Maximum density????";
182 LOG(warning) << "prob2int: " << prob2int;
183 LOG(warning) << "maxrho: " << mparam[7];
184 LOG(warning) << "material: " << mat->GetName();
185 }
186 } else {
187
188 prob2int = 0.;
189 }
190 count += 1;
191 }
192
193 LOG(
debug) <<
"Info MuDISGenerator: prob2int " << prob2int <<
", " << count;
194 LOG(
debug) <<
"MuDIS: put position " << xmu <<
", " << ymu <<
", " << zmu;
195
196 Double_t total_mom =
197 TMath::Sqrt(TMath::Power((*mu)[1], 2) + TMath::Power((*mu)[2], 2) +
198 TMath::Power((*mu)[3], 2));
199
200 Double_t distance =
201 TMath::Sqrt(TMath::Power(x - xmu, 2) + TMath::Power(y - ymu, 2) +
202 TMath::Power(z - zmu, 2));
203
204 static const Double_t muon_mass =
205 TDatabasePDG::Instance()->GetParticle(13)->Mass();
208 TMath::Sqrt(TMath::Power(total_mom, 2) + TMath::Power(muon_mass, 2));
209 Double_t t_rmu = distance /
v;
210
211
212 if (zmu < z) {
213 t_rmu = -t_rmu;
214 }
215
216 Double_t t_DIS = (t_muon + t_rmu) /
218
219 cpg->AddTrack(static_cast<int>((*mu)[0]),
220 (*mu)[1], (*mu)[2], (*mu)[3], xmu, ymu, zmu, -1,
221 false,
222 (*mu)[4],
223 t_DIS,
224
225 w * DIS_multiplicity);
226
227
228
229
230
231 w = mparam[0] * mparam[4];
232
234 for (
auto&& particle : *
dPart) {
235 TVectorD* Part = dynamic_cast<TVectorD*>(particle);
236 LOG(
debug) <<
"muon DIS Generator out part " <<
int((*Part)[0]);
237 LOG(
debug) <<
"muon DIS Generator out part mom " << (*Part)[1] <<
" "
238 << (*Part)[2] << " " << (*Part)[3] << " " << (*Part)[4];
239 LOG(
debug) <<
"muon DIS Generator out part pos " << xmu <<
" " << ymu <<
""
240 << zmu;
241 LOG(
debug) <<
"muon DIS Generator out part w " <<
w;
242
243 if (index == 0) {
244 cpg->AddTrack(static_cast<int>((*Part)[0]), (*Part)[1], (*Part)[2],
245 (*Part)[3], xmu, ymu, zmu, 0, true, (*Part)[4], t_DIS,
246 cross_sec);
247 } else {
248 cpg->AddTrack(static_cast<int>((*Part)[0]), (*Part)[1], (*Part)[2],
249 (*Part)[3], xmu, ymu, zmu, 0, true, (*Part)[4], t_DIS, w);
250 }
253 }
254
255
257 TVectorD* SoftPart = dynamic_cast<TVectorD*>(softParticle);
258 if ((*SoftPart)[7] > zmu) {
260 continue;
261 }
263 cpg->AddTrack(static_cast<int>((*SoftPart)[0]), (*SoftPart)[1],
264 (*SoftPart)[2], (*SoftPart)[3], (*SoftPart)[5],
265 (*SoftPart)[6], (*SoftPart)[7], 0, true, (*SoftPart)[4],
266 t_soft, w);
268 }
269
271
272 return kTRUE;
273}
void IncrementCounter(const std::string &name, Long64_t delta=1)
double MeanMaterialBudget(std::span< const double, 3 > start, std::span< const double, 3 > end, std::span< double, 10 > mparam)