Changeset 19785 for trunk


Ignore:
Timestamp:
10/24/19 15:02:48 (5 years ago)
Author:
tbretz
Message:
Allow to setup a point source.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/hawc/fresnellens_traceray.C

    r19649 r19785  
    4444    const double lambda  = 546; // [nm] Wavelength for the simulated photons
    4545
    46     double angle = 6; // Angle of incidence of the simulated rays
     46    const bool point_source = false;  // Enable simulation of a point source
    4747
    48     double Z0 = 3;    // Starting Z-position of rays
     48    const double angle = 6; // [deg] Angle of incidence of the simulated rays
     49
     50    const double Z0 = point_source ? F : 3; // [cm] Starting Z-position of rays
     51    const double X0 = Z0*atan(angle*TMath::DegToRad()); // [cm] (If<0: parallel rays (see angle), If>=0: point source at X0/Z0)
    4952
    5053    MFresnelLens lens;
     
    9497    // ------------------------------------------------------
    9598
     99    if (point_source)
     100        cout << "\nPoint source at x=" << X0 << " z=" << Z0 << "\n" << endl;
     101
     102    // ------------------------------------------------------
     103
    96104    TArrow arrow;
    97105    TMarker marker;
     
    112120        TVector3 dir(0, 0, -1);
    113121
    114         dir.SetMagThetaPhi(1, (180-angle)*TMath::DegToRad(), 0);
     122        double theta = point_source ?
     123            TMath::Pi()-atan((X+X0)/Z0) :
     124            (180-angle)*TMath::DegToRad();
     125
     126        dir.SetMagThetaPhi(1, theta, 0);
    115127
    116128        MQuaternion p(pos, 0);
    117129        MQuaternion u(dir, vc);
    118130
    119         // Photon must be at the lens surface before it can enter the lens
     131        // Propagate to starting plane in front of the lens
    120132        p.PropagateZ(u, Z0);
    121133
     
    125137        const int cnt = lens.TraceRay(vec, p, u, lambda, true);
    126138
    127         // Particle sucdessfully reached the focal plane
     139        // Particle successfully reached the focal plane
    128140        if (cnt>=0)
    129141        {
Note: See TracChangeset for help on using the changeset viewer.