Hi,
In following example macro BeamSize.C,
the first function draw in the memory will be overwritten by
the second function draw attempt and I cannot draw both
functions in the same plot. How can I both curves in the same
plot?
Thanks,
#define M_PI 3.14159265358979323846264338327950288 /* pi /
#define M_PI_2 1.57079632679489661923132169163975144 / pi/2 */
const Float_t m_to_mm = 1e3;
/* defaults /
Float_t beta_star = 0.7 ;// [m]
Float_t gamma = 250 ;
Float_t emittance = 40e-6M_PI; // [m rad]
Float_t BetaFunc(Float_t z);
Float_t BmSz(Float_t z);
Float_t BetaFunc(Float_t z){
return beta_star + z*z/beta_star;
}
Float_t BmSz(Float_t z){
return sqrt(emittance*BetaFunc(z)/6/M_PI/gamma)*m_to_mm;
}
void LoadParameters(Int_t energy){
gamma = Float_t(energy) ;
if (energy == 250){
beta_star = 0.7 ;
emittance = 42e-6M_PI ;
}else if (energy == 100) {
beta_star = 1.0 ;
emittance = 20e-6M_PI ;
}
}
Int_t BeamSize(){
TCanvas * c = new TCanvas(“c”," ", 600, 400);
TF1 *f = new TF1(“f”,“BmSz(x)”,0, 0.1);
LoadParameters(250);
f -> SetLineColor(2) ; f -> Draw();
LoadParameters(100);
f -> SetLineColor(1) ; f -> Draw(“same”);
return 0;
}