Changeset 19917 for trunk/Mars
- Timestamp:
- 12/17/19 17:26:49 (5 years ago)
- Location:
- trunk/Mars
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Mars/mbase/MSpline3.cc
r19128 r19917 234 234 } 235 235 236 return TMath::TwoPi()*MSpline3(x.GetArray(), y.GetArray(), n).Integral(); 237 } 236 return MSpline3(x.GetArray(), y.GetArray(), n).Integral(); 237 } 238 239 MSpline3 MSpline3::GetIntegralSpline() const 240 { 241 const Int_t n = GetNp(); 242 243 MArrayD x(n+2); 244 MArrayD y(n+2); 245 246 GetKnot(0, x[0], y[0]); 247 248 y[0] = 0; 249 250 GetKnot(0, x[1], y[1]); 251 252 y[1] = 0; 253 254 for (int i=0; i<n-1; i++) 255 { 256 GetKnot(i+1, x[i+2], y[i+2]); 257 y[i+2] = y[i+1]+IntegralBin(i, x[i+2]); 258 } 259 260 for (int i=2; i<=n; i++) 261 y[i] /= y[n]; 262 263 y[n+1] = 1; 264 265 x[0] = x[1] -(x[2]-x[1]); 266 x[n+1] = x[n] +(x[n]-x[n-1]); 267 268 return MSpline3(x.GetArray(), y.GetArray(), n+2, "b1 e1"); 269 } 270 238 271 239 272 -
trunk/Mars/mbase/MSpline3.h
r19128 r19917 64 64 Double_t IntegralSolidAngle() const; 65 65 66 MSpline3 GetIntegralSpline() const; 67 66 68 void Scale(double=1); 67 69 -
trunk/Mars/msimreflector/MSimRays.cc
r19788 r19917 52 52 #include "MParList.h" 53 53 54 #include "MSpline3.h" 54 55 #include "MQuaternion.h" 55 56 … … 71 72 : fEvt(0), fReflector(0), fPointPos(0), fSource(0), 72 73 fNumPhotons(1000), fHeight(-1), fWavelengthMin(-1), fWavelengthMax(-1), 73 f NameReflector("MReflector"), fNamePointPos("MPointingPos"),74 fRandomDist(0), fNameReflector("MReflector"), fNamePointPos("MPointingPos"), 74 75 fNameSource("Source") 75 76 { 76 77 fName = name ? name : "MSimRays"; 77 78 fTitle = title ? title : "Task to calculate reflection os a mirror"; 79 } 80 81 MSimRays::~MSimRays() 82 { 83 delete fRandomDist; 78 84 } 79 85 … … 234 240 dat.SetDirection(w); 235 241 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 } 238 251 239 252 idx++; … … 247 260 } 248 261 262 void MSimRays::SetDistribution(const MSpline3 &s) 263 { 264 delete fRandomDist; 265 fRandomDist = new MSpline3(s.GetIntegralSpline()); 266 } 267 268 bool 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 249 278 // -------------------------------------------------------------------------- 250 279 // -
trunk/Mars/msimreflector/MSimRays.h
r19599 r19917 7 7 8 8 class MParList; 9 class MSpline3; 9 10 class MGeomCam; 10 11 class MPointingPos; … … 28 29 Double_t fWavelengthMax; 29 30 31 MSpline3 *fRandomDist; //! 32 30 33 TString fNameReflector; 31 34 TString fNamePointPos; … … 41 44 public: 42 45 MSimRays(const char *name=NULL, const char *title=NULL); 46 ~MSimRays(); 43 47 44 48 void SetNameReflector(const char *name="MReflector") { fNameReflector = name; } … … 50 54 51 55 void SetWavelengthRange(Double_t min, Double_t max) { fWavelengthMin = min; fWavelengthMax = max; } 56 void SetDistribution(const MSpline3 &s); 57 bool ReadDistribution(const char *filename, const char *fmt="%lg %lg"); 52 58 53 59 // MSimRays
Note:
See TracChangeset
for help on using the changeset viewer.