#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::list; #include using std::map; #include using std::pair; #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 "DrcOptReflSilver.h" #include "DrcOptMatAbs.h" #include "DrcOptMatLithotecQ0.h" #include "DrcOptDev.h" #include "DrcOptDevSys.h" #include "DrcOptVol.h" #include "DrcOptPixel.h" #include "DrcOptMirror.h" #include "DrcOptDevManager.h" int main() { // Example for a simple bar with screen (photon detection) and mirror. //int number_photons = 50; int verbosity = 0; // 0=quiet, 1=constructors,2=member,3=functionality // 4=photons, 5=everything. // create one segment of a disk and reprocuce the other. // // y // | // | // | // 8 7 | // p4-----------------p3 | // \ / 0-----------x // \ / / // \ / / // \ / / // \ 5 / 6 z // p1-----p2 // const int nsegs = 12; // Number of segments double dist_z1 = 200;//mm // distance from beam axis (=z) double dist_z2 = 700;//mm // outer distance from beam. double angle = 2*3.1415926/nsegs; XYZPoint p1(-dist_z1*tan(angle/2), dist_z1, 200); XYZPoint p2(+dist_z1*tan(angle/2), dist_z1, 200); XYZPoint p3(+dist_z2*tan(angle/2), dist_z2, 200); XYZPoint p4(-dist_z2*tan(angle/2), dist_z2, 200); XYZPoint p5(-dist_z1*tan(angle/2), dist_z1, 210); XYZPoint p6(+dist_z1*tan(angle/2), dist_z1, 210); XYZPoint p7(+dist_z2*tan(angle/2), dist_z2, 210); XYZPoint p8(-dist_z2*tan(angle/2), dist_z2, 210); DrcSurfPolyFlat pfront; //pfront.setVerbosity(4); pfront.addPoint(p1); pfront.addPoint(p2); pfront.addPoint(p3); pfront.addPoint(p4); pfront.setName("pfront"); DrcSurfPolyFlat pback(pfront); // construct from pfront pback.setVerbosity(verbosity); Transform3D trans1(XYZVector(0,0,+10)); pback.addTransform(trans1);// and shift it pback.setName("pback"); //DrcSurfPolyFlat pback; //pfront.setVerbosity(4); //pback.addPoint(p5); //pback.addPoint(p6); //pback.addPoint(p7); //pback.addPoint(p8); //pback.setName("pback"); DrcSurfPolyFlat pbottom; pbottom.addPoint(p1); pbottom.addPoint(p2); pbottom.addPoint(p6); pbottom.addPoint(p5); pbottom.setName("pbottom"); DrcSurfPolyFlat ptop; ptop.addPoint(p4); ptop.addPoint(p3); ptop.addPoint(p7); ptop.addPoint(p8); ptop.setName("ptop"); DrcSurfPolyFlat pleft; pleft.setVerbosity(verbosity); pleft.addPoint(p1); pleft.addPoint(p5); pleft.addPoint(p8); pleft.addPoint(p4); pleft.setName("pleft"); DrcSurfPolyFlat pright; pright.setVerbosity(verbosity); pright.addPoint(p2); pright.addPoint(p6); pright.addPoint(p7); pright.addPoint(p3); pright.setName("pright"); DrcOptVol psegment; DrcOptMatLithotecQ0 quartz; psegment.setOptMaterial(quartz); psegment.addSurface(pfront); psegment.addSurface(pback); psegment.addSurface(pbottom); psegment.addSurface(ptop); psegment.addSurface(pleft); psegment.addSurface(pright); psegment.setName("segment"); psegment.setVerbosity(verbosity); DrcOptPixel pscreen; DrcSurfPolyFlat ps(ptop); ps.setName("screen_surf"); ps.setPrintColor(2); // red pscreen.addSurface(ps); pscreen.setName("screen"); DrcSurfPolyFlat amf(pbottom); amf.setName("mirror_front"); amf.setPrintColor(4); // blue DrcSurfPolyFlat amb(pbottom); amb.setName("mirror_back"); amb.setPrintColor(4); // blue DrcOptMirror pmirror; pmirror.setFrontSurface(amf); pmirror.setBackSurface(amb); pmirror.setName("mirror"); DrcOptDevSys psystem; psystem.addDevice(psegment); psystem.addDevice(pscreen); psystem.addDevice(pmirror); psystem.coupleDevice("segment","screen","ptop","screen_surf"); psystem.coupleDevice("segment","mirror","pbottom","mirror_front"); psystem.setName("sys_segment"); DrcOptDevManager manager; // reproduce the system nsegs times (system = segment + mirror) DrcOptDevSys psys[nsegs]; for (int i=0; iSetRange(-500,-500,-500,500,500,500);"<SetView(0,90,90,i);"< list_photon; DrcPhoton ph; ph.setPosition(XYZPoint(0,300,205)); ph.setDirection(XYZVector(-2,1,0)); ph.setWavelength(500); list_photon.push_back(ph); bool photons_exist = true; manager.setPhotonList(list_photon,"segment",0); */ XYZPoint pos(0,0,0); XYZVector dir(0,2,2); bool photons_exist = manager.cerenkov(pos,dir.Unit(),0.99); // generate photons //bool photons_exist = (photons_exist1 || photons_exist2 || // photons_exist3 || photons_exist4); if (photons_exist) { fstream scr; scr.open("Screen.C",std::ios::out); scr<<"{"<SetMarkerStyle(20);"<SetMinimum(-100);"<SetMaximum(+100);"<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();"<