/** * Create output objects */ void UserCreateOutputObjects() { fList = new TList; fList->SetOwner(); fList->SetName("triggerSums"); // Double_t mb[] = { 0, 1, 2, 3, 4, 5, 6, 8, 9, 10, 11 }; // Int_t nM = 10; TAxis eAxis(200, -4, 6); TAxis pAxis(40, 0, 2*TMath::Pi()); fData = new TH2D("data", "Cache", eAxis.GetNbins(), eAxis.GetXmin(), eAxis.GetXmax(), pAxis.GetNbins(), pAxis.GetXmin(), pAxis.GetXmax()); fData->SetDirectory(0); fData->SetXTitle("#eta"); fData->SetYTitle("#varphi [radians]"); fData->SetZTitle("N_{ch}(#eta,#varphi)"); fData->Sumw2(); fM = new TH1D("m", "Distribution of N_{ch}|_{|#eta|<1}", kMaxN+1,0,kMaxN+1); fM->SetXTitle("N_{ch}|_{|#eta|<1}"); fM->SetYTitle("Events"); fM->SetFillColor(kRed+1); fM->SetFillStyle(3001); fM->SetDirectory(0); fList->Add(fM); for (Int_t i = 0; i <= kMaxN; i++) { TString lbl; if (i == 0) lbl = "all"; else if (i == kMaxN) lbl = Form("%d+",i-1); else lbl = Form("<%d",i); fM->GetXaxis()->SetBinLabel(i+1, lbl); } fTriggers = new TH1I("triggers", "Triggers", 8, -.5, 7.5); fTriggers->SetDirectory(0); fTriggers->GetXaxis()->SetBinLabel(1, "INEL (MC)"); fTriggers->GetXaxis()->SetBinLabel(2, "INEL (ESD)"); fTriggers->GetXaxis()->SetBinLabel(3, "INEL & N_{cluster}>0 (MC)"); fTriggers->GetXaxis()->SetBinLabel(4, "INEL & N_{cluster}>0 (ESD)"); fTriggers->GetXaxis()->SetBinLabel(5, "INEL>0 (MC)"); fTriggers->GetXaxis()->SetBinLabel(6, "INEL>0 (ESD)"); fTriggers->GetXaxis()->SetBinLabel(7, "NSD (MC)"); fTriggers->GetXaxis()->SetBinLabel(8, "NSD (ESD)"); fTriggers->SetFillColor(kYellow+1); fTriggers->SetFillStyle(3001); fList->Add(fTriggers); fVertexESD = new TH1D("vertexESD", "ESD vertex distribution", fVertexAxis.GetNbins(), fVertexAxis.GetXmin(), fVertexAxis.GetXmax()); fVertexESD->SetDirectory(0); fVertexESD->SetFillColor(kRed+1); fVertexESD->SetFillStyle(3001); fVertexESD->SetXTitle("v_{z} [cm]"); fVertexESD->SetYTitle("P(v_{z})"); fList->Add(fVertexESD); fVertexMC = new TH1D("vertexMC", "MC vertex distribution", fVertexAxis.GetNbins(), fVertexAxis.GetXmin(), fVertexAxis.GetXmax()); fVertexMC->SetDirectory(0); fVertexMC->SetFillColor(kBlue+1); fVertexMC->SetFillStyle(3001); fVertexMC->SetXTitle("v_{z} [cm]"); fVertexMC->SetYTitle("P(v_{z})"); fList->Add(fVertexMC); fInel.CreateObjects(fList, fM, fData); fInelGt0.CreateObjects(fList, fM, fData); fNSD.CreateObjects(fList, fM, fData); fNClusterGt0.CreateObjects(fList, fM, fData); fInspector.DefineOutput(fList); fInspector.Init(fVertexAxis); PostData(1, fList); }
void POVRayExport::exportParticle(std::ofstream& os, const shared_ptr<Particle>& p){ const auto sphere=dynamic_cast<Sphere*>(p->shape.get()); const auto capsule=dynamic_cast<Capsule*>(p->shape.get()); const auto ellipsoid=dynamic_cast<Ellipsoid*>(p->shape.get()); const auto wall=dynamic_cast<Wall*>(p->shape.get()); const auto infCyl=dynamic_cast<InfCylinder*>(p->shape.get()); const auto facet=dynamic_cast<Facet*>(p->shape.get()); // convenience const auto& n0(p->shape->nodes[0]); if(sphere) os<<"sphere{ o, "<<sphere->radius<<" "<<makeTexture(p)<<" "<<node2pov(n0)<<" }"; else if(capsule) os<<"sphere_sweep{ linear_spline, 2, <"<<-.5*capsule->shaft<<",0,0> ,"<<capsule->radius<<", <"<<.5*capsule->shaft<<",0,0> ,"<<capsule->radius<<" "<<makeTexture(p)<<" "<<node2pov(n0)<<" }"; else if(ellipsoid) os<<"sphere{ o, 1 scale "<<vec2pov(ellipsoid->semiAxes)<<" "<<makeTexture(p)<<" "<<node2pov(n0)<<" }"; else if(wall){ if((wall->glAB.isEmpty())){ os<<"plane{ "<<Vector3r::Unit(wall->axis)<<", "<<wall->nodes[0]->pos[wall->axis]; } else{ // quad, as mesh2 Vector3r a; a[wall->axis]=wall->nodes[0]->pos[wall->axis]; Vector3r b(a), c(a), d(a); short ax1((wall->axis+1)%3), ax2((wall->axis+2)%3); a[ax1]=wall->glAB.min()[0]; a[ax2]=wall->glAB.min()[1]; b[ax1]=wall->glAB.min()[0]; b[ax2]=wall->glAB.max()[1]; c[ax1]=wall->glAB.max()[0]; c[ax2]=wall->glAB.min()[1]; d[ax1]=wall->glAB.max()[0]; d[ax2]=wall->glAB.max()[1]; os<<"mesh2{ vertex_vectors { 4 "<<vec2pov(a)<<", "<<vec2pov(b)<<", "<<vec2pov(c)<<", "<<vec2pov(d)<<" } face_indices { 2, <0,2,1>, <1,2,3> }"; } os<<makeTexture(p,wallTexture)<<" }"; // will use the default if wallTexture is empty } else if(infCyl){ if(isnan(infCyl->glAB.maxCoeff())){ // infinite cylinder, use quadric for this Vector3r abc=Vector3r::Ones(); abc[infCyl->axis]=0; os<<"quadric{ "<<vec2pov(abc)<<", <0,0,0>, <0,0,0>, -1 "<<makeTexture(p)<<" "<<node2pov(n0)<<" }"; } else { #if 0 #endif // base point (global coords), first center Vector3r pBase(n0->pos); pBase[infCyl->axis]+=infCyl->glAB[0]; // axis vector (global coords), pBase+pAxis is the second center Vector3r pAxis(Vector3r::Zero()); pAxis[infCyl->axis]=infCyl->glAB[1]-infCyl->glAB[0]; // axial rotation; warn if not around the axis AngleAxisr aa(n0->ori); Vector3r axRotVecDeg(aa.axis()*aa.angle()*180./M_PI); if(aa.angle()>1e-6 && abs(aa.axis()[infCyl->axis])<.999999) LOG_WARN("#"<<p->id<<": InfCylinder rotation not aligned with its axis (cylinder axis "<<infCyl->axis<<"; rotation axis "<<aa.axis()<<", angle "<<aa.angle()<<")"); bool open=!cylCapTexture.empty(); if(open){ os<<"/*capped cylinder*/"; Vector3r normal=Vector3r::Unit(infCyl->axis); for(int i:{-1,1}){ os<<"disc{ o, "<<vec2pov(i*normal)<<", "<<infCyl->radius<<" "<<makeTexture(p,cylCapTexture)<<" rotate "<<vec2pov(axRotVecDeg)<<" translate "<<vec2pov(i<0?pBase:(pBase+pAxis).eval()); os<<" }"; } } // length of the cylinder Real cylLen=(infCyl->glAB[1]-infCyl->glAB[0]); // non-axial rotation, from +x cyl to infCyl->axis (case-by-case) Vector3r nonAxRotVec=(infCyl->axis==0?Vector3r::Zero():(infCyl->axis==1?Vector3r(0,0,90):Vector3r(0,-90,0))); // cylinder spans +x*cylLen from origin, then rotated, so that the texture is rotated as well os<<"cylinder{ o, <"<<cylLen<<",0,0>, "<<infCyl->radius<<(open?" open ":" ")<<" "<<makeTexture(p)<<" rotate "<<vec2pov(nonAxRotVec)<<" rotate "<<vec2pov(axRotVecDeg)<<" translate "<<vec2pov(pBase)<<" }"; } } else if(facet){ // halfThick ignored for now, as well as connectivity if(facet->halfThick>0){ Vector3r dp=facet->getNormal()*facet->halfThick; const Vector3r& a(facet->nodes[0]->pos); const Vector3r& b(facet->nodes[1]->pos); const Vector3r& c(facet->nodes[2]->pos); os<<"merge{ sphere_sweep{ linear_spline, 4 "<<vec2pov(a)<<", "<<facet->halfThick<<", "<<vec2pov(b)<<", "<<facet->halfThick<<", "<<vec2pov(c)<<", "<<facet->halfThick<<", "<<vec2pov(a)<<", "<<facet->halfThick<<" } triangle{"<<vec2pov(a+dp)<<", "<<vec2pov(b+dp)<<", "<<vec2pov(c+dp)<<" } triangle {"<<vec2pov(a-dp)<<", "<<vec2pov(b-dp)<<", "<<vec2pov(c-dp)<<" } "<<makeTexture(p)<<" }"; } else { os<<"triangle{ "<<vec2pov(facet->nodes[0]->pos)<<", "<<vec2pov(facet->nodes[1]->pos)<<", "<<vec2pov(facet->nodes[2]->pos)<<" "<<makeTexture(p)<<" }"; } } os<<" // id="<<p->id<<endl; }