ROBAST logo
// Author: Akira Okumura <mailto:oxon@mac.com>
/******************************************************************************
 * Copyright (C) 2006-, Akira Okumura                                         *
 * All rights reserved.                                                       *
 *****************************************************************************/

#ifndef A_REFRACTIVE_INDEX_H
#define A_REFRACTIVE_INDEX_H

#include "TGraph.h"
#include "TMath.h"

#include <complex>
#include <limits>
#include <memory>

///////////////////////////////////////////////////////////////////////////////
//
// ARefractiveIndex
//
// Abstract class for refractive index
//
///////////////////////////////////////////////////////////////////////////////

class ARefractiveIndex : public TObject {
 protected:
  std::shared_ptr<TGraph> fRefractiveIndex;
  std::shared_ptr<TGraph> fExtinctionCoefficient;

 public:
  ARefractiveIndex(){};
  ARefractiveIndex(Double_t n, Double_t k = 0.);
  virtual ~ARefractiveIndex(){};

  virtual Double_t GetAbbeNumber() const;
  virtual Double_t GetRefractiveIndex(Double_t lambda) const {
    return fRefractiveIndex ? fRefractiveIndex->Eval(lambda) : 1.;
  }
  virtual Double_t GetExtinctionCoefficient(Double_t lambda) const {
    return fExtinctionCoefficient ? fExtinctionCoefficient->Eval(lambda) : 0.;
  }
  virtual Double_t GetAbsorptionLength(Double_t lambda) const {
    static const Double_t inf = std::numeric_limits<Double_t>::infinity();
    Double_t k = GetExtinctionCoefficient(lambda);
    return k <= 0. ? inf : ExtinctionCoefficientToAbsorptionLength(k, lambda);
  }
  virtual std::complex<Double_t> GetComplexRefractiveIndex(
      Double_t lambda) const {
    return std::complex<Double_t>(GetRefractiveIndex(lambda),
                                  GetExtinctionCoefficient(lambda));
  }
  virtual void SetExtinctionCoefficient(std::shared_ptr<TGraph> graph) {
    fExtinctionCoefficient = graph;
  }
  virtual void SetRefractiveIndex(std::shared_ptr<TGraph> graph) {
    fRefractiveIndex = graph;
  }
  static Double_t AbsorptionLengthToExtinctionCoefficient(Double_t a,
                                                          Double_t lambda) {
    return lambda / (4 * TMath::Pi() * a);
  }
  static Double_t ExtinctionCoefficientToAbsorptionLength(Double_t k,
                                                          Double_t lambda) {
    return lambda / (4 * TMath::Pi() * k);
  }

  ClassDef(ARefractiveIndex, 1)
};

#endif  // A_REFRACTIVE_INDEX_H
 ARefractiveIndex.h:1
 ARefractiveIndex.h:2
 ARefractiveIndex.h:3
 ARefractiveIndex.h:4
 ARefractiveIndex.h:5
 ARefractiveIndex.h:6
 ARefractiveIndex.h:7
 ARefractiveIndex.h:8
 ARefractiveIndex.h:9
 ARefractiveIndex.h:10
 ARefractiveIndex.h:11
 ARefractiveIndex.h:12
 ARefractiveIndex.h:13
 ARefractiveIndex.h:14
 ARefractiveIndex.h:15
 ARefractiveIndex.h:16
 ARefractiveIndex.h:17
 ARefractiveIndex.h:18
 ARefractiveIndex.h:19
 ARefractiveIndex.h:20
 ARefractiveIndex.h:21
 ARefractiveIndex.h:22
 ARefractiveIndex.h:23
 ARefractiveIndex.h:24
 ARefractiveIndex.h:25
 ARefractiveIndex.h:26
 ARefractiveIndex.h:27
 ARefractiveIndex.h:28
 ARefractiveIndex.h:29
 ARefractiveIndex.h:30
 ARefractiveIndex.h:31
 ARefractiveIndex.h:32
 ARefractiveIndex.h:33
 ARefractiveIndex.h:34
 ARefractiveIndex.h:35
 ARefractiveIndex.h:36
 ARefractiveIndex.h:37
 ARefractiveIndex.h:38
 ARefractiveIndex.h:39
 ARefractiveIndex.h:40
 ARefractiveIndex.h:41
 ARefractiveIndex.h:42
 ARefractiveIndex.h:43
 ARefractiveIndex.h:44
 ARefractiveIndex.h:45
 ARefractiveIndex.h:46
 ARefractiveIndex.h:47
 ARefractiveIndex.h:48
 ARefractiveIndex.h:49
 ARefractiveIndex.h:50
 ARefractiveIndex.h:51
 ARefractiveIndex.h:52
 ARefractiveIndex.h:53
 ARefractiveIndex.h:54
 ARefractiveIndex.h:55
 ARefractiveIndex.h:56
 ARefractiveIndex.h:57
 ARefractiveIndex.h:58
 ARefractiveIndex.h:59
 ARefractiveIndex.h:60
 ARefractiveIndex.h:61
 ARefractiveIndex.h:62
 ARefractiveIndex.h:63
 ARefractiveIndex.h:64
 ARefractiveIndex.h:65
 ARefractiveIndex.h:66
 ARefractiveIndex.h:67
 ARefractiveIndex.h:68
 ARefractiveIndex.h:69
 ARefractiveIndex.h:70