void Statistics::GenerateTimingHistogram(){ ScintillatorPlane topPlane(2,8,"Top-Plane"); ScintillatorPlane bottomPlane(2,8,"Bottom-Plane"); int nxbins = 1000; int xlow = 20000; int xhigh = 21000; int nybins = 150; int ylow = -10; int yhigh = 140; Channel *trig = 0; Channel *ch = 0; TCanvas *c2 = new TCanvas("c2", "Timing-Info", 200, 10, 700, 500); c2->Divide(1, 1); c2->cd(1); Tree t("6133.root", "BSC_DATA_TREE"); int numOfEvents = t.GetNumOfEvents(); // TH1F *hTrig = new TH1F("hTrig","TEST",100,20000,21000); TH2F *h2d = new TH2F("h2d", "Timing", nxbins, xlow, xhigh, nybins, ylow, yhigh); std::vector<Scintillator*> scintPlane = topPlane.GetScintillatorPlane(); for (int evNo = 0; evNo < numOfEvents; evNo++) { trig = t.GetEntry("Module2_LE_CH31", evNo); h2d->Fill(trig->at(0), 31); //for (int i = 0; i < fScintillatorPlane.size(); i++) { for (int i = 0; i < scintPlane.size(); i++) { ch = t.GetEntry(scintPlane[i]->GetName(), evNo); if (ch->size()) { for (int j = 0; j < ch->size(); j++) { h2d->Fill(ch->at(j), scintPlane[i]->GetChannelId()); } } } } scintPlane = bottomPlane.GetScintillatorPlane(); for (int evNo = 0; evNo < numOfEvents; evNo++) { for (int i = 0; i < scintPlane.size(); i++) { ch = t.GetEntry(scintPlane[i]->GetName(), evNo); if (ch->size()) { for (int j = 0; j < ch->size(); j++) { h2d->Fill(ch->at(j), scintPlane[i]->GetChannelId()); } } } } h2d->Draw(); h2d->Print(); // TFile f("hTrig.root","recreate"); //Open file, then write histo to it. TFile::Open("hTrig.root", "RECREATE"); h2d->Write(); c2->Modified(); c2->Update(); }
Frustum<float> Camera::getFrustum() const { float hnear, wnear; float hfar, wfar; hnear = 2 * tanf(fov / 2) * nearDist; wnear = hnear * ratio; hfar = 2 * tanf(fov / 2) * farDist; wfar = hfar * ratio; vector3f farCenter = front * farDist; vector3f nearCenter = front * nearDist; vector3f right = cross(front, up); //tworzę wierzchołki vector3f ftl = farCenter + (up * hfar / 2) - (right * wfar / 2); vector3f ftr = farCenter + (up * hfar / 2) + (right * wfar / 2); vector3f fbl = farCenter - (up * hfar / 2) - (right * wfar / 2); vector3f fbr = farCenter - (up * hfar / 2) + (right * wfar / 2); vector3f ntl = nearCenter + (up * hnear / 2) - (right * wnear / 2); vector3f ntr = nearCenter + (up * hnear / 2) + (right * wnear / 2); vector3f nbl = nearCenter - (up * hnear / 2) - (right * wnear / 2); vector3f nbr = nearCenter - (up * hnear / 2) + (right * wnear / 2); //tworzę płaszczyzny plane<float> nearPlane(nearCenter, front); plane<float> farPlane(farCenter, -front); plane<float> rightPlane(vector3f(0, 0, 0), cross(up, (nearCenter + right * wnear / 2).normalized())); plane<float> leftPlane(vector3f(0, 0, 0), cross((nearCenter - right * wnear / 2).normalized(), up)); plane<float> topPlane(vector3f(0, 0, 0), cross((nearCenter + up * hnear / 2).normalized(), right)); plane<float> bottomPlane(vector3f(0, 0, 0), cross(right, (nearCenter - up * hnear / 2).normalized())); /* tu może być komszmarnie dużo błędów, to najbardziej "ludzki" fragment kodu top=3 | v 7___________________6 /: /| / : / | / : / | / : / | /__________________/ | 4| : 5| | 4=left->| : | | <- right =5 | : far=\ | | | : rear=1 | | | :.............|....| | . 3 | / 2 | . | / | . | / |. front=0=near |/ |__________________/ 0 1 ^ | bottom=2 */ std::vector < plane < float >> planes; std::vector < vector3f> vertices; std::vector<Polyhedron<float>::PolyhedronEdge> edges; //KOLEJNOŚĆ ŚCIAN MA ZNACZENIE! #define pp(_plane) planes.push_back(_plane) pp(nearPlane); pp(farPlane); pp(bottomPlane); pp(topPlane); pp(leftPlane); pp(rightPlane); #undef pp //KOLEJNOŚĆ WIERZCHOŁKÓW MA ZNACZENIE! #define pv(_vert) vertices.push_back(_vert) pv(nbl); pv(nbr); pv(fbr); pv(fbl); pv(ntl); pv(ntr); pv(ftr); pv(ftl); #undef pv //kolejność krawędzi nie ma znaczenia #define pe(v1, v2, p1, p2) edges.push_back(Polyhedron<float>::PolyhedronEdge(v1, v2, p1, p2)) pe(0, 1, 2, 0); //bottom-front pe(1, 2, 2, 5); //bottom-right pe(2, 3, 2, 1); //bottom-far pe(3, 0, 2, 4); //bottom-left pe(0, 4, 4, 0); //left-front pe(1, 5, 0, 5); //front-right pe(2, 6, 5, 1); //right-far pe(3, 7, 1, 4); //far-left pe(4, 5, 0, 3); //front-top pe(5, 6, 5, 3); //right-top pe(6, 7, 1, 3); //far-top pe(7, 4, 4, 3); //left-top #undef pe return Frustum<float>(planes, vertices, edges, vector3f(0, 0, 0)); }