10#include "FairPrimaryGenerator.h"
13#include "TGeoCompositeShape.h"
15#include "TGeoManager.h"
17#include "TGeoVolume.h"
36 LOGF(info,
"Opening input file %s", fileName);
43 LOG(fatal) <<
"Error opening input file";
51 fTree->SetBranchAddress(
"DISParticles", &
dPart);
52 fTree->SetBranchAddress(
"SoftParticles",
54 LOG(info) <<
"MuDISGenerator: Initialization successful.";
67 LOG(warning) <<
"End of input file. Rewind.";
72 LOG(info) <<
"Info MuDISGenerator: MuDIS event-nr " <<
fn;
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;
81 Double_t start[3] = {0., 0.,
startZ};
82 Double_t end[3] = {0., 0.,
endZ};
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.;
92 Double_t cross_sec = (*mu)[10];
93 Double_t t_muon = (*mu)[11];
94 Double_t DIS_multiplicity = 1 / (*mu)[12];
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]
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] <<
", "
112 LOG(
debug) <<
"MuDIS: end position " << end[0] <<
", " << end[1] <<
", "
119 Double_t prob2int = 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;
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;
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();
142 prob2int = mat->GetDensity() / mparam[7];
144 LOG(warning) <<
"MuDISGenerator: prob2int > Maximum density????";
145 LOG(warning) <<
"prob2int: " << prob2int;
146 LOG(warning) <<
"maxrho: " << mparam[7];
147 LOG(warning) <<
"material: " << mat->GetName();
152 LOG(
debug) <<
"Info MuDISGenerator: prob2int " << prob2int <<
", " << count;
153 LOG(
debug) <<
"MuDIS: put position " << xmu <<
", " << ymu <<
", " << zmu;
156 TMath::Sqrt(TMath::Power((*mu)[1], 2) + TMath::Power((*mu)[2], 2) +
157 TMath::Power((*mu)[3], 2));
160 TMath::Sqrt(TMath::Power(x - xmu, 2) + TMath::Power(y - ymu, 2) +
161 TMath::Power(z - zmu, 2));
165 TMath::Sqrt(TMath::Power(total_mom, 2) + TMath::Power(
muon_mass, 2));
166 Double_t t_rmu = distance / v;
174 (t_muon + t_rmu) / 1e9;
176 cpg->AddTrack(
static_cast<int>((*mu)[0]),
177 (*mu)[1], (*mu)[2], (*mu)[3], xmu, ymu, zmu, -1,
182 w * DIS_multiplicity);
188 w = mparam[0] * mparam[4];
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 <<
""
198 LOG(
debug) <<
"muon DIS Generator out part w " << w;
201 cpg->AddTrack(
static_cast<int>((*Part)[0]), (*Part)[1], (*Part)[2],
202 (*Part)[3], xmu, ymu, zmu, 0,
true, (*Part)[4], t_DIS,
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);
213 TVectorD* SoftPart =
dynamic_cast<TVectorD*
>(softParticle);
214 if ((*SoftPart)[7] > zmu) {
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],
~MuDISGenerator() override
Bool_t Init(const char *, int) override
Bool_t ReadEvent(FairPrimaryGenerator *) override
TFile * fInputFile
don't make it persistent, magic ROOT command
double MeanMaterialBudget(std::span< const double, 3 > start, std::span< const double, 3 > end, std::span< double, 10 > mparam)