// ---------------------------------------------------- // 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; } //---------------------------------------------------------------------- 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()) { // cout<<" PndDrcOptVol::propagate: killed (absorbed) photon after " // <::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()<=4) cout<<" path_length "<kEps) { path_length_min = path_length; surf_closest = (*kSurf); } } else { if (Verbosity()>=4) { cout<<" no hit "<<(*kSurf)->Name()<=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 "<> waveabsorb.tmp"; // system( shellString ); // // break; // leave while loop } else { ph.SetPosition(pos_new); if( ph.PositionListFlag() ) { ph.SetPositionXlist( pos_new.X() ); ph.SetPositionYlist( pos_new.Y() ); ph.SetPositionZlist( pos_new.Z() ); } 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( surf_closest->Name() == "lens_side1" || surf_closest->Name() == "lens_side2" || surf_closest->Name() == "lens_side3" // || surf_closest->Name() == "lens_side4" ) // if( surf_closest->Name() == "lens_sphere") // { // cout << "ja" << endl; // bool blub = ph.Refract(norm, OptMaterial().RefIndex(ph.Wavelength()),OptMaterial().Extinction(ph.Wavelength()),1,0,true,0,true); // } if (Verbosity()>=4) cout<<" PndDrcOptVol::propagate: mirror absorbed"<=4) cout<<" Photon lost"<Coupled()) { // Step 3a ----------- Refraction (no reflectivity defined, no couplings) if (Verbosity()>=4) cout<<" PndDrcOptVol::reflectivity1b clause"<Name() == "box_side2" || surf_closest->Name() == "box_side3" || surf_closest->Name() == "box_side4" // || surf_closest->Name() == "box_side6") // refr = ph.Refract(norm,OptMaterial().RefIndex(ph.Wavelength()), OptMaterial().Extinction(ph.Wavelength()),1,0,false,0); // else // refr = ph.Refract(norm,OptMaterial().RefIndex(ph.Wavelength()), OptMaterial().Extinction(ph.Wavelength()) ); if (refr) { if ( ph.Fate() == Drc::kPhotFlying) // otherwise different fate alread assigned { ph.SetFate(Drc::kPhotLost); // Photon refracted in nirvana. if (Verbosity()>=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()<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="<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, 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. if (ph.Fate() == Drc::kPhotMeasured) PositionCorrection(ph); } //---------------------------------------------------------------------- void PndDrcOptVol::PositionCorrection(PndDrcPhoton& ph) { // do nothing // might be implemented in detectors derived from this class. }