#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 #include using std::fstream; #include using std::pair; #include using std::map; //#include #include "TVector3.h" #include "TRandom.h" #include "TRotation.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 "DrcSurfPolyFlat.h" #include "DrcSurfQuadFlatDiff.h" #include "DrcSurfPolySphere.h" #include "DrcSurfPolyPara.h" #include "DrcSurfPolyAsphere.h" #include "DrcOptReflSilver.h" #include "DrcOptReflNone.h" #include "DrcOptReflPerfect.h" #include "DrcOptMatAbs.h" #include "DrcOptMatLithotecQ0.h" #include "DrcOptMatNLAK33A.h" #include "DrcOptMatLLF1.h" #include "DrcOptMatVacuum.h" #include "DrcOptDev.h" #include "DrcOptDevSys.h" #include "DrcOptVol.h" #include "DrcOptPixel.h" #include "DrcOptMirror.h" #include "DrcOptDevManager.h" #include "DrcUtil.h" int main(int argc, char *argv[]) { double conical_const = 0; //cout<<" constant = "; //cin>>conical_const; //double conical_const = -1; // parabola //double conical_const = 1; // ellipse //double conical_const = -1; // hyperbola //int ioption = 1; // parallel beam (0 deg) int ioption = 2; // 0, +- 20, +-40 deg //int ioption = 3; // C-cone //int ioption = 4; // random in front of lens. //int ioption = 5; // single photon for debugging. //int ioption = 6; // grid 5 deg double pi=3.1415926535; DrcOptReflPerfect refl_perfect; DrcOptReflNone refl_none; double lambda=500; double slab_width = 17; double slab_height = 17; XYZPoint q0(-slab_width/2, +slab_height/2, 0.0); XYZPoint q1(-slab_width/2, -slab_height/2, 0.0); XYZPoint q2(+slab_width/2, -slab_height/2, 0.0); XYZPoint q3(+slab_width/2, +slab_height/2, 0.0); DrcOptMatLithotecQ0 quartz; DrcOptMatNLAK33A nlak33a; DrcOptMatVacuum vacuum; DrcOptMatLLF1 llf1; DrcSurfPolySphere lens_sphere; lens_sphere.setVerbosity(0); //lens_sphere.setConicalConstant(conical_const); lens_sphere.addPoint(q0); lens_sphere.addPoint(q1); lens_sphere.addPoint(q2); lens_sphere.addPoint(q3); // screen 101 mm from b0 double f,f1,f2,radius1,radius2; double n2 = llf1.refIndex(lambda); double n1 = nlak33a.refIndex(lambda); cout<<" n1 = "<>f; double viol = 0.1; // Petzval violation f1 = f*(1.0+n2/(-n1)); f2 = f*(1.0+n1/(-n2)); cout<<" petzval = "<0) : "<addDeviceSystem(opt_system); fstream geo; geo.open("Geo.C",std::ios::out); geo<<"{"<SetRange(-450,-450,-300,450,450,500);"<SetRange(-450,-450,-450,450,450,450);"<SetView(180,45,90,i);"<SetView(90,0,90,i);"<Zoom();"<Zoom();"<Zoom();"<Zoom();"<Zoom();"<Zoom();"<Zoom();"<print(geo); //geo<<"}"< list_photon; // get list DrcPhoton ph; bool photons_exist = false; if (ioption==1) { slab_width*=0.5; slab_height*=0.5; for (double xx=-slab_width/2; xx<=slab_width/2; xx+=slab_width/4) { for (double yy=-slab_height/2; yy<=slab_height/2; yy+=slab_height/4) { ph.setPosition(XYZPoint(xx,yy,dist-500)); ph.setDirection(XYZVector(0,0,1)); ph.setWavelength(lambda); list_photon.push_back(ph); } } photons_exist = true; manager->setPhotonList(list_photon,"slab"); } if (ioption==2) { for (double angle1=-30; angle1<30.5; angle1+=5.0) { for (double xx=-0.2*slab_width; xx<=0.21*slab_width; xx+=.40*slab_width) { double yy=0; //for (double lambda1=330; lambda1<631; lambda1+=100) { double angle; double lambda1 = lambda; ph.setPosition(XYZPoint(xx,yy,-500.5)); angle = pi/180.0 * angle1; ph.setDirection(XYZVector(sin(+angle),0,cos(+angle))); ph.setWavelength(lambda1); list_photon.push_back(ph); } } } photons_exist = true; manager->setPhotonList(list_photon,"slab"); } if (ioption==3) { XYZPoint pos(0,-10,-45.0); XYZVector dir(0.0,1,-3); double beta = 0.80; photons_exist = manager->cerenkov(pos,dir,beta,100,200); // generate photons } if (ioption==4) { TRandom ran; for (int ii=0; ii<30; ii++) { ph.setPosition(XYZPoint(0,0,dist-20)); double phi = ran.Uniform(0,2*pi); double costh = ran.Uniform(-1,1); double sinth = sqrt(1-costh*costh); ph.setDirection(XYZVector(sinth*sin(phi),sinth*cos(phi),costh)); ph.setWavelength(lambda); list_photon.push_back(ph); } photons_exist = true; manager->setPhotonList(list_photon,"slab"); } if (ioption==5) { double angle = pi/180.0 * 0; ph.setDirection(XYZVector(0,sin(+angle),cos(+angle))); ph.setPosition(XYZPoint(0,5,-5)); ph.setWavelength(400); list_photon.push_back(ph); ph.setPosition(XYZPoint(0,-5,-5)); ph.setWavelength(400); list_photon.push_back(ph); ph.setPosition(XYZPoint(0,5,-5)); ph.setWavelength(600); list_photon.push_back(ph); ph.setPosition(XYZPoint(0,-5,-5)); ph.setWavelength(600); list_photon.push_back(ph); photons_exist = true; manager->setPhotonList(list_photon,"slab"); } if (ioption==6) { // straight lines. TRandom ran; for (double angle=5; angle<=30.5; angle+=5) { cout<<" angle = "<329; lambda1-=10) { //double lambda1=lambda; // go in x dir double y1 = tan(angle*pi/180); double x1 = y1; double scale = 3/angle; for (double y=-y1; y<= y1; y+= 2*y1/50*scale) { double xx=ran.Uniform(-0.5*slab_width,0.5*slab_width); double yy=ran.Uniform(-0.5*slab_height,0.5*slab_height); ph.setPosition(XYZPoint(0,0,-0.5)); double x = x1; ph.setDirection(XYZVector(x,y,1).Unit()); ph.setWavelength(lambda1); list_photon.push_back(ph); ph.setDirection(XYZVector(-x,y,1).Unit()); ph.setWavelength(lambda1); list_photon.push_back(ph); } for (double x=-x1; x<= x1; x+= 2*y1/50*scale) { double xx=ran.Uniform(-0.5*slab_width,0.5*slab_width); double yy=ran.Uniform(-0.5*slab_height,0.5*slab_height); ph.setPosition(XYZPoint(0,0,-0.5)); double y = y1; ph.setDirection(XYZVector(x,y,1).Unit()); ph.setWavelength(lambda1); list_photon.push_back(ph); ph.setDirection(XYZVector(x,-y,1).Unit()); ph.setWavelength(lambda1); list_photon.push_back(ph); } } } photons_exist = true; manager->setPhotonList(list_photon,"slab"); } if (photons_exist) { manager->propagate(); // propagate photons } list_photon = manager->photonList(); // get list geo<<"}"<SetMarkerStyle(7);"<SetMarkerSize(0.5);"<SetMinimum(-300);"<SetMaximum(+300);"<Draw(\"POL\");"<::iterator iph; DrcPhoton ph_old; double dista,distb; for(iph=list_photon.begin(); iph != list_photon.end(); ++iph) { //(*iph).print(); if ((*iph).fate()==Drc::PhotMeasured) { icnt_measured++; XYZPoint pos = (*iph).position(); //pos -= shift_screen; //pos.Transform(rotInv_screen); double x = pos.X(); double y = pos.Y(); //cout<<" i,p,d="<SetMarkerStyle(7);"<SetMarkerColor(" <<(*iph).colorNumber((*iph).wavelength()) <<");"<SetMarkerSize(0.7);"<Draw();"<