// ---------------------------------------------------- // This file belongs to the ray tracing framework // for the use with Cherenkov detectors // // created 2007 //----------------------------------------------------- #include "PndDrcOptVol.h" //#include "PndDrcPhoton.h" #include "PndDrcOptReflAbs.h" #include "PndDrcSurfAbs.h" #include "PndDrcOptMatAbs.h" //#include "PndDrcOptDev.h" //#include "PndDrcUtil.h" // //#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 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 using std::numeric_limits; #include #include // system #include //---------------------------------------------------------------------- PndDrcOptVol::PndDrcOptVol() { fOptMat = 0; fRadiator = true; } //---------------------------------------------------------------------- PndDrcOptVol::~PndDrcOptVol() { delete fOptMat; } //---------------------------------------------------------------------- PndDrcOptVol* PndDrcOptVol::Clone() const { return new PndDrcOptVol(*this); } //---------------------------------------------------------------------- void PndDrcOptVol::Copy(const PndDrcOptVol& d) { if (!(&(d.OptMaterial()))) { cerr<<" *** PndDrcOptVol::copy: optMaterial undefined."<=1) cout<<" PndDrcOptVol::operator=" <<"(const PndDrcOptVol&) name,copy: " <((*this)) = d; // assignment of base class part. Copy(d); } return *this; } //---------------------------------------------------------------------- void PndDrcOptVol::SetOptMaterial(const PndDrcOptMatAbs& mat) { if (&mat) { delete fOptMat; fOptMat = mat.Clone(); } } //---------------------------------------------------------------------- void PndDrcOptVol::Propagate(PndDrcPhoton& ph) { // fVerbosity=4; static const double kEps = 1.0e-9; if (Verbosity()>=4) cout<<" PndDrcOptVol::propagate, you are in "<=4) ph.print(); list::const_iterator kSurf; while (ph.Fate() == Drc::kPhotFlying) {// while if (ph.Reflections() > ph.ReflectionLimit()) { ph.SetFate(Drc::kPhotAbsorbed); if (Verbosity()>=4) cout<<" reflection limit was reached (absorbed)" << endl; break; // leave while loop } ph.SetDevice(this); //--------------- // search the closest surface which is not the surface where the photon is // right now. PndDrcSurfAbs* surf_closest=0; double path_length_min = numeric_limits::max(); for(kSurf=fListSurf.begin(); kSurf != fListSurf.end(); ++kSurf) { if (Verbosity()>=4) cout<<" check "<<(*kSurf)->Name() <<" (surface coupling = " <<(*kSurf)->Coupled()<<")"<SurfaceHit(ph,pos_new,path_length)) { if (Verbosity()>=4) { cout<<" hit for "<<(*kSurf)->Name()<kEps) { path_length_min = path_length; surf_closest = (*kSurf); } } else { if (Verbosity()>=4) { cout<<" no hit "<<(*kSurf)->Name()<<" of "<=4) cout<<" no hit with any surface ->edge hit->lost"<=4) cout<<" closest "<Name()<SurfaceHit(ph,pos_new,path_length)) {// hit surf_closest if (Verbosity()>=4) { XYZPoint pos_old(ph.Position()); XYZVector dir_old(ph.Direction()); cout<<" hit, set pos from "<=4) cout<<" absorption by material" << endl; break; // leave while loop } else { if (Verbosity()>=4) cout<<" new position set."<Normal(ph.Position()); Drc::Reflectivity refl; if (&(surf_closest->Reflectivity())) // Reflectivity defined { if (Verbosity()>=4) cout<<" PndDrcOptVol::reflectivity1a clause"<Reflectivity().Reflectivity(ph,norm); if (refl == Drc::ReflAbsorbed) { if (Verbosity()>=4) cout<<" PndDrcOptVol::propagate: absorbed"<Fresnel()); if (refr) { ph.SetFate(Drc::kPhotLost); // Photon refracted in nirvana. if (Verbosity()>=4) cout<<" Photon lost"<Coupled()) { // Step 3a ----------- Refraction (no reflectivity defined, no couplings) if (Verbosity()>=4) cout<<" PndDrcOptVol::reflectivity1b clause"; bool refr = ph.Refract(norm, OptMaterial().RefIndex(ph.Wavelength()), OptMaterial().Extinction(ph.Wavelength()), surf_closest->Fresnel()); if (Verbosity()>=4) cout<<" refr="<=4) cout<<" Photon lost"<=4) cout<<" surface coupling = " <Coupled() <<" for " <Name()<Coupled()) {// if surf_closest coupled list::const_iterator kDev_coupled; list::const_iterator kSurf_coupled; for (kDev_coupled = (surf_closest->CoupledDeviceList()).begin(), kSurf_coupled = (surf_closest->CoupledSurfaceList()).begin(); kDev_coupled != (surf_closest->CoupledDeviceList()).end(); ++kDev_coupled, ++kSurf_coupled) { if (Verbosity()>=4) cout<<" coupling to dev,copy,surf= " <<(*kDev_coupled)->Name()<<"," <<(*kDev_coupled)->CopyNumber()<<"," <<(*kSurf_coupled)->Name()<isFlat()) // taken out 27.02.08 after problems in test_barrel1 { ph1.SetPosition(ph.Position()-ph.Direction()*0.1); if (Verbosity()>=4) { cout<<" bring back from " <setVerbosity(5);//### bool hit = (*kSurf_coupled)->SurfaceHit(ph1,pos_new,path_length); if (Verbosity()>=4) { cout<<" hit="<Name()<<" of "<Normal(ph.Position()); if (&((*kSurf_coupled)->Reflectivity())) // Reflectivity defined { if (Verbosity()>=4) cout<<" PndDrcOptVol::reflectivity2a clause"<Reflectivity().Reflectivity(ph,norm); if (refl == Drc::ReflAbsorbed) { if (Verbosity()>=4) cout<<" PndDrcOptVol::propagate: mirror absorbed"<OptMaterial()); if (Verbosity()>=4) cout<<" opt_mat="<Name()<RefIndex(ph.Wavelength()); double ex2 = opt_mat->Extinction(ph.Wavelength()); // cout << "VOLCHECK: " << n1 << " " << ex1 << " " << n2 << " " << ex2 << endl; bool iref = ph.Refract(surf_closest->Normal(ph.Position()), n1, ex1, surf_closest->Fresnel(), n2, ex2); // if( surf_closest->Name() == "slab_side1" && !iref ) // cout << "wrong" << endl; if (Verbosity()>=4) cout<<" refract in new volume flag = " <=4) cout<<" go into new volume " <<(*kDev_coupled)->Name()<Propagate(ph); } else { break; // coupled surface loop, since phot. is reflected. } } else // screen or mirror... { // do not bring photons inside flat objects // ph.setPosition(ph.position()+2*kEps*ph.direction()); (*kDev_coupled)->Propagate(ph); } if (ph.Fate() != Drc::kPhotFlying) break; } } } if (ph.Fate() != Drc::kPhotFlying) break; // while loop } // if surf_closest... } // while // if the photon got from a surface hit the attribute Drc::kPhotMeasured // it should pass this location. // has moved into the surfaces->surfaceHit // if (ph.Fate() == Drc::kPhotMeasured) //PositionCorrection(ph); } //---------------------------------------------------------------------- //void PndDrcOptVol::PositionCorrection(PndDrcPhoton& ph) //{ // do nothing // might be implemented in detectors derived from this class. //}