ROBAST logo
/******************************************************************************
 * Copyright (C) 2006-, Akira Okumura                                         *
 * All rights reserved.                                                       *
 *****************************************************************************/

///////////////////////////////////////////////////////////////////////////////
//
// AOpticalComponent
//
// Classical ray class
//
///////////////////////////////////////////////////////////////////////////////

#include "TGeoManager.h"

#include "AOpticalComponent.h"

ClassImp(AOpticalComponent);

AOpticalComponent::AOpticalComponent()
    : TGeoVolume(), fBorderSurfaceConditionArray(0) {}

//_____________________________________________________________________________
AOpticalComponent::AOpticalComponent(const char* name, const TGeoShape* shape,
                                     const TGeoMedium* med)
    : TGeoVolume(name, shape, med), fBorderSurfaceConditionArray(0) {
#if ROOT_VERSION(5, 34, 16) <= ROOT_VERSION_CODE
  if (GetMedium() == TGeoVolume::DummyMedium()) {
    SetMedium(GetOpaqueVacuumMedium());
  }
#endif
}

//_____________________________________________________________________________
AOpticalComponent::~AOpticalComponent() {
  SafeDelete(fBorderSurfaceConditionArray);
}

//______________________________________________________________________________
void AOpticalComponent::AddBorderSurfaceCondition(
    ABorderSurfaceCondition* condition) {
  if (!fBorderSurfaceConditionArray) {
    fBorderSurfaceConditionArray = new TObjArray;
    fBorderSurfaceConditionArray->SetOwner(kTRUE);
  }

  fBorderSurfaceConditionArray->Add(condition);
}

//______________________________________________________________________________
ABorderSurfaceCondition* AOpticalComponent::FindBorderSurfaceCondition(
    AOpticalComponent* component2) {
  if (!fBorderSurfaceConditionArray) {
    return 0;
  }

  for (Int_t i = 0; i < fBorderSurfaceConditionArray->GetEntries(); i++) {
    if (((ABorderSurfaceCondition*)(*fBorderSurfaceConditionArray)[i])
            ->GetComponent2() == component2) {
      return (ABorderSurfaceCondition*)(*fBorderSurfaceConditionArray)[i];
    }
  }

  return 0;
}

//______________________________________________________________________________
TGeoMaterial* AOpticalComponent::GetOpaqueVacuumMaterial() const {
  if (!fGeoManager) {
    return 0;
  }

  TGeoMaterial* mat = fGeoManager->GetMaterial("ROBAST_OpaqueVacuumMaterial");
  if (!mat) {
    mat = new TGeoMaterial("ROBAST_OpaqueVacuumMaterial", 0, 0, 0);
  }

  return mat;
}

//______________________________________________________________________________
TGeoMaterial* AOpticalComponent::GetTransparentVacuumMaterial() const {
  if (!fGeoManager) {
    return 0;
  }

  TGeoMaterial* mat =
      fGeoManager->GetMaterial("ROBAST_TransparentVacuumMaterial");
  if (!mat) {
    mat = new TGeoMaterial("ROBAST_TransparentVacuumMaterial", 0, 0, 0);
    mat->SetTransparency(70);
  }

  return mat;
}

//______________________________________________________________________________
TGeoMedium* AOpticalComponent::GetOpaqueVacuumMedium() const {
  if (!fGeoManager) {
    return 0;
  }

  TGeoMedium* med = fGeoManager->GetMedium("ROBAST_OpaqueVacuumMedium");
  if (!med) {
    TGeoMaterial* mat = GetOpaqueVacuumMaterial();
    med = new TGeoMedium("ROBAST_OpaqueVacuumMedium", 1, mat);
  }

  return med;
}

