Ignore:
Timestamp:
07/26/02 14:49:58 (22 years ago)
Author:
tbretz
Message:
*** empty log message ***
Location:
trunk/WuerzburgSoft/Thomas/mphys
Files:
6 edited

Legend:

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

    r1429 r1448  
    11                                                                  -*-*- END -*-*-
     2 2002/06/26: Thomas Bretz
     3
     4   * MParticle.[h,cc]:
     5     - added fX data member
     6     - corrected a small bug in the SetNewPosition calculation
     7       (dr*cos(fTheta)>R*cos(fTheta) --> x(2)>R*cos(fTheta))
     8     - added usage of fX to the =-operator and SetNewPosition
     9     - added fSrcR (unsaved)
     10
     11   * MElectron.cc:
     12     - added usage of fX to the =-operator and SetNewPosition
     13     - changed to use the more accurate SetNewPosition in case B==0
     14
     15   * MPhoton.cc:
     16     - return 1e50 as InteractionLength in case Eg<100GeV
     17
     18   * phys.C:
     19     - added support for a B-Field-Bubble
     20
     21
     22
    223 2002/06/21: Thomas Bretz
    324
  • trunk/WuerzburgSoft/Thomas/mphys/MElectron.cc

    r1430 r1448  
    371371Bool_t MElectron::SetNewPositionB(Double_t B)
    372372{
     373    if (B==0)
     374        return SetNewPosition();
     375
    373376    static TRandom rand(0);
    374377    Double_t x = rand.Exp(GetInteractionLength());
     
    456459        p(0) = beta_p/beta*x;
    457460        p(1) = GetPType()==kEElectron?r*sin(rho):-r*sin(rho);
    458         p(2) = r*(1-cos(rho));
     461        p(2) = r*(1.-cos(rho));
    459462    }
    460463    else
     
    463466        p(1) = beta_o/beta*x;
    464467        p(2) = 0;
     468        cout << "------------- HEY! --------------" << endl;
    465469    }
    466470
     
    474478    p *= N2;
    475479    p *= M2;
     480
     481    if (p(2)<x) // happens sometimes in case B==0
     482    {
     483        cout << "----- HA: " << B << " " << x << " " << p(2) << " " << x-p(2) << endl;
     484        p(2)=x;
     485    }
     486
    476487    s -= p;
    477488
     
    479490    fPhi = atan2(s(1), s(0));
    480491    fZ   = ZofR(&s(2));
     492    fX  += x-p(2);
    481493
    482494    // -----------------------------
  • trunk/WuerzburgSoft/Thomas/mphys/MParticle.cc

    r1430 r1448  
    198198
    199199MParticle::MParticle(ParticleType_t t, const char *name, const char *title)
    200     : fPType(t), fZ(0), fR(0), fPhi(0), fTheta(0), fPsi(0)
     200    : fPType(t), fZ(0), fR(0), fPhi(0), fTheta(0), fPsi(0), fX(0)
    201201{
    202202    //
     
    259259    x(2) = cos(fTheta);
    260260
    261     x *= dr;
    262 
    263261    // ------------------------------
    264262
    265263    const Double_t R = RofZ(&fZ);
    266264
    267     if (x(2) > R*cos(fTheta))
     265    const Double_t dx = R - dr*x(2);
     266
     267    if (dx < 0)
    268268    {
    269         x *= R/dr;
     269        dr = R/x(2); // R>0 --> x(2)>0
    270270        rc = kFALSE;
    271271    }
     272    else
     273        fX += dr*(1.-x(2));
     274
     275    x  *= dr;
    272276
    273277    // ------------------------------
     
    283287    r -= x;
    284288
    285     fR   = sqrt(r(0)*r(0)+r(1)*r(1));
    286     fPhi = atan2(r(1), r(0));
    287     fZ   = ZofR(&r(2));
     289    if (fR!=0)
     290        fPhi = atan2(r(1), r(0));
     291
     292    fR = sqrt(r(0)*r(0)+r(1)*r(1));
     293    fZ = ZofR(&r(2));
    288294
    289295    return rc;
  • trunk/WuerzburgSoft/Thomas/mphys/MParticle.h

    r1447 r1448  
    2222
    2323protected:
     24    Double_t fSrcR;   //! [kpc] Distance from observer to source
     25
    2426    Double_t fEnergy; // [GeV] Energy
    2527
     
    3133    Double_t fPsi;    // [rad] Direction of momentum, az. angle
    3234
    33     Double_t fX;      // [kpc] real traveled distance (added in version 2)
     35    Double_t fX;      // [kpc] real traveled distance minus observers distance (added in version 2)
    3436
    3537public:
     
    4345    void operator=(MParticle &p)
    4446    {
     47        fSrcR = p.fSrcR;
    4548        fZ = p.fZ;
    4649        fR = p.fR;
     
    6063    void SetIsPrimary(Bool_t is=kTRUE) { is ? SetBit(kEIsPrimary) : ResetBit(kEIsPrimary); }
    6164    Bool_t IsPrimary() const { return TestBit(kEIsPrimary); }
     65
     66    void SetSrcR(Double_t r) { fSrcR = r; }
    6267
    6368    // ----------------------------------------------------------------
  • trunk/WuerzburgSoft/Thomas/mphys/MPhoton.cc

    r1430 r1448  
    121121    Double_t z  = k ? k[0] : 0;
    122122
     123    if (Eg<100)
     124        return 1e50;
     125
    123126    Double_t val[2] = { Eg, z };
    124127
  • trunk/WuerzburgSoft/Thomas/mphys/phys.C

    r1430 r1448  
    3333Double_t PhotonSpect(Double_t *x, Double_t *k=NULL)
    3434{
    35     Double_t Ep  = pow(10, x[0]);
     35    Double_t Ep = pow(10, x[0]);
    3636
    3737    Double_t res = MPhoton::Int2(&Ep, k);
     
    137137    Double_t R      = MParticle::RofZ(&startz); // [kpc]
    138138
    139     const char *filename = "cascade_0.03_24_1e2_1e6_256_1.root";
    140 
    141     const Double_t B = 0; // [T] mean magnetic field
    142 
    143     Double_t runtime = 3.5*60*60; // [s] maximum time to run the simulation
    144 
    145     Int_t nbins = 24;     // number of bins produced in energy spectrum
    146 
    147     Double_t lo = 1e2;    // lower limit of displayed spectrum
    148     Double_t hi = 1e6;    // upper limit of spectrum (cutoff)
    149 
    150     Int_t counter = 256;  // maximum number of inv. Compton (-1 means infinite)
    151 
    152     Double_t alpha = -1;  // -1 means a E^2 plot
    153     Double_t plot  =  1;  //  1 means a E^-2 spectrum
     139    const char *filename = "cascade_0.03_18_1e2_1e5_B0_256_1.root";
     140    //const char *filename = "test.root";
     141
     142    const Double_t B = 0;//1e-6*1e-4; // [T=1e4G] mean magnetic field
     143
     144    Double_t runtime = 45*60;     // [s] maximum time to run the simulation
     145
     146    Int_t nbins = 18;      // number of bins produced in energy spectrum
     147
     148    Double_t lo = 1e2;     // lower limit of displayed spectrum
     149    Double_t hi = 1e5;     // upper limit of spectrum (cutoff)
     150
     151    Int_t counter = 256;   // maximum number of inv. Compton (-1 means infinite)
     152
     153    Double_t alpha = -1;   // -1 means a E^2 plot
     154    Double_t plot  =  1;   //  1 means a E^-2 spectrum
     155
     156    Double_t bubbler = R-1e3*10; // [kpc]
     157    Double_t bubblez = MParticle::ZofR(&bubbler);
    154158
    155159    // --------------------------------------------------------------------
     
    250254        MPhoton *gamma=new MPhoton(E, startz);
    251255        gamma->SetIsPrimary();
     256        gamma->SetSrcR(R);
    252257        gamma->InitRandom();
    253258        listg.Add(gamma);
     
    304309                    //
    305310                    phot.SetParameter(1, p->GetZ());
    306 
    307                     Double_t Ep = pow(10, phot.GetRandom());
    308                     if (Ep==pow(10,0))
     311                    Double_t pe = phot.GetRandom();
     312                    if (pe==0)
    309313                    {
    310314                        cout << "z" << flush;
     
    312316                    }
    313317
     318                    Double_t Ep = pow(10, pe);
    314319                    Double_t theta = RandomTheta(Eg, Ep);
    315320                    if (theta==0)
     
    355360                while (test<0 ? true : (test++<counter))
    356361                {
    357 
    358                     if (!e->SetNewPositionB(B))
     362                    if (!e->SetNewPositionB(e->GetZ()>bubblez ? B : 0))
    359363                    {
    360364                        cout << "!" << flush;
     
    423427    file.Write();
    424428
     429    cout << "Wrote: " << filename << endl;
    425430    cout << "Created " << n << " gammas from source with E^" << alpha << endl;
    426431    cout << "Processing time: " << Form("%.1f", (TStopwatch::GetRealTime()-starttime)/n) << " sec/gamma." << endl;
     
    441446void phys()
    442447{
     448    /*
     449    Double_t Eg = 10;
     450    Double_t E0 = 511e-6;
     451    Double_t z  = 0.03;
     452    Double_t lolim = E0*E0/Eg;
     453    Double_t inf   = (Eg<1e6 ? 3e-11*(z+1) : 3e-12*(z+1));
     454    if (Eg<5e4)
     455        inf = 3e-11*(z+1)*pow(10, 9.4-log10(Eg)*2);
     456    TF1 phot("PhotonSpectrum", PhotonSpect, log10(lolim), log10(inf), 2);
     457    phot.SetParameter(0, Eg);
     458    phot.SetParameter(1, z);
     459
     460    Double_t val[2] = {Eg,z};
     461    cout << phot.Integral(log10(lolim), log10(inf), val, 1e-2) << endl;
     462
     463    cout << lolim << " " << inf << endl;
     464
     465    phot.DrawCopy();
     466    return;
     467*/
     468
    443469    DoIt();
    444470
Note: See TracChangeset for help on using the changeset viewer.