#include using std::cout; using std::cerr; using std::cin; using std::endl; #include using std::valarray; #include using std::fstream; #include using std::string; #include using std::list; #include "TObject.h" #include "TVector3.h" #include "TRandom.h" #include "Math/Vector3D.h" using ROOT::Math::XYZVector; #include "Math/Point3D.h" using ROOT::Math::XYZPoint; #include "Math/Transform3D.h" using ROOT::Math::Transform3D; #include "Math/RotationX.h" using ROOT::Math::RotationX; #include "Math/RotationY.h" using ROOT::Math::RotationY; #include "Math/RotationZ.h" using ROOT::Math::RotationZ; #include "Math/Rotation3D.h" using ROOT::Math::Rotation3D; #include "DrcPhoton.h" #include "DrcOptReflAbs.h" #include "DrcSurfAbs.h" #include "DrcOptMatAbs.h" #include "DrcOptDev.h" #include "DrcOptMirror.h" //---------------------------------------------------------------------- DrcOptMirror::DrcOptMirror() { m_first = true; m_surfFront = 0; m_surfBack = 0; } //---------------------------------------------------------------------- DrcOptMirror::~DrcOptMirror() { //delete m_surfFront; its in m_listSurf and is destructed by base class //delete m_surfBack; } //---------------------------------------------------------------------- DrcOptMirror* DrcOptMirror::clone() const { return new DrcOptMirror(*this); // call ctor } //---------------------------------------------------------------------- void DrcOptMirror::copy(const DrcOptMirror& d) { m_first = false; // do not copy. m_listSurf.clear(); m_surfFront = (d.m_surfFront)->clone(); m_listSurf.push_back(m_surfFront); m_surfBack = (d.m_surfBack)->clone(); m_listSurf.push_back(m_surfBack); //setFrontSurface(d.m_surfFront); not allowed because of delete //setBackSurface(d.m_surfBack); of unitialized m_surfXXX (eg. 0x1). } //---------------------------------------------------------------------- void DrcOptMirror::setFrontSurface(const DrcSurfAbs& surf) { if (&surf) { delete m_surfFront; m_surfFront = surf.clone(); m_listSurf.push_back(m_surfFront); } } //---------------------------------------------------------------------- void DrcOptMirror::setBackSurface(const DrcSurfAbs& surf) { if (&surf) { delete m_surfBack; m_surfBack = surf.clone(); m_listSurf.push_back(m_surfBack); } } //---------------------------------------------------------------------- DrcOptMirror::DrcOptMirror(const DrcOptMirror& d) : DrcOptDev(d) { if (d.m_verbosity>=1) cout<<" DrcOptMirror::DrcOptMirror" <<"(const DrcOptMirror&) name,copy: " <=1) cout<<" DrcOptMirror::operator=" <<"(const DrcOptMirror&) name,copy: " <((*this)) = d; // assignment of base class part. copy(d); } return *this; } //---------------------------------------------------------------------- void DrcOptMirror::addSurface(const DrcSurfAbs& surf) { cerr<<" *** DrcOptMirror::addSurface: do not use this routine.\n"; cerr<<" use setFrontSurface and setBackSurface\n"; exit(EXIT_FAILURE); } //---------------------------------------------------------------------- void DrcOptMirror::propagate(DrcPhoton& ph) { // mirror has two surfaces, front and back. if (m_first) { m_first = false; if (m_surfFront==0 || m_surfBack==0) { cerr<<" *** DrcOptMirror::propagate: Mirror needs 2 sides!"<reflectivity())) { refl = (m_surfFront->reflectivity()). reflectivity(ph,m_surfFront->normal(ph.position())); } if (refl == Drc::ReflAbsorbed) { if (verbosity()>=4) cout<<" DrcOptMirror::propagate: mirror absorbed"<::const_iterator idev_back_coupled; list::const_iterator isurf_back_coupled; XYZPoint pos_new; double path_length; for (idev_back_coupled = (m_surfBack->coupledDeviceList()).begin(), isurf_back_coupled = (m_surfBack->coupledSurfaceList()).begin(); idev_back_coupled != (m_surfBack->coupledDeviceList()).end(); ++idev_back_coupled, ++isurf_back_coupled) { bool hit = (*isurf_back_coupled)->surfaceHit(ph,pos_new,path_length); if (verbosity()>=4) { cout<<" DrcOptMirror::propagate: mirror transmitted def surf hit = " <<(*idev_back_coupled)->name()<<" " <<(*isurf_back_coupled)->name()<<" " <propagate(ph); } } // no successful coupling... if (ph.fate()==Drc::PhotFlying) ph.setFate(Drc::PhotAbsorbed); return; } if (refl == Drc::ReflReflected) { // reflect photon XYZVector norm = m_surfFront->normal(ph.position()); ph.reflect(norm); list::const_iterator idev_front_coupled; list::const_iterator isurf_front_coupled; XYZPoint pos_new; double path_length; for (idev_front_coupled = (m_surfFront->coupledDeviceList()).begin(), isurf_front_coupled = (m_surfFront->coupledSurfaceList()).begin(); idev_front_coupled != (m_surfFront->coupledDeviceList()).end(); ++idev_front_coupled, ++isurf_front_coupled) { bool hit = (*isurf_front_coupled)->surfaceHit(ph,pos_new,path_length); if (verbosity()>=4) { cout<<" DrcOptMirror::propagate: mirror reflected def surf hit = " <<(*idev_front_coupled)->name()<<" " <<(*isurf_front_coupled)->name()<<" " <propagate(ph); } } if (ph.fate() != Drc::PhotFlying) return; cerr<<" *** DrcOptMirror::propagate 1: this code line should never be hit.\n"; exit(EXIT_FAILURE); } if (ph.fate() != Drc::PhotFlying) return; cerr<<" *** DrcOptMirror::propagate 2: this code line should never be hit.\n"; exit(EXIT_FAILURE); }