Changeset 1356 for trunk


Ignore:
Timestamp:
06/12/02 09:35:01 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/WuerzburgSoft/Thomas/mphys
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WuerzburgSoft/Thomas/mphys/Changelog

    r1352 r1356  
    11                                                                  -*-*- END -*-*-
     2 2002/06/12: Thomas Bretz
     3
     4   * MElectron.[h,cc]:
     5     - added a primitive theta dependancy to DoInvCompton
     6     - added DrawInteractionLength
     7     
     8   * MParticle.[h,cc]:
     9     - added RofZ and ZofR as static functions
     10
     11   * MPhoton.[h,cc]:
     12     - added DrawInteractionLength
     13     - fixed the bug causing the 'strange factor': sigma_gg needs
     14       the sqrt of s.
     15
     16   * energyloss.C:
     17     - added
     18
     19
     20
    221 2002/06/10: Thomas Bretz
    322
  • trunk/WuerzburgSoft/Thomas/mphys/MElectron.cc

    r1352 r1356  
    3333
    3434#include <TF1.h>
     35#include <TH1.h>
     36#include <TPad.h>
     37#include <TCanvas.h>
     38#include <TRandom.h>
    3539
    3640#include "MPhoton.h"
     
    286290#include <iostream.h>
    287291
    288 MPhoton *MElectron::DoInvCompton()
    289 {
     292MPhoton *MElectron::DoInvCompton(Double_t theta)
     293{
     294    static TRandom rand(0);
     295
    290296    Double_t E0 = 511e-6; //[GeV]
    291297
    292298    Double_t epsilon;
    293299    Double_t e = GetEnergyLoss(&epsilon);
     300
     301    // er: photon energy before interaction, rest frame
     302    // e:  photon energy after interaction, lab
     303
     304    Double_t gamma     = fEnergy/E0;
     305    Double_t beta      = sqrt(1.-1./(gamma*gamma));
     306    //Double_t gammabeta = sqrt(gamma*gamma-1);
     307
     308    Double_t f = fEnergy/e;
     309
     310    Double_t t;
     311    Double_t arg;
     312    do
     313    {
     314        t = rand.Uniform(TMath::Pi()*2);
     315        Double_t er  = gamma*epsilon*(1.-beta*cos(t)); // photon energy rest frame
     316        arg = (f - E0/er - 1)/(f*beta+1);
     317        cout << "~" << flush;
     318
     319    } while (arg<-1 || arg>1);
     320
     321    Double_t theta1s = acos(arg);
     322    Double_t thetas = atan(sin(t)/(gamma*(cos(t)-beta)));
     323
     324    Double_t thetastar = thetas-theta1s;
     325
     326    Double_t theta1 = atan(sin(thetastar)/(gamma*(cos(thetastar)+beta)));
     327
    294328    /*
    295      Double_t gamma = fEnergy/E0;
    296      Double_t beta = sqrt(1-1/(gamma*gamma));
    297      Double_t bega = sqrt(gamma*gamma-1);
    298 
    299      Double_t theta = TMath::Pi()/4;
    300 
    301      // er: photon energy before interaction rest frame
    302      // e:  photon energy after interaction lab
    303      Double_t er = gamma*epsilon*(1-beta*cos(theta)); // photon energy rest frame
    304      Double_t r1 = fEnergy/e;
    305      Double_t r2 = E0/er;
    306      Double_t ctheta = (r1-r2-1)/(beta*r1-1);
    307      Double_t tg = sqrt(1-ctheta*ctheta)/gamma/(beta+ctheta);
    308     */
     329     cout << "(" << theta1/TMath::Pi()*180 << ",";
     330     cout << theta1s/TMath::Pi()*180<< ",";
     331     cout << arg << ")" << flush;
     332     */
     333
    309334    fEnergy -= e;
    310335
    311336    MPhoton &p = *new MPhoton(e, fZ);
    312337    p = *this;
    313 
    314     /*
    315      cout << "(" << atan(tg)*180/TMath::Pi() << ")" << flush;
    316 
    317      static TRandom rand(0);
    318      p->SetNewDirection(atan(tg), rand.Uniform(TMath::Pi()*2));
    319      */
     338    p.SetNewDirection(theta1, rand.Uniform(TMath::Pi()*2));
    320339
    321340    // MISSING: Electron angle
     
    327346    return &p;
    328347}
     348
     349void MElectron::DrawInteractionLength(Double_t z)
     350{
     351    if (!gPad)
     352        new TCanvas("IL_Electron", "Mean Interaction Length Electron");
     353    else
     354        gPad->GetVirtCanvas()->cd(3);
     355
     356    TF1 f2("length", MElectron::InteractionLength, 1e3, 1e10, 0);
     357    f2.SetParameter(0, z);
     358
     359    gPad->SetLogx();
     360    gPad->SetLogy();
     361    gPad->SetGrid();
     362    f2.SetLineWidth(1);
     363
     364    TH1 &h=*f2.DrawCopy()->GetHistogram();
     365
     366    h.SetTitle("Mean Interaction Length (Electron)");
     367    h.SetXTitle("E [GeV]");
     368    h.SetYTitle("x [kpc]");
     369
     370    gPad->Modified();
     371    gPad->Update();
     372}
     373
     374void MElectron::DrawInteractionLength() const
     375{
     376    DrawInteractionLength(fZ);
     377}
  • trunk/WuerzburgSoft/Thomas/mphys/MElectron.h

    r1352 r1356  
    4040    Double_t GetEnergyLoss(Double_t *ep) const;
    4141
    42     MPhoton *DoInvCompton();
     42    MPhoton *DoInvCompton(Double_t theta);
     43
     44    // ----------------------------------------------------------------
     45
     46    static void DrawInteractionLength(Double_t z);
     47    void DrawInteractionLength() const;
    4348
    4449    ClassDef(MElectron, 1)
  • trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc

    r1352 r1356  
    2525 */
    2626
    27 Double_t ZofR(Double_t *x, Double_t *k=NULL)
     27Double_t MParticle::ZofR(Double_t *x, Double_t *k)
    2828{
    2929    const Double_t c  = 299792458;        // [m/s]
     
    3939}
    4040
    41 Double_t RofZ(Double_t *x, Double_t *k=NULL)
     41Double_t MParticle::RofZ(Double_t *x, Double_t *k)
    4242{
    4343    Double_t z1 = x[0] + 1;
  • trunk/WuerzburgSoft/Thomas/mphys/MParticle.h

    r1352 r1356  
    1616protected:
    1717    Double_t fEnergy; // [GeV] Energy
    18     Double_t fBeta;   // [1]   beta
     18//    Double_t fBeta;   // [1]   beta
    1919
    2020    Double_t fZ;      // [1]   Red shift
     
    3838    }
    3939
     40    static Double_t MParticle::ZofR(Double_t *x, Double_t *k=NULL);
     41    static Double_t MParticle::RofZ(Double_t *x, Double_t *k=NULL);
     42
    4043    //    void Fill(const MParContainer *inp);
    4144
     
    4447
    4548    void SetEnergy(Double_t e) { fEnergy = e; }
    46     void SetBeta(Double_t b)   { fBeta = b; }
     49  //  void SetBeta(Double_t b)   { fBeta = b; }
    4750
    4851    void SetZ(Double_t z)      { fZ = z; }
  • trunk/WuerzburgSoft/Thomas/mphys/MPhoton.cc

    r1349 r1356  
    3333
    3434#include <TF1.h>
     35#include <TH1.h>
     36#include <TPad.h>
     37#include <TCanvas.h>
    3538
    3639ClassImp(MPhoton);
     
    4346    // constants moved out of function, see below
    4447    //
    45     Double_t E   = x[0];                    // [GeV]
    46     Double_t z   = k ? k[0] : 0;
    47 
    48     Double_t T   = 2.96*(z+1);              // [K]
    49     Double_t e   = 1.602176462e-19;         // [C]
    50     Double_t kB  = 1e-9/e*1.3806503e-23;    // [GeV/K]
    51 
    52     Double_t EkT = E/kB/T;
     48    const Double_t E   = x[0];                    // [GeV]
     49    const Double_t z   = k ? k[0] : 0;
     50
     51    const Double_t T   = 2.96*(z+1);              // [K]
     52    const Double_t e   = 1.602176462e-19;         // [C]
     53    const Double_t kB  = 1e-9/e*1.3806503e-23;    // [GeV/K]
     54
     55    const Double_t EkT = E/kB/T;
    5356
    5457    /*
     
    6669Double_t MPhoton::Sigma_gg(Double_t *x, Double_t *k=NULL)
    6770{
    68     Double_t s = x[0]; // omega: CM mass
    69 
    70     Double_t E0 = 511e-6;         // [GeV]
    71     Double_t r0 = 2.81794092e-15; // [m] = e^2/4/pi/m/eps0/c^2
    72 
    73     Double_t m  = E0/s;
    74 
    75     Double_t m2 = m*m;
    76     Double_t beta  = sqrt(1.-m2);
    77     Double_t beta2 = 1.-m2;
    78 
    79     Double_t p1 = r0*r0*TMath::Pi()/2;
    80 
    81     // ----- Extreme Relativistic -----
     71    const Double_t m2 = x[0]; // m2: (E0/sqrt(s))^2
     72
     73    const Double_t r0 = 2.81794092e-15; // [m] = e^2/4/pi/m/eps0/c^2
     74
     75    const Double_t beta2 = 1.-m2;
     76    const Double_t beta  = sqrt(beta2);
     77
     78    const Double_t p1 = r0*r0*TMath::Pi()/2;
     79
     80    // ----- Extreme Relativistic -------
    8281    // return p1*2 * m*m*m* (log(2./m)-1);
    83     // --------------------------------
    84 
    85     Double_t p2 = m2;
    86     Double_t p3 = 3.-beta2*beta2;
    87     Double_t p4 = log((1.+beta)/(1.-beta));
    88     Double_t p5 = beta*2*(1.+m2);
    89 
    90     Double_t sigma = p1*p2*(p3*p4-p5); // [m^2]
     82    // ----------------------------------
     83
     84    const Double_t p2 = 3.-beta2*beta2;
     85    const Double_t p3 = log((1.+beta)/(1.-beta));
     86    const Double_t p4 = beta*2*(1.+m2);
     87
     88    const Double_t sigma = p1*m2*(p2*p3-p4); // [m^2]
    9189
    9290    return sigma;
     
    9593Double_t MPhoton::Int1(Double_t *x, Double_t *k=NULL)
    9694{
    97     Double_t costheta = x[0];
    98 
    99     Double_t Eg = k[0];
    100     Double_t Ep = k[1];
    101 
    102     Double_t E0 = 511e-6; // [GeV]
    103 
    104     Double_t s = Eg*Ep/E0*(1.-costheta)*2;
    105 
    106     if (s<E0)   // Why is this necessary???
     95    const Double_t costheta = x[0];
     96
     97    const Double_t Eg = k[0];
     98    const Double_t Ep = k[1];
     99
     100    const Double_t E0 = 511e-6; // [GeV]
     101
     102    Double_t s = E0/Eg*E0/Ep/(1.-costheta)/2;
     103    if (s>1)   // Why is this necessary???
    107104        return 0;
    108105
    109     Double_t sigma = Sigma_gg(&s);  // [m^2]
     106    const Double_t sigma = Sigma_gg(&s);  // [m^2]
    110107
    111108    return sigma/2 * (1.-costheta); // [m^2]
     
    114111Double_t MPhoton::Int2(Double_t *x, Double_t *k)
    115112{
    116     Double_t E0 = 511e-6; // [GeV]
     113    const Double_t E0 = 511e-6; // [GeV]
    117114
    118115    Double_t Ep = x[0];
    119     Double_t Eg = k[0];
    120 
    121116    Double_t z  = k[1];
    122117
     118    const Double_t Eg = k[0];
     119
    123120    Double_t val[2] = { Eg, Ep };
    124121
    125     Double_t from = -1.0;
    126     Double_t to   = 1.-E0*E0/2./Eg/Ep; // Originally Was: 1.
     122    const Double_t from = -1.0;
     123    const Double_t to   = 1.-E0*E0/(2.*Eg*Ep); // Originally Was: 1.
    127124
    128125    TF1 f("int1", Int1, from, to, 2);
    129     Double_t int1   = f.Integral(from, to, val);  // [m^2]
    130     Double_t planck = Planck(&Ep, &z);            // [GeV^2]
    131 
    132     Double_t res = planck * int1;
    133 
    134     res *= Eg/E0*1e-9; // FIXME!!!!!!!!!! WHICH FACTOR IS THIS????
     126
     127    const Double_t int1   = f.Integral(from, to, val);  // [m^2]
     128    const Double_t planck = Planck(&Ep, &z);            // [GeV^2]
     129
     130    const Double_t res = planck * int1;
    135131
    136132    return res; // [GeV^2 m^2]
     
    156152    Double_t val[2] = { Eg, z };
    157153
    158     Double_t lolim = E0*E0/Eg;
    159     Double_t inf   = 4e-12; //E0*E0/Eg * sqrt(Eg);
     154    Double_t lolim = E0*E0 > 1e-8 ? E0*E0/Eg : 1e-8/Eg;
     155    Double_t inf   = 3e-11;
    160156
    161157    TF1 f("int2", Int2, lolim, inf, 2);
     
    192188}
    193189
     190void MPhoton::DrawInteractionLength(Double_t z)
     191{
     192    if (!gPad)
     193        new TCanvas("ILPhoton", "Mean Interaction Length Photon");
     194    else
     195        gPad->GetVirtCanvas()->cd(4);
     196
     197    TF1 f1("length", InteractionLength, 1e4, 1e11, 1);
     198    f1.SetParameter(0, z);
     199
     200    gPad->SetLogx();
     201    gPad->SetLogy();
     202    gPad->SetGrid();
     203    f1.SetMaximum(1e5);
     204    f1.SetLineWidth(1);
     205
     206    TH1 &h=*f1.DrawCopy()->GetHistogram();
     207
     208    h.SetTitle("Mean Interaction Length (Photon)");
     209    h.SetXTitle("E [GeV]");
     210    h.SetYTitle("x [kpc]");
     211
     212    gPad->Modified();
     213    gPad->Update();
     214}
     215
     216void MPhoton::DrawInteractionLength() const
     217{
     218    DrawInteractionLength(fZ);
     219}
  • trunk/WuerzburgSoft/Thomas/mphys/MPhoton.h

    r1352 r1356  
    1717    void operator=(MParticle &p) { MParticle::operator=(p); }
    1818
     19    // ----------------------------------------------------------------
     20
    1921    static Double_t Planck(Double_t *x, Double_t *k=NULL);
    2022    static Double_t Sigma_gg(Double_t *x, Double_t *k=NULL);
     
    2628    Double_t GetInteractionLength() const;
    2729
     30    // ----------------------------------------------------------------
     31
     32    static void DrawInteractionLength(Double_t z);
     33    void DrawInteractionLength() const;
     34
    2835    ClassDef(MPhoton, 1)
    2936};
Note: See TracChangeset for help on using the changeset viewer.