//______________________________________________________________________________
TGeoMedium* AOpticalComponent::GetTransparentVacuumMedium() const {
  if (!fGeoManager) {
    return 0;
  }

  TGeoMedium* med = fGeoManager->GetMedium("ROBAST_TransparentVacuumMedium");
  if (!med) {
    TGeoMaterial* mat = GetTransparentVacuumMaterial();
    med = new TGeoMedium("ROBAST_TransparentVacuumMedium", 1, mat);
  }

  return med;
}
 AOpticalComponent.cxx:1
 AOpticalComponent.cxx:2
 AOpticalComponent.cxx:3
 AOpticalComponent.cxx:4
 AOpticalComponent.cxx:5
 AOpticalComponent.cxx:6
 AOpticalComponent.cxx:7
 AOpticalComponent.cxx:8
 AOpticalComponent.cxx:9
 AOpticalComponent.cxx:10
 AOpticalComponent.cxx:11
 AOpticalComponent.cxx:12
 AOpticalComponent.cxx:13
 AOpticalComponent.cxx:14
 AOpticalComponent.cxx:15
 AOpticalComponent.cxx:16
 AOpticalComponent.cxx:17
 AOpticalComponent.cxx:18
 AOpticalComponent.cxx:19
 AOpticalComponent.cxx:20
 AOpticalComponent.cxx:21
 AOpticalComponent.cxx:22
 AOpticalComponent.cxx:23
 AOpticalComponent.cxx:24
 AOpticalComponent.cxx:25
 AOpticalComponent.cxx:26
 AOpticalComponent.cxx:27
 AOpticalComponent.cxx:28
 AOpticalComponent.cxx:29
 AOpticalComponent.cxx:30
 AOpticalComponent.cxx:31
 AOpticalComponent.cxx:32
 AOpticalComponent.cxx:33
 AOpticalComponent.cxx:34
 AOpticalComponent.cxx:35
 AOpticalComponent.cxx:36
 AOpticalComponent.cxx:37
 AOpticalComponent.cxx:38
 AOpticalComponent.cxx:39
 AOpticalComponent.cxx:40
 AOpticalComponent.cxx:41
 AOpticalComponent.cxx:42
 AOpticalComponent.cxx:43
 AOpticalComponent.cxx:44
 AOpticalComponent.cxx:45
 AOpticalComponent.cxx:46
 AOpticalComponent.cxx:47
 AOpticalComponent.cxx:48
 AOpticalComponent.cxx:49
 AOpticalComponent.cxx:50
 AOpticalComponent.cxx:51
 AOpticalComponent.cxx:52
 AOpticalComponent.cxx:53
 AOpticalComponent.cxx:54
 AOpticalComponent.cxx:55
 AOpticalComponent.cxx:56
 AOpticalComponent.cxx:57
 AOpticalComponent.cxx:58
 AOpticalComponent.cxx:59
 AOpticalComponent.cxx:60
 AOpticalComponent.cxx:61
 AOpticalComponent.cxx:62
 AOpticalComponent.cxx:63
 AOpticalComponent.cxx:64
 AOpticalComponent.cxx:65
 AOpticalComponent.cxx:66
 AOpticalComponent.cxx:67
 AOpticalComponent.cxx:68
 AOpticalComponent.cxx:69
 AOpticalComponent.cxx:70
 AOpticalComponent.cxx:71
 AOpticalComponent.cxx:72
 AOpticalComponent.cxx:73
 AOpticalComponent.cxx:74
 AOpticalComponent.cxx:75
 AOpticalComponent.cxx:76
 AOpticalComponent.cxx:77
 AOpticalComponent.cxx:78
 AOpticalComponent.cxx:79
 AOpticalComponent.cxx:80
 AOpticalComponent.cxx:81
 AOpticalComponent.cxx:82
 AOpticalComponent.cxx:83
 AOpticalComponent.cxx:84
 AOpticalComponent.cxx:85
 AOpticalComponent.cxx:86
 AOpticalComponent.cxx:87
 AOpticalComponent.cxx:88
 AOpticalComponent.cxx:89
 AOpticalComponent.cxx:90
 AOpticalComponent.cxx:91
 AOpticalComponent.cxx:92
 AOpticalComponent.cxx:93
 AOpticalComponent.cxx:94
 AOpticalComponent.cxx:95
 AOpticalComponent.cxx:96
 AOpticalComponent.cxx:97
 AOpticalComponent.cxx:98
 AOpticalComponent.cxx:99
 AOpticalComponent.cxx:100
 AOpticalComponent.cxx:101
 AOpticalComponent.cxx:102
 AOpticalComponent.cxx:103
 AOpticalComponent.cxx:104
 AOpticalComponent.cxx:105
 AOpticalComponent.cxx:106
 AOpticalComponent.cxx:107
 AOpticalComponent.cxx:108
 AOpticalComponent.cxx:109
 AOpticalComponent.cxx:110
 AOpticalComponent.cxx:111
 AOpticalComponent.cxx:112
 AOpticalComponent.cxx:113
 AOpticalComponent.cxx:114
 AOpticalComponent.cxx:115
 AOpticalComponent.cxx:116
 AOpticalComponent.cxx:117
 AOpticalComponent.cxx:118
 AOpticalComponent.cxx:119
 AOpticalComponent.cxx:120
 AOpticalComponent.cxx:121
 AOpticalComponent.cxx:122
 AOpticalComponent.cxx:123
 AOpticalComponent.cxx:124
 AOpticalComponent.cxx:125