#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 "TROOT.h" #include "TRint.h" #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 "PndDrcSurfAbs.h" #include "PndDrcPhoton.h" #include "PndDrcSurfPolyFlat.h" #include "PndDrcOptReflSilver.h" #include "PndDrcOptReflPerfect.h" #include "PndDrcOptReflGeffcken.h" #include "PndDrcOptMatLithotecQ0.h" #include "PndDrcOptMatMarcol7.h" #include "PndDrcOptMatVacuum.h" #include "PndDrcOptDevSys.h" #include "PndDrcOptVol.h" #include "PndDrcOptDevManager.h" #include "PndDrcOptBrick.h" #include "PndDrcOptCylLens.h" #include "PndDrcOptLens.h" int main(int argc, char *argv[]) { static const double kPi=3.1415926535; // Example for a simple sheet with lens and expansion box. //--------------------------------------------------------- //int focus_option = 0; // nothing //int focus_option = 1; // lens //int focus_option = 2; // focussing downstream spherical mirror int focus_option = 3; // focussing downstream cylindrical mirror int ioption = 1; // 1=cherenkov, 2=testbeam int top_option = 0; // 0 with expansion volume, 1 without expandsion volume // top_option=1 writes times versus x into the Screen.C file. //int coating = true; int coating = false; // don't turn on... double half_width = 200.0 /2; //mm double half_thick = 17.0 /2; //mm double half_length = 2500.0 /2; //mm //--------------------------------------------------------- // ex_box=300mm + 10mm air gap => // for air filled box radius = 310mm = 1/(1.47-1) R // R = 310 * 0.47 = 145.7 // // the medium in the box enhances the focal length to 300mm *1.47 // therefore use a focal length // of 145.7/1.47 = 99.1 // or more precise: R = (300/1.47 + 10) *0.47 = 100.6 // mirror: // create a focussing mirror at the downstream side // with width like quartz bar, length 40 mm // the focusing distance is 2500+300 mm => radius = 5600 mm //double lens_radius = 99999.9; // mm double lens_radius = 100.6; // mm double mirror_radius = 5600; if (top_option==1) mirror_radius = 5000; // only radiator bar PndDrcOptDevSys opt_system; PndDrcOptBrick sheet(half_width,half_thick,half_length); sheet.SetOptMaterial(PndDrcOptMatLithotecQ0()); sheet.SetName("sheet"); // move sheet such into positive z space such that end of sheet is at z=0 sheet.AddTransform(Transform3D(XYZVector(0,0,half_length))); //sheet.SetVerbosity(5); if (top_option==1) sheet.Surface("side1")->SetPixel(); // time of propagation // downstream mirror if (focus_option == 0 || focus_option == 1) { sheet.Surface("side6")->SetReflectivity(PndDrcOptReflSilver()); } opt_system.AddDevice(sheet); if (focus_option == 2) // spherical downstream mirror { PndDrcOptLens mirror(half_width,half_thick,10/2,9999,mirror_radius); // spherical mirror mirror.SetOptMaterial(PndDrcOptMatLithotecQ0()); mirror.SetName("mirror"); mirror.Surface("side6")->SetReflectivity(PndDrcOptReflSilver()); // the mirror mirror.AddTransform(Transform3D(XYZVector(0,0, 2*half_length+10/2))); mirror.SetPrintColor(2); opt_system.AddDevice(mirror); opt_system.CoupleDevice("mirror","sheet", "side1","side6"); } if (focus_option == 3) // cylindrical downstream mirror { // x=thick y=width --> will be later rotated by pi/2 PndDrcOptCylLens mirror(half_thick,half_width,10/2,9999,mirror_radius); mirror.SetOptMaterial(PndDrcOptMatLithotecQ0()); mirror.SetName("mirror"); mirror.Surface("side6")->SetReflectivity(PndDrcOptReflSilver()); // the mirror mirror.AddTransform(Transform3D(XYZVector(0,0, 2*half_length+10/2))); mirror.AddTransform(Transform3D(RotationZ(-kPi/2))); mirror.SetPrintColor(2); opt_system.AddDevice(mirror); opt_system.CoupleDevice("mirror","sheet", "side1","side6"); } // upstream cylindrical lens... or not // create two adjacent lenses, one made of quartz and one made of air. // and embedd the into sheet. // since the curvature is around the y-axis, create it rotated by 90 degree and rotate it back double lens_body_hthick = 5.0; if (focus_option == 1) { PndDrcOptCylLens lens_quartz(half_thick,half_width,lens_body_hthick,lens_radius,99999.9); lens_quartz.SetOptMaterial(PndDrcOptMatLithotecQ0()); lens_quartz.AddTransform(Transform3D(XYZVector(0,0,-lens_body_hthick))); lens_quartz.AddTransform(Transform3D(RotationZ(kPi/2))); lens_quartz.SetName("lens_quartz"); lens_quartz.SetPrintColor(2); if (coating) lens_quartz.Surface("side1")->SetReflectivity(PndDrcOptReflGeffcken()); //lens_quartz.SetVerbosity(5); opt_system.AddDevice(lens_quartz); PndDrcOptCylLens lens_air(half_thick,half_width,lens_body_hthick,99999.9,-lens_radius); lens_air.AddTransform(Transform3D(XYZVector(0,0,-(2+1)*lens_body_hthick))); lens_air.AddTransform(Transform3D(RotationZ(kPi/2))); //lens_air.SetOptMaterial(PndDrcOptMatVacuum()); lens_air.SetOptMaterial(PndDrcOptMatVacuum()); lens_air.SetName("lens_air"); lens_air.SetPrintColor(4); //lens_air.SetVerbosity(5); //if (lens_air.Surface("side6")) lens_air.Surface("side6")->SetVerbosity(5); lens_air.Surface("side56")->SetPrintColor(5); lens_air.Surface("side51")->SetPrintColor(5); opt_system.AddDevice(lens_air); // make the air gap extent larger than the lens PndDrcOptBrick addition_top(2*half_thick,half_width,lens_body_hthick); addition_top.SetOptMaterial(PndDrcOptMatVacuum()); addition_top.SetName("addition_top"); addition_top.SetPrintColor(4); PndDrcOptBrick addition_bot(addition_top); addition_bot.SetName("addition_bot"); addition_top.AddTransform(Transform3D(XYZVector(3*half_thick,0,-(2+1)*lens_body_hthick))); addition_top.AddTransform(Transform3D(RotationZ(kPi/2))); addition_bot.AddTransform(Transform3D(XYZVector(-3*half_thick,0,-(2+1)*lens_body_hthick))); addition_bot.AddTransform(Transform3D(RotationZ(kPi/2))); opt_system.AddDevice(addition_top); opt_system.AddDevice(addition_bot); // couple surface 1 of device 1 with surface 2 of device 2 // dev1 dev2 surf1 surf2 opt_system.CoupleDevice("sheet" ,"lens_quartz" ,"side1", "side6"); opt_system.CoupleDevice("lens_quartz" ,"lens_air" ,"side1", "side6"); opt_system.CoupleDevice("addition_top" ,"lens_air", "side3", "side56"); opt_system.CoupleDevice("addition_top" ,"lens_air", "side3", "side51"); opt_system.CoupleDevice("addition_bot" ,"lens_air", "side5", "side36"); opt_system.CoupleDevice("addition_bot" ,"lens_air", "side5", "side31"); } // expansion box double ex_box_hw = 300; double ex_box_ht = 300; double ex_box_hl = 150; PndDrcOptBrick ex_box(ex_box_hw,ex_box_ht,ex_box_hl); ex_box.SetOptMaterial(PndDrcOptMatMarcol7()); ex_box.SetName("expansion box"); //ex_box.Surface("side6")->SetPixel(); if (focus_option==1) { ex_box.AddTransform(Transform3D(XYZVector(0,0,-ex_box_hl-(2+2)*lens_body_hthick))); } else { ex_box.AddTransform(Transform3D(XYZVector(0,0,-ex_box_hl))); } ex_box.Surface("side1")->SetPixel(); if (coating) ex_box.Surface("side6")->SetReflectivity(PndDrcOptReflGeffcken()); opt_system.AddDevice(ex_box); if (focus_option==1) { opt_system.CoupleDevice("lens_air" ,"expansion box","side1", "side6"); opt_system.CoupleDevice("addition_top" ,"expansion box","side1", "side6"); opt_system.CoupleDevice("addition_bot" ,"expansion box","side1", "side6"); } else { opt_system.CoupleDevice("sheet" ,"expansion box","side1", "side6"); } // The manager must be created as pointer. // It is created as singleton, that is only // one manager can exist per application. PndDrcOptDevManager* manager = new PndDrcOptDevManager(); manager->AddDeviceSystem(opt_system); // enable geometry print into Geo.C // fstream geo; geo.open("Geo.C",std::ios::out); geo<<"{"<GetVersionInt() < 51600) { geo<<" TView *view = new TView(1);"<SetRange(-1000,-1000,-1000,3000,3000,3000);"<SetView(0,90,90,i);"<Print(geo); // // the intention is to play around with routines. // there hast to come another geo output after propagation... // manager->Print(); // print out to screen everything... // create a list of photons in sheet XYZPoint pos(0,-half_thick-10.0,half_length); XYZVector dir(0,1,1); double beta = 0.80;//0.684; bool photons_exist = false; if (ioption==1) { photons_exist = manager->Cerenkov(pos,dir,beta,100000); // generate photons } else { PndDrcPhoton ph; ph.SetReflectionLimit(200); list list_photon; int imax=20; // rays in one dimension for (int ix=0; ixDevice("sheet")); //ph.SetSeed(); list_photon.push_back(ph); } } } photons_exist=true; manager->SetPhotonList(list_photon,"sheet"); } if (photons_exist) manager->Propagate(); // propagate photons geo<<"}"<SetStats(0);"<SetMarkerStyle(20);"<SetMinimum(-500);"<SetMaximum(500);"<Draw(\"POL\");"< list_photon = manager->PhotonList(); // get list //fstream out; //out.open("debug.dat",std::ios::out); //int icnt1=0; int icnt_measured = 0; int icnt_flying = 0; int icnt_lost = 0; int icnt_absorbed = 0; list::iterator iph; for(iph=list_photon.begin(); iph != list_photon.end(); ++iph) { if ((*iph).Fate()==Drc::kPhotMeasured) { icnt_measured++; double xx=(*iph).Position().X(); double yy; if (top_option==1) { yy=(*iph).Time(); } else { yy=(*iph).Position().Y(); } scr<<" TMarker* t = new TMarker("<SetMarkerColor(" <<(*iph).ColorNumber((*iph).Wavelength()) <<");"<SetMarkerSize(0.2);"<Draw();"<