//This is a script to draw the LBCF veto tubes in the 15-minitube stack //currently present in the Tate Laboratory room 256. The goal is to visualize //events which come in there and decide if they correspond to muon tracks //and also analyze their efficiency void displayEv256Setup(){ gROOT->Reset(); c1 = new TCanvas("c1","PolyLine3D & PolyMarker3D Window",200,10,700,700); // create a pad p1 = new TPad("p1","p1",0.1,0.1,0.9,0.9,0,4,1); p1->Draw(); p1->cd(); // creating a view view = TView::CreateView(1); view->SetRange(-48,-48,-48,48,48,48); view->RotateView(90.0,0.0); view->ZoomView(p1,2.0); int colors[15]={2,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; for(int i=0; i<100; i++){ if(i%2==0) *(colors)=1; else *(colors)=2; DrawDet(15,colors); } } TPolyLine3D *makepanel3D(float r, float h, int col){ TPolyLine3D *pan = new TPolyLine3D((6*4+1)); TPolyLine3D *temp = new TPolyLine3D((6*4+1)); //NOTE this function fails if "oldpoints" and "points" //are declared on the same line like Float_t* oldpoints,newpoints; //why? Float_t* oldpoints; Float_t* points; Int_t n,oldn; Float_t x,y,z; pan=makengon3D(r,h,6,col); temp=makengon3D(r,h,6,col); for(int i=0; i<4; i++){ shift(temp,0.0,2*r,0.0); n=temp->GetN(); points=temp->GetP(); oldn=pan->GetN(); oldpoints=pan->GetP(); TPolyLine3D *newline = new TPolyLine3D(n+oldn); //cout << n << " " << oldn << endl; //pan->SetPolyLine(pan->GetN()+1); //npan=pan->GetN(); for(Int_t j=0; jSetPoint(j,*(oldpoints+j*3),*(oldpoints+j*3+1),*(oldpoints+j*3+2)); } for(Int_t j=0; jSetPoint(j+oldn,*(points+j*3),*(points+j*3+1),*(points+j*3+2)); } pan->SetPolyLine(newline->GetN(),newline->GetP()); delete newline; } pan->SetLineColor(col); return pan; } TPolyLine3D *makepanel2D(float r, float h, int col){ TPolyLine3D *pan = new TPolyLine3D(6); //NOTE this function fails if "oldpoints" and "points" //are declared on the same line like Float_t* oldpoints,newpoints; //why? Float_t* oldpoints; Float_t* points; Int_t n,oldn; Float_t x,y,z; float vs=r*cos(3.14159/6.0); float hs=r*sin(3.14159/6.0)+r; int starts[8]={1,3,3,3,4,-1,-1,0}; int stops[8]={4,4,4,6,7,1,1,3}; float shiftsx[8]={0,0,0,0,hs,hs,hs,hs}; float shiftsy[8]={0,-2*vs,-4*vs,-6*vs,-5*vs,-3*vs,-1*vs,1*vs}; float shiftsz[8]={0,0,0,0,0,0,0,0}; pan=makengon2D(r,0.0,6,starts[0],stops[0],col); shift(pan,shiftsx[0],shiftsy[0],shiftsz[0]); for(int i=0; i<7; i++){ TPolyLine3D *temp = new TPolyLine3D(6); temp=makengon2D(r,0.0,6,starts[i+1],stops[i+1],col); shift(temp,shiftsx[i+1],shiftsy[i+1],shiftsz[i+1]); n=temp->GetN(); points=temp->GetP(); oldn=pan->GetN(); oldpoints=pan->GetP(); TPolyLine3D *newline = new TPolyLine3D(n+oldn); //cout << n << " " << oldn << endl; //pan->SetPolyLine(pan->GetN()+1); //npan=pan->GetN(); for(Int_t j=0; jSetPoint(j,*(oldpoints+j*3),*(oldpoints+j*3+1),*(oldpoints+j*3+2)); } for(Int_t j=0; jSetPoint(j+oldn,*(points+j*3),*(points+j*3+1),*(points+j*3+2)); } pan->SetPolyLine(newline->GetN(),newline->GetP()); delete newline; delete temp; } pan->SetLineColor(col); return pan; } TPolyLine3D *makengon3D(float r, float h, int sides, int col){ int nsides = sides-sides%2; //must be even TPolyLine3D *ngon = new TPolyLine3D(nsides*4+1); int p=0; float x,y,z,theta; theta = 0; z=h/2; x=r*cos(theta); y=r*sin(theta); ngon->SetPoint(p,x,y,z); for(int i=0;iSetPoint(p,x,y,z); p++; z *= -1; x=r*cos(theta); y=r*sin(theta); ngon->SetPoint(p,x,y,z); } for(int i=0;iSetPoint(p,x,y,z); p++; theta += 3.14159*2/nsides; x=r*cos(theta); y=r*sin(theta); ngon->SetPoint(p,x,y,z); } ngon->SetLineColor(col); return ngon; } TPolyLine3D *makengon2D(float r, float h, int sides, int start, int stop, int col){ int nsides = sides-sides%2; //must be even if(stopSetPoint(p,x,y,z); for(int i=0;iSetPoint(p,x,y,z); } ngon->SetLineColor(col); int n=ngon->GetN(); Float_t* points=ngon->GetP(); for(int i=0; iGetN(); float x,y,z; for(int p=0;pGetP()[3*p]; y=obj->GetP()[3*p+1]; z=obj->GetP()[3*p+2]; obj->SetPoint(p,x+xs,y+ys,z+zs); } } void zrot(TPolyLine3D *obj, float phi){ int np = obj->GetN(); float x,y,z; for(int p=0;pGetP()[3*p]; y=obj->GetP()[3*p+1]; z=obj->GetP()[3*p+2]; obj->SetPoint(p,cos(phi)*x-sin(phi)*y,sin(phi)*x+cos(phi)*y,z); } } void pastearr(Int_t n, Float_t* a, Int_t m, Float_t* b, Float_t* sum){ int size=n+m; Float_t* newarr[size*3]; newarr = (Float_t*) malloc(3*size*sizeof(Float_t)); for(int i=0;i<3*n;i++) newarr[i]=*(a+i); for(int i=3*n;i<3*size;i++) newarr[i]=*(b+i-3*n); sum=newarr; //free(newarr); return; } void DrawDet(int n,int* col){ int colors[15]; for(int i=0;i<15;i++){ if(n>=i) colors[i]=*(col+i); else colors[i]=1; } TPolyLine3D *tube[15]; // panel thickness // inches float tubeRadius=2.0,tubeLength=48.0; //int colors[15]={2,1,1,1,1,1,1,1,1,1,1,1,1,1,1}; //tube panels for(int i=0; i<15; i++) tube[i]=makepanel2D(tubeRadius,tubeLength,colors[i]); /*tube[0]=makepanel2D(tubeRadius,tubeLength,1); tube[1]=makepanel2D(tubeRadius,tubeLength,1); tube[2]=makepanel2D(tubeRadius,tubeLength,1); tube[3]=makepanel2D(tubeRadius,tubeLength,1); tube[4]=makepanel2D(tubeRadius,tubeLength,1); tube[5]=makepanel2D(tubeRadius,tubeLength,1); tube[6]=makepanel2D(tubeRadius,tubeLength,1); tube[7]=makepanel2D(tubeRadius,tubeLength,1); tube[8]=makepanel2D(tubeRadius,tubeLength,1); tube[9]=makepanel2D(tubeRadius,tubeLength,1); tube[10]=makepanel2D(tubeRadius,tubeLength,1); tube[11]=makepanel2D(tubeRadius,tubeLength,1); tube[12]=makepanel2D(tubeRadius,tubeLength,1); tube[13]=makepanel2D(tubeRadius,tubeLength,1); tube[14]=makepanel2D(tubeRadius,tubeLength,1);*/ float vs=tubeRadius*cos(3.14159/6.0); float hs=tubeRadius*sin(3.14159/6.0)+tubeRadius; // ###### DRAW STUFF ##### //rotate into correct orientation for(int i=0; i<15; i++) zrot(tube[i],(90.0/180.0)*3.14159); float shiftsx[15]={0,-1,-2,-3,-4,0,-1,-2,-3,-4,0,-1,-2,-3,-4}; float shiftsy[15]={0,0,0,0,0,-1,-1,-1,-1,-1,-2,-2,-2,-2,-2}; float shiftsz[15]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; //do overall shift for(int i=0; i<15; i++) shift(tube[i],2*(8*vs),0,0); //add 3% to spacing vs=vs*(1.03); hs=hs*(1.03); //shift each one over by 8*hs for(int i=0; i<15; i++) shift(tube[i],shiftsx[i]*(8*vs),shiftsy[i]*(2*hs),0); /*shift(tube[0],0*(8*vs),0,0); shift(tube[1],-1*(8*vs),0,0); shift(tube[2],-2*(8*vs),0,0); shift(tube[3],-3*(8*vs),0,0); shift(tube[4],-4*(8*vs),0,0);*/ /*tube[0]->Draw(); tube[1]->Draw(); tube[2]->Draw(); tube[3]->Draw(); tube[4]->Draw();*/ for(int i=0; i<15; i++) tube[i]->Draw(); }