#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 "PndDrcOptReflGray.h" #include "PndDrcOptMatLithotecQ0.h" #include "PndDrcOptDevSys.h" #include "PndDrcOptVol.h" #include "PndDrcOptDevManager.h" #include "PndDrcOptBrick.h" #include "PndDrcOptLens.h" int main(int argc, char *argv[]) { // Example for a simple bar with screen (photon detection) and mirror. enum OPTION {Cherenkov,Point,Squares1,Squares2,Line}; // normal Cherenkov, focus test, squares, squares OPTION opt; opt = Line; PndDrcOptReflGray refl; refl.SetReflProb(0.99); PndDrcOptBrick bar1(17,17.5/2,500); bar1.SetOptMaterial(PndDrcOptMatLithotecQ0()); bar1.SetName("bar1"); bar1.Surface("side2")->SetReflectivity(refl); bar1.Surface("side3")->SetReflectivity(refl); bar1.Surface("side4")->SetReflectivity(refl); bar1.Surface("side5")->SetReflectivity(refl); PndDrcOptBrick bar2(17,17.5/2,500); bar2.SetOptMaterial(PndDrcOptMatLithotecQ0()); bar2.SetName("bar2"); //bar2.Surface("side1")->SetPixel(); bar2.Surface("side2")->SetReflectivity(refl); bar2.Surface("side3")->SetReflectivity(refl); bar2.Surface("side4")->SetReflectivity(refl); bar2.Surface("side5")->SetReflectivity(refl); bar1.AddTransform(Transform3D(XYZVector(0,0, 500))); // shift by half length bar2.AddTransform(Transform3D(XYZVector(0,0,-500))); // define an expansion volume with limitin points in z-y: // // p3a // / | // / | // / | y // p2a | ^ // | | | // p1a------p4a z <--0 // // the left side will be connected to the quartz bar the right side will be the pixel. // // // seen from -z it looks like // // p3a----p3b Y // | | ^ // | | | // | | x <--0 // | | // | | // p4a----p4b XYZPoint p1a(-300, -30,-1000); XYZPoint p1b(+300, -30,-1000); XYZPoint p2a(-300, +30,-1000); XYZPoint p2b(+300, +30,-1000); XYZPoint p3a(-300,+500,-1300); XYZPoint p3b(+300,+500,-1300); XYZPoint p4a(-300, -30,-1300); XYZPoint p4b(+300, -30,-1300); PndDrcSurfPolyFlat a1,a2,a3,a4,a5,a6; a1.SetName("side-z"); a1.AddPoint(p4a); a1.AddPoint(p4b); a1.AddPoint(p3b); a1.AddPoint(p3a); a1.SetPrintColor(2); // paint it in red a1.SetPixel(); // pixel a2.SetName("side+z"); a2.AddPoint(p1a); a2.AddPoint(p1b); a2.AddPoint(p2b); a2.AddPoint(p2a); a3.SetName("side+x"); a3.AddPoint(p1a); a3.AddPoint(p4a); a3.AddPoint(p3a); a3.AddPoint(p2a); a4.SetName("side-x"); a4.AddPoint(p1b); a4.AddPoint(p4b); a4.AddPoint(p3b); a4.AddPoint(p2b); a5.SetName("side+y"); a5.AddPoint(p2a); a5.AddPoint(p3a); a5.AddPoint(p3b); a5.AddPoint(p2b); a6.SetName("side-y"); a6.AddPoint(p1a); a6.AddPoint(p4a); a6.AddPoint(p4b); a6.AddPoint(p1b); // create from surfaces the volume PndDrcOptVol ex_box; PndDrcOptMatLithotecQ0 quartz; ex_box.SetOptMaterial(quartz); ex_box.AddSurface(a1); ex_box.AddSurface(a2); ex_box.AddSurface(a3); ex_box.AddSurface(a4); ex_box.AddSurface(a5); ex_box.AddSurface(a6); ex_box.SetName("expansion_box"); // create a focussing mirror at the downstream side // with width like quartz bar, length 40mm // the focusing distance is 1000+1000+300mm => radius = 4600mm PndDrcOptLens mirror(17,17.5/2,40,9999,4700); // focussing (corrected by hand) //PndDrcOptLens mirror(17,17.5/2,40,9999,4600); // focussing //PndDrcOptLens mirror(17,17.5/2,40,9999,9999); // non focussing mirror.SetOptMaterial(PndDrcOptMatLithotecQ0()); // // // p16---------p26 // /| side6 /| // / | / | // / p46-------/-p36 Y // p1-----------p2 / ^ Z side46 // / | / /| / | / side56 side36 // / |/ / |/ |/ side26 // / p4-------/--p3 X <---0 // p11---------p21 / // | /side1 | / side41 // |/ |/ side51 side31 // p41---------p31 side21 mirror.SetName("mirror"); mirror.Surface("side6")->SetReflectivity(PndDrcOptReflSilver()); // the mirror mirror.AddTransform(Transform3D(XYZVector(0,0, 1000+40))); // shift by half length + 200mm bar length mirror.Surface("side21")->SetReflectivity(refl); mirror.Surface("side26")->SetReflectivity(refl); mirror.Surface("side31")->SetReflectivity(refl); mirror.Surface("side36")->SetReflectivity(refl); mirror.Surface("side41")->SetReflectivity(refl); mirror.Surface("side46")->SetReflectivity(refl); mirror.Surface("side51")->SetReflectivity(refl); mirror.Surface("side56")->SetReflectivity(refl); mirror.SetPrintColor(2); PndDrcOptDevSys opt_system; opt_system.AddDevice(bar1); opt_system.AddDevice(bar2); opt_system.AddDevice(ex_box); opt_system.AddDevice(mirror); // couple surface 1 of device 1 with surface 2 of device 2 // dev1 dev2 surf1 surf2 opt_system.CoupleDevice("mirror","bar1", "side1","side6"); opt_system.CoupleDevice("bar1", "bar2", "side1","side6"); opt_system.CoupleDevice("bar1", "bar2", "side1","side6"); opt_system.CoupleDevice("bar2", "expansion_box","side1","side+z"); // 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); fstream geo; geo.open("Geo.C",std::ios::out); geo<<"{"<GetVersionInt() < 51600) { geo<<" TView *view = new TView(1);"<SetRange(-50,-50,-50,50,50,50);"<SetView(0,90,90,i);"<Print(geo); // // the intention is to play around with routines. // create a list of photons in bar bool photons_exist = false; list list_photon; // get list if (opt==Cherenkov) { XYZPoint pos(0,-20,50); XYZVector dir(0,1.45,2.3);//(0,1.45,2.3) double beta = 0.80; photons_exist = manager->Cerenkov(pos,dir,beta,10000,1e16,400,405); // generate photons //photons_exist = manager->Cerenkov(pos,dir,beta); // generate photons } else if (opt==Point) { PndDrcPhoton ph; for (double xx=-15; xx<=+15; xx+=2) { for (double yy=-7; yy<=7; yy+=2) { ph.SetPosition(XYZPoint(xx,yy,10)); ph.SetDirection(XYZVector(0,0,+1)); ph.SetWavelength(650); list_photon.push_back(ph); } } photons_exist = true; manager->SetPhotonList(list_photon,"bar1"); } else if (opt==Squares1) { PndDrcPhoton ph; int n=100; for (double angle=0.1; angle<0.5; angle +=0.1) { double dist = sin(angle/180*6.28); for (int i=0; iSetPhotonList(list_photon,"bar1"); } else if (opt==Squares2) { PndDrcPhoton ph; int n=10; double angle = 0.1; //for (double angle=0.1; angle<0.5; angle +=0.1) //{ double dist = sin(angle/180*6.28); for (int ipos=0; ipos<4; ipos++) { if (ipos==0) ph.SetPosition(XYZPoint(-5,0,10)); if (ipos==1) ph.SetPosition(XYZPoint(+5,0,10)); if (ipos==2) ph.SetPosition(XYZPoint(0,-5,10)); if (ipos==3) ph.SetPosition(XYZPoint(0,5,10)); for (int i=0; iSetPhotonList(list_photon,"bar1"); } else if (opt==Line) { PndDrcPhoton ph; int n=10000; double angle = 40; double dist = sin(angle/180*6.28); ph.SetPosition(XYZPoint(0,0,10)); for (int i=0; iSetPhotonList(list_photon,"bar1"); } else { cerr<<" wrong option"<Propagate(); // propagate photons list_photon = manager->PhotonList(); // get list cout<<" photons in list : "<SetMarkerStyle(20);"<SetMarkerStyle(20);"<SetMinimum(-100);"<SetMaximum(500);"<Draw(\"POL\");"<::iterator iph; for(iph=list_photon.begin(); iph != list_photon.end(); ++iph) { if ((*iph).Fate()==Drc::kPhotMeasured) { icnt_measured++; double rx = (*iph).Position().X(); double ry = (*iph).Position().Y(); int irefl = (*iph).Reflections()-1; // -1 for mirror cout<max) max=irefl; if (ireflSetMarkerColor(" <SetMarkerSize(0.6);"<Draw();"<