1 #include "SecondaryInteractionSystematic.hxx" 2 #include "Parameters.hxx" 17 if (matName ==
"Air")
return kOxygen;
19 else if (matName ==
"Oxygen")
return kOxygen;
21 else if (matName ==
"CO2")
return kOxygen;
23 else if (matName ==
"Carbon")
return kCarbon;
25 else if (matName ==
"Aluminum")
return kAluminium;
27 else if (matName ==
"Aluminium")
return kAluminium;
29 else if (matName ==
"Steel")
return kIron;
31 else if (matName ==
"Iron")
return kIron;
33 else if (matName ==
"AlRoha" || matName ==
"AlRoha2")
return kAluminium;
35 else if (matName ==
"AlG10")
return kAlG10;
37 else if (matName ==
"WaterSystem")
return kWaterSystem;
39 else if (matName ==
"G10FGD1" || matName ==
"G10")
return kG10;
43 else if (matName.find(
"FGDScintillator") != std::string::npos)
return kCarbon;
45 else if (matName ==
"FGDGlue")
return kFGDGlue;
47 else if (matName ==
"G10Roha")
return kG10Roha;
53 else if (matName ==
"G10FGD2")
return kG10;
55 else if (matName ==
"ActiveWater")
return kOxygen;
57 else if (matName ==
"Polypropylene")
return kCarbon;
59 else if (matName ==
"FGDWaterModuleEpoxy")
return kFGDGlue;
67 else if (matName ==
"GasMixtureTPC")
return kAluminium;
121 TGeoVolume *volume = node->GetVolume();
122 TGeoMaterial *material = volume->GetMaterial();
123 TGeoMixture *mixture = (TGeoMixture*)material;
128 Int_t NElements = mixture->GetNelements();
131 Double_t* Zmixt = mixture->GetZmixt();
134 Double_t* Amixt = mixture->GetAmixt();
137 Double_t* Wmixt = mixture->GetWmixt();
140 for(Int_t i = 0; i < NElements; i++){
142 ZoverA += Wmixt[i]*(Zmixt[i]/Amixt[i]);
152 TGeoVolume *volume = node->GetVolume();
153 TGeoMaterial *material = volume->GetMaterial();
154 TGeoMixture *mixture = (TGeoMixture*)material;
156 Double_t ZoverA = GetZoverAMaterial(node);
161 Int_t NElements = mixture->GetNelements();
164 Double_t* Zmixt = mixture->GetZmixt();
167 Double_t* Amixt = mixture->GetAmixt();
170 Double_t* Wmixt = mixture->GetWmixt();
173 for(Int_t i = 0; i < NElements; i++){
175 lnI += (Wmixt[i]*(Zmixt[i]/Amixt[i])*log(GetIElement((Int_t)Zmixt[i])))/ZoverA;
188 TGeoVolume *volume = node->GetVolume();
189 TGeoMaterial *material = volume->GetMaterial();
192 Double_t betagamma = state.Momentum/state.Mass;
193 Double_t energy = sqrt(state.Momentum*state.Momentum + state.Mass*state.Mass);
194 Double_t beta = state.Momentum/energy;
195 Double_t gamma = betagamma/beta;
196 Double_t T_max = (2*units::mass_electron*pow(betagamma,2))/(1 + 2*gamma*(units::mass_electron/state.Mass) + pow(units::mass_electron/state.Mass,2));
199 Double_t I = GetIMaterial(node)*(1E-6);
202 Double_t rho = (1000.0/(6.2415e21))*(material->GetDensity());
206 return 0.1*rho*
K*1.*(ZoverA)*(1/pow(beta,2))*((1.0/2.0)*log(2*units::mass_electron*pow(betagamma,2)*T_max/pow(I,2)) - pow(beta,2));
218 TVector3 initDir = state.Dir;
220 Double_t p = state.Momentum;
221 Double_t betagamma = p / state.Mass;
222 Double_t beta = p /(initEkin + state.Mass);
223 Double_t gamma = betagamma / beta;
231 Double_t finalEkin = initEkin - dEdx*(0.1)*stepLength;
233 if (finalEkin <= 0 ){
234 state.Dir = TVector3(0., 0., 0.);
243 Double_t c = 299792458;
244 TVector3 initVelocity = beta*c*initDir;
248 TVector3 dpdt = 1.*(1.602176e-19)*initVelocity.Cross(
field);
252 Double_t dt = ((0.001*stepLength)/initVelocity.Mag());
253 TVector3 dp = dpdt*dt;
258 TVector3 pFinal = gamma*state.Mass*(1.782662e-30)*initVelocity + dp;
262 state.Dir = pFinal*(1/pFinal.Mag());
269 state.Pos += stepLength*initDir;
271 state.Momentum = sqrt(pow(finalEkin + state.Mass, 2) - pow(state.Mass, 2));
283 TGeoVolume *volume = node->GetVolume();
284 TGeoMaterial *material = volume->GetMaterial();
285 TGeoMixture *mixture = (TGeoMixture*)material;
290 Double_t* AArray = mixture->GetAmixt();
291 Double_t* WArray = mixture->GetWmixt();
292 Int_t NElts = mixture->GetNelements();
298 for(Int_t i = 0; i< NElts; i++)
300 result += (units::Avogadro/AArray[i])*WArray[i]*((1000.0/(6.2415e21))*mixture->GetDensity());
318 std::cout <<
" ======= " << std::endl;
319 std::cout <<
" si_syst::ParticleSIPropagator::Propagate: in det " << det << std::endl;
320 particle_in.trueTrack->Print();
327 std::cout <<
" no VOI" << std::endl;
337 std::cout <<
" no Interactions" << std::endl;
346 Double_t initPointSep = (finalPos - particle.
stateCurrent.Pos).Mag();
347 Double_t stepPointSep = 0.0;
353 std::cout <<
" ======= " << std::endl;
354 std::cout <<
" si_syst::ParticleSIPropagator::Propagate: " << std::endl;
356 std::cout <<
" finalPos: " << finalPos << std::endl;
357 std::cout <<
" initPointSep: " << initPointSep << std::endl;
365 std::vector<si_syst::SIXSecData> xSecAccum;
368 std::vector<si_syst::SIXSecData> xSecRefAccum;
373 while (stepPointSep < initPointSep){
376 TGeoNode *node = ND::hgman().GeoManager()->FindNode(particle.
stateCurrent.Pos.X(),
383 std::cout <<
" Start of step: " << std::endl;
385 std::cout <<
" momStartStep: " << momStartStep << std::endl;
392 stepPointSep = (particle.
stateCurrent.Pos - initPos).Mag();
395 std::cout <<
" End of step: " << std::endl;
397 std::cout <<
" stepPointSep: " << stepPointSep << std::endl;
407 TGeoVolume *volume = node->GetVolume();
408 TGeoMaterial *material = volume->GetMaterial();
409 std::string materialName = material->GetName();
410 TGeoMixture *mixture = (TGeoMixture*)material;
412 std::cout <<
" out of VOI/zero-mom, int: " << *iter << std::endl;
413 std::cout <<
" out of VOI/zero-mom, xsec: " << xsec << std::endl;
414 std::cout <<
" material: " << materialName << std::endl;
415 std::cout <<
" material Z: " << mixture->GetZ() << std::endl;
416 std::cout <<
" material A: " << mixture->GetA() << std::endl;
417 std::cout <<
" momStartStep : " << momStartStep << std::endl;
418 std::cout <<
" NDMat: " << NDMat << std::endl;
419 std::cout <<
" factor: " << factor << std::endl;
420 std::cout <<
" factor_ref: " << factor_ref << std::endl;
424 std::set<si_syst::InteractionType>::const_iterator iter =
_intTypes.begin();
426 for (; iter !=
_intTypes.end(); iter++, i++){
432 xSecAccum[i].XSec += xsec;
440 xSecRefAccum[i].XSec += xsecRef;
441 xSecRefAccum[i].XSecErr += 0.;
452 std::cout <<
" ======= " << std::endl;
465 std::cout <<
" ======= " << std::endl;
466 std::cout <<
" si_syst::ParticleSIManager::CollectParticleInteractions " << std::endl;
469 assert(GetPropagator());
473 GetPropagator()->SetDetector(det);
480 for (
int i = 0; i < result->nParticles; i++){
487 _propagator->GetCrossSection(
491 _propagator->GetCrossSectionError(
500 result->Particles[i].
Weight = 1.;
502 if (!GetPropagator()->GetComputeReWeightStatus())
516 Float_t survProb = 0.;
517 Float_t survProbReference = 0.;
520 size_t nSteps = result->Particles[i].
propSteps.size();
523 std::cout <<
" particle i: " << i <<
" nSteps " << nSteps << std::endl;
526 for (
size_t ns = 0; ns < nSteps; ns++){
528 size_t nInts = result->Particles[i].
propSteps[ns].size();
529 for (
size_t nint = 0; nint < nInts; nint++){
530 survProb += result->Particles[i].
propSteps[ns][nint].XSec;
535 result->Particles[i].
Weight *= exp( - (survProbReference - survProb));
537 if (result->Particles[i].
XSecData.XSec != 0)
542 std::cout <<
" particle i: " << i <<
" weight " << result->Particles[i].
Weight << std::endl;
543 std::cout <<
" particle i: " << i <<
" int type " << result->Particles[i].
intType << std::endl;
550 std::cout <<
" ======= " << std::endl;
564 std::cout <<
" ======= " << std::endl;
565 std::cout <<
" si_syst::ParticleSIManager::GetRelevantParticles " << std::endl;
568 assert(GetPropagator());
579 for (Int_t it = 0; it < nTrajs; it++){
586 std::set<ParticleId::PdgEnum>::const_iterator it_set = GetPropagator()->GetParticlePDGs().begin();
588 for (; it_set != GetPropagator()->GetParticlePDGs().end(); it_set++){
589 if (*it_set == track->
PDG){
599 if (!GetPropagator()->InVOI(track->
Position))
continue;
601 ParticlesAndInteractions.push_back(std::make_pair(track, std::vector<AnaTrueParticleB*>()));
605 for (Int_t jt = 0; jt < nTrajs; jt++){
612 ParticlesAndInteractions.back().second.push_back(track2);
622 result->nParticles = ParticlesAndInteractions.size();
628 for(Int_t i = 0; i < result->nParticles; i++){
633 if (ParticlesAndInteractions[i].second.size() == 0)
634 result->Particles[i].
intType = si_syst::kNoInteraction;
639 std::cout <<
" nParticles: " << result->nParticles << std::endl;
643 std::cout <<
" ======= " << std::endl;
651 std::ostream& operator<<(std::ostream& os,
const TLorentzVector& vect){
653 os <<
" X " << vect.X() <<
" Y " << vect.Y() <<
" Z " << vect.Z() <<
" T " << vect.T() << std::endl;
658 std::ostream& operator<<(std::ostream& os,
const TVector3& vect){
660 os <<
" X " << vect.X() <<
" Y " << vect.Y() <<
" Z " << vect.Z() << std::endl;
std::vector< std::pair< AnaTrueParticleB *, std::vector< AnaTrueParticleB * > > > ParentsAndDaughters
Basic structures to be able to associate a track with its "relatives".
si_syst::SIXSecData XSecDataReference
Store data for reference cross-section.
std::vector< StepInfo > propStepsReference
std::set< si_syst::InteractionType > _intTypes
Relevant interaction types to be considered while propagating.
bool _computeReWeightInfo
Whether to caculate weight for re-weighting (using the reference cross-section)
virtual Double_t GetCrossSectionError(const si_syst::InteractionType &, const Float_t &, const Int_t &, TGeoNode *) const =0
Double_t _lengthStepSize
The step size in terms of length.
virtual si_syst::SISystInput * GetRelevantParticles(AnaTrueParticleB **, int) const
Double_t GetIMaterial(TGeoNode *node)
si_syst::SIXSecData XSecData
Store both the cross-section and error.
bool IsInitialized()
Whether the propagator was initialized.
Int_t ID
The ID of the trueObj, which corresponds to the ID of the TTruthParticle that created it...
Representation of a true Monte Carlo trajectory/particle.
A simple structure to repesent a pair: xsection value and its uncertainty.
si_syst::SISystInput * CollectParticleInteractions(AnaTrueParticleB **, int, const SubDetId::SubDetEnum &) const
Calculates the information needed to compute an event weight.
const TVector3 field
Constants.
SubDetEnum
Enumeration of all detector systems and subdetectors.
virtual Double_t GetCrossSection(const si_syst::InteractionType &, const Float_t &, const Int_t &, TGeoNode *) const =0
Int_t PDG
The PDG code of this particle.
Float_t Weight
Weight for this particle, to be applied to correspond to a reference cross-section.
const AnaTrueParticleB * trueTrack
A pointer to the original true track.
MaterialEnum GetMaterialEnum(const std::string &)
Get the material enum given a material name.
const Double_t K
Bethe-Bloch constants.
A simple structure to represent a state object: position, direction, momentum, charge.
virtual Double_t DScattCenters(TGeoNode *) const
void TakeSmallStep(ParticleState &, const Double_t &)
Propagate a state in a small step.
Double_t BetheBloch(const ParticleState &)
virtual void Propagate(ParticleHistory &, const TVector3 &) const
Propagates a particle to a given pos filling all the history info.
std::vector< StepInfo > propSteps
Vector of steps considered with the corresponding info.
Int_t ParentID
The ID of this particle's immediate parent, or 0 if there is no parent.
Float_t PositionEnd[4]
The end position of the true particle.
Double_t GetIElement(Int_t Z)
Float_t Position[4]
The initial position of the true particle.
virtual Double_t GetReferenceCrossSection(const si_syst::InteractionType &, const Float_t &, const Int_t &, TGeoNode *) const
Double_t GetZoverAMaterial(TGeoNode *)
Float_t ComputeKineticEnergy(Float_t mom, Float_t mass)
Compute kinetic energy given momentum and mass.
void Print()
Dump the history.
virtual Bool_t InVOI(const TVector3 &) const =0
Is a point inside a volume of interest: the region where the propagation is relevant.
ParticleState stateCurrent
Current state of the particle.