#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 "PndDrcPhoton.h" #include "PndDrcSurfPolyFlat.h" #include "PndDrcOptReflSilver.h" #include "PndDrcOptMatLithotecQ0.h" #include "PndDrcOptDevSys.h" #include "PndDrcOptVol.h" #include "PndDrcOptDevManager.h" int main(int argc, char *argv[]) { // Example for a simple bar with screen (photon detection) and mirror. int verbosity = 0; // 0=quiet, 1=constructors,2=member,3=functionality // 4=photons, 5=everything. // 8 points define a bar XYZPoint p1(-15.0, +8.5, 1100); // p5----------p8 XYZPoint p2(-15.0, -8.5, 1100); // /| /| XYZPoint p3(+15.0, -8.5, 1100); // / | / | XYZPoint p4(+15.0, +8.5, 1100); // / p6-------/--p7 // / / / / // / / / / // / / / / // / / / / XYZPoint p5(-15.0, +8.5, -800); // p1---------p4 / XYZPoint p6(-15.0, -8.5, -800); // | / | / XYZPoint p7(+15.0, -8.5, -800); // |/ |/ XYZPoint p8(+15.0, +8.5, -800); // 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. PndDrcOptReflSilver refl; // Declare flat surfaces with arbitrary number of points. PndDrcSurfPolyFlat a1,a2,a3,a4,a5,a6; a1.SetVerbosity(verbosity); a1.SetReflectivity(refl); // this acts as a mirror a1.AddPoint(p1); a1.AddPoint(p2); a1.AddPoint(p3); a1.AddPoint(p4); a1.SetName("adown"); a2.SetVerbosity(verbosity); a2.AddPoint(p2); a2.AddPoint(p6); a2.AddPoint(p7); a2.AddPoint(p3); a2.SetName("aside1"); a3.SetVerbosity(verbosity); a3.AddPoint(p1); a3.AddPoint(p5); a3.AddPoint(p6); a3.AddPoint(p2); a3.SetName("aside2"); a4.SetVerbosity(verbosity); a4.AddPoint(p4); a4.AddPoint(p3); a4.AddPoint(p7); a4.AddPoint(p8); a4.SetName("aside3"); a5.SetVerbosity(verbosity); a5.AddPoint(p1); a5.AddPoint(p4); a5.AddPoint(p8); a5.AddPoint(p5); a5.SetName("aside4"); a6.SetVerbosity(verbosity); a6.AddPoint(p8); a6.AddPoint(p7); a6.AddPoint(p6); a6.AddPoint(p5); a6.SetPixel(); // this acts as a screen a6.SetPrintColor(2); a6.SetName("aup"); // create a volume consiting of surfaces // create a material the bar will consist of PndDrcOptVol bar; PndDrcOptMatLithotecQ0 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"); PndDrcOptDevSys opt_system; opt_system.SetVerbosity(verbosity); opt_system.AddDevice(bar); // 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->SetVerbosity(verbosity); 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 XYZPoint pos(0,-10,0); XYZVector dir(0,1,1); double beta = 0.89; double range=500; bool photons_exist = manager->Cerenkov(pos,dir,beta); // generate photon //bool photons_exist = manager->Cerenkov(pos,dir,beta,100,range,400,650); // generate photons //bool photons_exist = manager->Cerenkov(pos,dir,beta,100,range,400,405); // generate photons cout<<" photons exist: "<Propagate(); // propagate photons } list list_photon = manager->PhotonList(); // get list // propagate writes to geo, that has finished, therefore, close geo geo<<"}"<SetMarkerStyle(20);"<SetMinimum(-40);"<SetMaximum(40);"<SetMinimum(-100);"<SetMaximum(+100);"<Draw(\"POL\");"< dir_list; double time400[200]={200*0}; double time600[200]={200*0}; fstream out1; out1.open("debug.dat",std::ios::out); list::iterator iph; for(iph=list_photon.begin(); iph != list_photon.end(); ++iph) { if ((*iph).Fate()==Drc::kPhotMeasured) { dir_list.push_back((*iph).Direction()); icnt_measured++; double rx = (*iph).Position().X(); double ry = (*iph).Position().Y(); double rz = (*iph).Position().Z(); double x = (*iph).Direction().X(); double y = (*iph).Direction().Y(); double z = (*iph).Direction().Z(); double theta = atan2(sqrt(x*x+y*y),fabs(z)); double phi = atan2(y,x); double r = theta; double xx = r*cos(phi)*180/3.1415; double yy = r*sin(phi)*180/3.1415; double time = (*iph).Time(); double lambda = (*iph).Wavelength(); //if (xx<1 && xx>-1) { if (lambda<450 && lambda>400) time400[int(time*10)]++; if (lambda<650 && lambda>600) time600[int(time*10)]++; } double scale = 300.0/z; double sx = x*scale; double sy = y*scale; double sz = z*scale; rx += sx; ry += sy; out1<SetMarkerColor(" <<(*iph).ColorNumber((*iph).Wavelength()) <<");"<SetMarkerSize(0.7);"<Draw();"<