package tfa;
import mmc.*;
/**
* This class can be used to produce energy losses and spectra of secondaries for all cross sections.
* Originally thought of to test precision of parameterizations used by mmc (with -test=1 and 2).
*
* -
* -proc=1: calculate energy losses and cross sections (above vcut)
*
* - rnd1>0 sets the random number which selects element of the medium on which the next interaction occurs
* - rnd2>0 sets the random number which selects the energy lost when the next interaction occurs
* - -rnd1>0 sets the initial energy of the muon for the generated table in GeV
* - -rnd2>0 sets the factor by which the energy of the muon is incremented in the generated table
*
*
* -
* -proc=2: check energy and distance integral calculation
*
* - rnd1 chooses final energy
* - rnd2 chooses final distance
*
*
* -
* -proc=3: calculate energy spectra for all cross sections (above vcut)
*
* - rnd1 sets muon energy in GeV
* - rnd2 sets number of points
*
*
*/
public class Test{
private static double rnd1=0.5, rnd2=0.5, edef=1.e4;
public static void main(String[] args){
double vcut=-1.0;
double ecut=-1.0;
String med="Ice";
String type="mu";
double elow=PhysicsModel.elow;
double ebig=PhysicsModel.ebig;
boolean lpmef=false;
int bspar=1;
int pncrs=1;
int pncbb=1;
int pncsh=1;
double crsci=1;
double crscb=1;
double crscp=1;
double crsce=1;
double crscd=1;
double rho=1;
int romb=5;
boolean raw=false;
String intr="none";
int test=1; // 1 for check_crosS, 2 for check_proP, 3 for plot_crosS
int bnum=0;
String param="Test", pbad="";
boolean pflag;
for(int n=0; n1?",":"")+" \""+args[n]+"\"";
pflag=false;
}
if(pflag) param+=" "+args[n];
}
Output.err.println(Output.version);
Output.err.println("Running \""+param+"\"");
if(bnum>0){
pbad=bnum==1?pbad+" is":"s"+pbad+" are";
Output.err.println("Warning: Parameter"+pbad+" not recognized");
}
if(bspar<1 || bspar>4){
Output.err.println("Warning: bs is not a valid number");
bspar=1;
}
if(pncrs<1 || pncrs>4 || (pncrs==2 && !(type.equals("mu") || type.equals("tau")))){
Output.err.println("Warning: ph is not a valid number");
pncrs=1;
}
if(((pncrs==1 || pncrs==2) && (pncbb<1 || pncbb>4)) ||
(pncrs==3 && (pncbb<1 || pncbb>2)) || (pncrs==4 && pncbb!=1)){
Output.err.println("Warning: bb is not a valid number");
pncbb=1;
}
if(((pncrs==1 || pncrs==2) && (pncsh!=1)) || ((pncrs>2) && (pncsh<1 || pncsh>2))){
Output.err.println("Warning: sh is not a valid number");
pncsh=1;
}
if(romb<2 || romb>6){
Output.err.println("Warning: romb is not a valid number");
romb=5;
}
PhysicsModel.elow=elow;
PhysicsModel.ebig=ebig;
Propagate p = new Propagate(med , ecut, vcut, type, rho);
// p.p.low=4.05e2; // Default settings for the Frejus run are: p.low=105+300 and vcut=0.2
// p.s.b.lorenzCut=1.e7; p.s.b.lorenz=true; // Enable Lorenz invariant violation - cutoff energy in [MeV]
p.s.lpm=lpmef; // Enable lpm and dielectric suppression effects
p.s.b.form=bspar; // Choose parametrization of the bremsstrahlung cross section
p.s.n.form=pncrs; // Choose parametrization of the photon-nucleon cross section
p.s.n.bb=pncbb; // Choose parametrization of the photon-nucleon cross section
p.s.n.shadow=pncsh; // Choose parametrization of the photon-nucleon cross section
p.s.ci=crsci; // Cross section multiplicative modifier
p.s.cb=crscb; // Cross section multiplicative modifier
p.s.cp=crscp; // Cross section multiplicative modifier
p.s.ce=crsce; // Cross section multiplicative modifier
p.s.cd=crscd; // Cross section multiplicative modifier
Propagate.g=romb;
Output.raw=raw;
p.interpolate(intr, ".test"); // Comment this out to leave out parameterizations
Output.DEBUG=false;
switch(test){
case 1: check_crosS(p); break;
case 2: check_proP(p); break;
case 3: plot_crosS(p); break;
default: Output.err.println("Error: the proc="+test+" is not defined");
}
}
private static void check_crosS(Propagate p){
double ind=rnd1; // random number, chooses element
double rnd=rnd2; // .0, ... ,1., chooses lost energy
double save=0, aux, sum, part, e;
aux=1/(p.m.Ro*1.e3);
for(e=ind<0?-ind*1.e3:p.p.low*1.1; ep.ebig) emu=edef;
if(num<10) num=10;
else if(num>1000) num=1000;
int i, n;
double v, sum, step;
p.p.setEnergy(emu*1.e3);
p.s.i.s.setEnergy();
double alli=p.s.i.s.dNdx();
double allb=p.s.b.s.dNdx();
double alle=p.s.e.s.dNdx();
double alln=p.s.n.s.dNdx();
double all=alli+allb+alle+alln;
v=p.m.vCut(p.p.e);
step=Math.pow(1/v, 1./num);
Output.out.println("Sum of all cross sections is normalized to 1 from "+Output.f(v*emu)+" to "+Output.f(emu)+" GeV");
Output.out.println("all = "+Output.f(all)+" alli = "+Output.f(alli)+" allb = "+Output.f(allb)+
" alle = "+Output.f(alle)+" alln = "+Output.f(alln));
for(n=0, v*=Math.sqrt(step); np.s.i.s.vMin && vp.s.b.s.vMin && vp.s.e.s.vMin && vp.s.n.s.vMin && v