//#include //#include //#include #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 "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 "DrcSurfPolyFlat.h" #include "DrcSurfCyl.h" #include "DrcOptReflSilver.h" #include "DrcOptMatAbs.h" #include "DrcOptMatLithotecQ0.h" #include "DrcOptDev.h" #include "DrcOptDevSys.h" #include "DrcOptVol.h" #include "DrcOptMirror.h" #include "DrcOptPixel.h" #include "DrcOptDevManager.h" int main() { //const double pi = 3.1415926535; int verbosity = 0; // 0=quiet, 1=constructors,2=member,3=functionality // 4=photons, 5=everything. // 8 points define a bar XYZPoint p1(-1500.0, 490+8.5, 1000); // p5----------p8 XYZPoint p2(-1500.0, 490-8.5, 1000); // /| /| XYZPoint p3(+1500.0, 490-8.5, 1000); // / | / | XYZPoint p4(+1500.0, 490+8.5, 1000); // / p6-------/--p7 // / / / / // / / / / // / / / / // / / / / XYZPoint p5(-1500.0, 490+8.5, -1000); // p1---------p4 / XYZPoint p6(-1500.0, 490-8.5, -1000); // | / | / XYZPoint p7(+1500.0, 490-8.5, -1000); // |/ |/ XYZPoint p8(+1500.0, 490+8.5, -1000); // p2---------p3 // Define from points 6 surfaces of the bar. The points have to be given in // the sequence going around the surface, clock- or counterclock-wise. // There are 2 additional surfaces, a mirror and a screen. // How to produce surfaces by shift and rotate operation is for sake of clearness // not shown here, but in one of the other examples. // Declare flat surfaces with arbitrary number of points. DrcSurfPolyFlat a1,a2,a3,a4,a5,a6; a1.setVerbosity(verbosity); a1.addPoint(p1); a1.addPoint(p2); a1.addPoint(p3); a1.addPoint(p4); a1.setName("pfront"); a2.setVerbosity(verbosity); a2.addPoint(p2); a2.addPoint(p6); a2.addPoint(p7); a2.addPoint(p3); a2.setName("pside1"); a3.setVerbosity(verbosity); a3.addPoint(p1); a3.addPoint(p5); a3.addPoint(p6); a3.addPoint(p2); a3.setName("pside2"); a4.setVerbosity(verbosity); a4.addPoint(p4); a4.addPoint(p3); a4.addPoint(p7); a4.addPoint(p8); a4.setName("pside3"); a5.setVerbosity(verbosity); a5.addPoint(p1); a5.addPoint(p4); a5.addPoint(p8); a5.addPoint(p5); a5.setName("pside4"); a6.setVerbosity(verbosity); a6.addPoint(p8); a6.addPoint(p7); a6.addPoint(p6); a6.addPoint(p5); a6.setName("pback"); DrcSurfPolyFlat as; as = a6; as.setName("screen_front"); as.setPrintColor(2); // root red // A mirror has two sides, since behind a dichroic mirror a volume or screen // can follow. DrcSurfPolyFlat amf,amb; DrcOptReflSilver refl; amf = a1; amf.setReflectivity(refl); amf.setName("mirror_front"); amf.setPrintColor(4); amb = a1; amb.setName("mirror_back"); amb.setPrintColor(4); // create a volume consiting of surfaces // create a material the bar will consist of DrcOptVol bar; DrcOptMatLithotecQ0 quartz; bar.setVerbosity(verbosity); bar.setOptMaterial(quartz); bar.addSurface(a1); bar.addSurface(a2); bar.addSurface(a3); bar.addSurface(a4); bar.addSurface(a5); bar.addSurface(a6); bar.setName("bar"); // create a screen (simplified photon detector) where photons end and // get the status Drc::Measured (no further propagation). For this you need // one single plane. DrcOptPixel screen; screen.setName("screen"); screen.addSurface(as); screen.setVerbosity(verbosity); DrcOptMirror mirror; mirror.setFrontSurface(amf); mirror.setBackSurface(amb); mirror.setName("mirror"); mirror.setVerbosity(verbosity); // Build a optical system consisting out of several volumes, mirrors and screens. // This layer has the advantage, that a device consisting out of many equal subsystems // like a bar box, easily can be reproduced. See one of the forth comming test examples. DrcOptDevSys opt_system; opt_system.setVerbosity(verbosity); opt_system.addDevice(bar); opt_system.addDevice(screen); opt_system.addDevice(mirror); // couple surface 1 of device 1 with surface 2 of device 2 // dev1 dev2 surf1 surf2 opt_system.coupleDevice("bar","screen","pback","screen_front"); opt_system.coupleDevice("bar","mirror","pfront","mirror_front"); // The manager must be created as pointer. It is created as singleton, that is only // one manager can exist per application. DrcOptDevManager manager; manager.setVerbosity(verbosity); manager.addDeviceSystem(opt_system); fstream geo; geo.open("Geo.C",std::ios::out); geo<<"{"<SetRange(-1000,-1000,-1000,1000,1000,1000);"<SetView(0,90,90,i);"<SetMarkerStyle(20);"<SetMinimum(-100);"<SetMaximum(+100);"<Draw(\"POL\");"<SetMarkerStyle(20);"<SetMinimum(0);"<SetMaximum(50);"<Draw(\"POL\");"< list_photon = manager.photonList(); // get list list::iterator iph; for (iph = list_photon.begin(); iph != list_photon.end(); ++iph) { //cout<<(*iph).fate()<SetMarkerColor(" <<(*iph).colorNumber((*iph).wavelength()) <<");"<SetMarkerSize(0.7);"<Draw();"< pi) phi-=2*pi; //if (phi < -pi) phi+=2*pi; //cout<<(*iph).position().X()<<" "<<(*iph).position().Y()<<" " // <<(*iph).time()<SetMarkerColor(" <<(*iph).colorNumber((*iph).wavelength()) <<");"<SetMarkerSize(0.7);"<Draw();"<