#include using std::cout; using std::cerr; using std::cin; using std::endl; #include using std::valarray; #include using std::vector; #include using std::string; #include using std::list; #include using std::map; #include #include using std::fstream; #include using std::pair; //#include #include "TObject.h" #include "TVector3.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 "DrcOptMatAbs.h" #include "DrcOptDev.h" #include "DrcUtil.h" //---------------------------------------------------------------------- DrcPhoton::DrcPhoton() { m_lambda = 0; m_position = XYZPoint(0,0,0); m_positionOld = XYZPoint(0,0,0); m_direction = XYZPoint(0,0,0); m_fate = Drc::PhotFlying; m_reflections = 0; m_verbosity = 0; m_time = 0; m_dev = 0; } //---------------------------------------------------------------------- void DrcPhoton::setPosition(const XYZPoint& pos) { if (m_dev && m_dev->radiator()) // no flat device { double n = (m_dev->optMaterial()).refIndex(m_lambda); double dndl = (m_dev->optMaterial()).refIndexDeriv(m_lambda); double len = sqrt((pos-m_position).Mag2()); // mm double v_phase = 299.792/n; double v_group = v_phase * ( 1.0 - m_lambda/n*dndl); double time = len/v_group; m_time += time; // pos in mm time in ns } m_positionOld = m_position; m_position = pos; }; //---------------------------------------------------------------------- void DrcPhoton::reflect(const XYZVector& normal) { XYZVector normal1(normal); if (m_direction.Dot(normal) < 0) normal1 *= -1; m_direction = m_direction-2*(m_direction.Dot(normal1))*normal1; m_reflections++; } //---------------------------------------------------------------------- int DrcPhoton::colorNumber(double lambda) const { // the colors were taken from wikipedia entry about colors. if (lambda< 0.1) return 17; // grey if (lambda> 740) return 50; // dark red else if (lambda> 625) return 2; // red else if (lambda> 590) return 42; // orange else if (lambda> 565) return 5; // yellow else if (lambda> 520) return 3; // green else if (lambda> 500) return 7; // cyan else if (lambda> 450) return 4; // blue else if (lambda> 430) return 9; // indigo else if (lambda> 380) return 39; // violet return 33; // blue grey } //---------------------------------------------------------------------- void DrcPhoton::print(fstream& stream) const { //if (m_reflections==0) return; stream<<" TPolyLine3D *l = new TPolyLine3D(2);"<SetPoint("<<0<<"," <SetPoint("<<1<<"," <SetLineColor("<Draw();"<