Ignore:
Timestamp:
12/17/19 17:26:49 (5 years ago)
Author:
tbretz
Message:
Added a possibility to produce a pre-defined wavelength distirbution.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Mars/msimreflector/MSimRays.cc

    r19788 r19917  
    5252#include "MParList.h"
    5353
     54#include "MSpline3.h"
    5455#include "MQuaternion.h"
    5556
     
    7172    : fEvt(0), fReflector(0), fPointPos(0), fSource(0),
    7273    fNumPhotons(1000), fHeight(-1), fWavelengthMin(-1), fWavelengthMax(-1),
    73     fNameReflector("MReflector"), fNamePointPos("MPointingPos"),
     74    fRandomDist(0), fNameReflector("MReflector"), fNamePointPos("MPointingPos"),
    7475    fNameSource("Source")
    7576{
    7677    fName  = name  ? name  : "MSimRays";
    7778    fTitle = title ? title : "Task to calculate reflection os a mirror";
     79}
     80
     81MSimRays::~MSimRays()
     82{
     83    delete fRandomDist;
    7884}
    7985
     
    234240        dat.SetDirection(w);
    235241
    236         if (fWavelengthMin>0 && fWavelengthMax>0)
    237             dat.SimWavelength(fWavelengthMin, fWavelengthMax);
     242        if (fRandomDist)
     243        {
     244            dat.SetWavelength(fRandomDist->FindX(gRandom->Uniform()));
     245        }
     246        else
     247        {
     248            if (fWavelengthMin>0 && fWavelengthMax>0)
     249                dat.SimWavelength(fWavelengthMin, fWavelengthMax);
     250        }
    238251
    239252        idx++;
     
    247260}
    248261
     262void MSimRays::SetDistribution(const MSpline3 &s)
     263{
     264    delete fRandomDist;
     265    fRandomDist = new MSpline3(s.GetIntegralSpline());
     266}
     267
     268bool MSimRays::ReadDistribution(const char *filename, const char *fmt)
     269{
     270    TGraph g(filename, fmt);
     271    if (g.GetN()<2)
     272        return false;
     273
     274    SetDistribution(MSpline3(g));
     275    return true;
     276}
     277
    249278// --------------------------------------------------------------------------
    250279//
Note: See TracChangeset for help on using the changeset viewer.