Beispiel #1
0
void Propagation::Propagate(Particle &curr_particle,
		std::vector<Particle> &ParticleAtMatrix,
		std::vector<Particle> &ParticleAtGround,
		bool dropParticlesBelowEnergyThreshold
		) const {

	double theta_deflBF = 0.0;
	double BNorm = magneticFieldStrength; 

	double zin = curr_particle.Getz();
	double Ein = curr_particle.GetEnergy();
	int type = curr_particle.GetType();

	int wi_last = curr_particle.GetWeigth();

	double z_curr = zin;
	double Ecurr = Ein;

	bool interacted = 0;
	double min_dist = 1e12;
	double walkdone = 0;

	double E1 = 0;
	double E2 = 0;
	double E3 = 0;

	double stepsize = 0;
	double Elast = 0;

	double R = Uniform(0.0, 1.0);
	double R2 = Uniform(0.0, 1.0);

	Process proc;
	proc.SetIncidentParticle(curr_particle);
	proc.SetBackground(Bkg);
	
	double Ethr2 = std::max(fEthr, std::max(ElectronMass,ElectronMass*ElectronMass/proc.feps_sup));
	if (Ecurr < Ethr2)
	{
		if (!dropParticlesBelowEnergyThreshold)
			ParticleAtGround.push_back(curr_particle);

		return;
	}
		

	std::vector<double> EtargetAll = GetEtarget(proc, curr_particle);

	min_dist = ExtractMinDist(proc, curr_particle.GetType(), R, R2, EtargetAll);

	interacted = 0;
	double dz = 0;
	double zpos = zin;

	double corrB_factor = 0;
	double realpath = 0;

	double min_dist_last = min_dist;

	while (!interacted) {

		proc.SetInteractionAngle(cPI);
		theta_deflBF = 0;
		realpath = 0.1 * min_dist;

		theta_deflBF = GetMeanThetaBFDeflection(BNorm,
				curr_particle.GetEnergy(), curr_particle.GetType(), min_dist);
		corrB_factor = cos(theta_deflBF);

		stepsize = realpath * corrB_factor;
		dz = Mpc2z(stepsize);


		if ((walkdone + realpath) > min_dist) {
			interacted = 1;
		}

		if (zpos - dz <= 0) {
			dz = zpos;
			stepsize = z2Mpc(dz);
			realpath = stepsize / corrB_factor;
		}

		zpos -= dz;
		walkdone += realpath;
		Elast = Ecurr;

		if (type == 0 || type == 22)
			Ecurr = EnergyLoss1D(Ecurr, zpos + Mpc2z(realpath), zpos, 0);
		else
			Ecurr = EnergyLoss1D(Ecurr, zpos + Mpc2z(realpath), zpos, BNorm);

		z_curr = zpos;

		curr_particle.Setz(z_curr);
		curr_particle.SetEnergy(Ecurr);

				
		if (z_curr <= 0) 
		{
			ParticleAtGround.push_back(curr_particle);
			return;
		}
		if (Ecurr <= Ethr2) 
		{ 
			if (!dropParticlesBelowEnergyThreshold)
			{
				ParticleAtGround.push_back(curr_particle);
			}
			return;
		}
		proc.SetIncidentParticle(curr_particle);
		proc.SetCMEnergy();
		proc.SetLimits();
		//      std::vector<double> EtargetAll=GetEtarget(proc,curr_particle);
		min_dist = ExtractMinDist(proc, curr_particle.GetType(), R, R2,
				EtargetAll);
	} //end while

	if (interacted == 1) {
		if (proc.GetName() == Process::PP) {

			E1 = ExtractPPSecondariesEnergy(proc);

			if (E1 == 0 || E1 == Ecurr)
				std::cerr << "ERROR in PP process:  E : " << Ecurr << "  " << E1
						<< " " << std::endl;

			Particle pp(11, E1, z_curr,curr_particle.Generation()+1);
			pp.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pp);

			Particle pe(-11, Ecurr - E1, z_curr,curr_particle.Generation()+1);
			pe.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pe);
			return;
		} //if PP
		else if (proc.GetName() == Process::DPP) {
		  E1 = (Ecurr - 2 * ElectronMass) / 2.0;
			if (E1 == 0)
				std::cerr << "ERROR in DPP process E : " << E1 << std::endl;

			Particle pp(11, E1, z_curr,curr_particle.Generation()+1);
			pp.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pp);
			
			Particle pe(-11, E1, z_curr,curr_particle.Generation()+1);
			pe.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pe);

			return;
		} //end if DPP
		else if (proc.GetName() == Process::ICS) {        

			E1 = ExtractICSSecondariesEnergy(proc);
			E2 = Ecurr - E1;
			if (E1 == 0 || E2 == 0)
				std::cerr << "ERROR in ICS process E : " << E1 << " " << E2
						<< std::endl;

			Particle pp(curr_particle.GetType(), E1, z_curr,curr_particle.Generation()+1);
			pp.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pp);
			Particle pg(22, E2, z_curr,curr_particle.Generation()+1);
			pg.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pg);

			return;
		} //end if ics
		else if (proc.GetName() == Process::TPP) {
			E1 = E2 = ExtractTPPSecondariesEnergy(proc);
			E3 = Ecurr - E1 - E2;
			if (E1 == 0 || E2 == 0 || E3 == 0)
				std::cerr << "ERROR in TPP process E : " << E1 << " " << E2
						<< std::endl;

			Particle pp(11, E1, z_curr,curr_particle.Generation()+1);
			pp.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pp);
			
			Particle pe(-11, E1, z_curr,curr_particle.Generation()+1);
			pe.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(pe);
			
			Particle psc(curr_particle.GetType(), E3, z_curr,curr_particle.Generation()+1);
			psc.SetWeigth(wi_last);
			ParticleAtMatrix.push_back(psc);
			return;
		}
	}

	return;

}
Beispiel #2
0
std::vector<double> Propagation::GetEtarget(Process &proc,
		const Particle &particle) const {

	std::vector<double> Etarget;
	double Etarget_tmp = 0;
	double smintmp = 0;
	double z_curr = particle.Getz();
	double Energy = particle.GetEnergy();
	int pType = particle.GetType();
	double Eexp = smintmp/(4.0 * Energy);

	if (pType == 22) {
		proc.SetName(Process::PP);
	  proc.SetLimits();
	  smintmp = proc.GetMin(); 
	  Eexp = std::max(proc.feps_inf,ElectronMass*ElectronMass/Energy);    
	  if (Eexp > proc.feps_sup) {
//	    std::cout << proc.GetName() << "  " <<  Eexp << " too big wrt " << proc.feps_sup << " , " << proc.feps_inf << " .. it should not interact!" << std::endl;
	    Eexp = 0; 
	    Etarget.push_back(0);}
	  else
	    Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr);
	  Etarget.push_back(Etarget_tmp);

		proc.SetName(Process::DPP);
	  proc.SetLimits();
	  smintmp = proc.GetMin();
	  Eexp = std::max(proc.feps_inf,2*ElectronMass*ElectronMass/Energy);
	  if (Eexp > proc.feps_sup) {
//	    std::cout << proc.GetName() << "  " <<  Eexp << " too big wrt " << proc.feps_sup << " , " << proc.feps_inf << " .. it should not interact!" << std::endl;
	    Eexp = 0; 
	    Etarget.push_back(0);}
	  else
	    Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr);	  
	  Etarget.push_back(Etarget_tmp);
	}

	else if (abs(pType) == 11) {
		proc.SetName(Process::ICS);
	  proc.SetLimits();
	  smintmp = proc.GetMin();
	  Eexp = proc.feps_inf;
          Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr);	  
	  
	  Etarget.push_back(Etarget_tmp);
	  
		proc.SetName(Process::TPP);
	  proc.SetLimits();
	  smintmp = proc.GetMin();
	  Eexp = std::max(proc.feps_inf,2*ElectronMass*ElectronMass/Energy);
	  if (Eexp > proc.feps_sup) {
//	    std::cout << proc.GetName() << "  " <<  Eexp << " too big wrt " << proc.feps_sup << " , " << proc.feps_inf << " .. it should not interact!" << std::endl;
	    Eexp = 0; 
	    Etarget.push_back(0);}
	  else
	    Etarget_tmp = ShootPhotonEnergyMC(Eexp, z_curr);	  

	  Etarget.push_back(Etarget_tmp);
	}    //end e/e
	else
		std::cerr << "something wrong in particle type ( " << pType
				<< ". Propagation of photons and e+/e- is the only allowed.)"
				<< std::endl;

	if (Etarget.size() != 2) {
		std::cout << "something wrong with the Etarget!! " << std::endl;
		exit(0);
	}

	return Etarget;
}