ViewParticle3D Class Reference

#include <ViewParticle3D.h>

Inheritance diagram for ViewParticle3D:
Page

List of all members.

Public Member Functions

 ViewParticle3D ()
 ~ViewParticle3D ()
virtual void BuildDisplay (TCanvas *c)
virtual void DrawEvent (ParticleObjectHolder *poh=0, NtpStRecord *ntp=0, int ntpEvt=-1)
void DrawParticles (ParticleObjectHolder *poh)
void DrawLegend ()
void DrawParticlesDetail (ParticleObjectHolder *poh, PRecord *precord)
void DrawTextLine (std::string text, int ln)

Private Attributes

TH3F * t3
TPad * leg
TPad * main
TPad * detail
double meupergev

Detailed Description

Definition at line 15 of file ViewParticle3D.h.


Constructor & Destructor Documentation

ViewParticle3D::ViewParticle3D (  ) 

Definition at line 15 of file ViewParticle3D.cxx.

References meupergev, and Page::myCanvas.

00015                                :Page()
00016 {
00017         myCanvas=0;
00018 
00019         meupergev = 25.;//rough value... need not be precise here
00020         
00021 }

ViewParticle3D::~ViewParticle3D (  ) 

Definition at line 24 of file ViewParticle3D.cxx.

00025 {}


Member Function Documentation

void ViewParticle3D::BuildDisplay ( TCanvas *  c  )  [virtual]

Reimplemented from Page.

Definition at line 28 of file ViewParticle3D.cxx.

References detail, leg, main, Page::myCanvas, and t3.

Referenced by ParticleDisplay::BuildDisplay().

00029 {
00030         myCanvas=c;
00031         t3 = new TH3F("th3","3D Particles",100,0,100,100,-10,10,100,-10,10);
00032         c->cd();
00033         
00034         main=new TPad("main","main",0,0.05,0.7,1);
00035         leg = new TPad("leg","leg",0,0,0.7,0.05);
00036         detail = new TPad("detail","detail",0.7,0,1,1);
00037         main->Draw();
00038         leg->Draw();
00039         detail->Draw();
00040         
00041         main->cd();
00042         t3->Draw();
00043 }

void ViewParticle3D::DrawEvent ( ParticleObjectHolder poh = 0,
NtpStRecord ntp = 0,
int  ntpEvt = -1 
) [virtual]

Reimplemented from Page.

Definition at line 46 of file ViewParticle3D.cxx.

References ParticlesAna::ana(), detail, DrawLegend(), DrawParticles(), DrawParticlesDetail(), leg, main, Page::myCanvas, PRecord::particles, and t3.

Referenced by ParticleDisplay::UpdateDisplay().

00047 {
00048 
00049         if(!poh)return;
00050  
00051         PRecord * precord = new PRecord();
00052         ParticlesAna pa;
00053         pa.ana(poh,&precord->particles);
00054 
00055 
00056 
00057         if(!myCanvas)return;
00058 
00059         main->cd();
00060         t3->Draw();
00061         DrawParticles(poh);
00062 
00063         leg->cd();
00064         DrawLegend();
00065         
00066         detail->Clear();
00067         detail->cd();
00068         DrawParticlesDetail(poh,precord);
00069         myCanvas->Update();
00070 }

void ViewParticle3D::DrawLegend (  ) 

Definition at line 253 of file ViewParticle3D.cxx.

References leg.

Referenced by DrawEvent().

00254 {
00255 
00256 leg->cd();
00257   //copied Chris' code
00258     TLine *line;
00259     line = new TLine(0.01,0.5,0.04,0.5);
00260     line->SetLineColor(4);
00261     line->SetLineWidth(2);
00262     line->Draw();
00263     line = new TLine(0.11,0.5,0.14,0.5);
00264     line->SetLineColor(3);
00265     line->SetLineWidth(2);
00266     line->Draw();
00267     line = new TLine(0.21,0.5,0.24,0.5);
00268     line->SetLineColor(5);
00269     line->SetLineWidth(2);
00270     line->Draw();
00271     line = new TLine(0.31,0.5,0.34,0.5);
00272     line->SetLineColor(6);
00273     line->SetLineWidth(2);
00274     line->Draw();
00275     line = new TLine(0.41,0.5,0.44,0.5);
00276     line->SetLineColor(2);
00277     line->SetLineWidth(2);
00278     line->Draw();
00279   
00280 
00281 
00282     TLatex *tex;
00283     tex = new TLatex(0.06,0.3,"e");
00284     tex->SetTextFont(132);
00285     tex->SetTextSize(0.7);
00286     tex->Draw();
00287     tex = new TLatex(0.16,0.3,"#mu");
00288     tex->SetTextFont(132);
00289     tex->SetTextSize(0.7);
00290     tex->Draw();
00291     tex = new TLatex(0.26,0.3,"p");
00292     tex->SetTextFont(132);
00293     tex->SetTextSize(0.7);
00294     tex->Draw();
00295     tex = new TLatex(0.36,0.3,"n");
00296     tex->SetTextFont(132);
00297     tex->SetTextSize(0.7);
00298     tex->Draw();
00299     tex = new TLatex(0.46,0.3,"other");
00300     tex->SetTextFont(132);
00301     tex->SetTextSize(0.7);
00302     tex->Draw();
00303 
00304 
00305 }

void ViewParticle3D::DrawParticles ( ParticleObjectHolder poh  ) 

Definition at line 136 of file ViewParticle3D.cxx.

References Particle3D::e, Particle3D::electron, Particle3D::entries, ParticleObjectHolder::event, Munits::m, Particle3D::muon, Particle3D::neutron, ParticleObjectHolder::particles3d, Particle3D::particletype, Particle3D::proton, Particle3D::shared, t3, Particle3D::u, Particle3D::v, ParticleEvent::vtx_u, ParticleEvent::vtx_v, ParticleEvent::vtx_z, and Particle3D::z.

Referenced by DrawEvent().

00137 {
00138         if(!poh)return;
00139 
00140 //      TClonesArray * particles3d = poh->particles3d1;
00141         std::vector<Particle3D>  particles3d = poh->particles3d;
00142 
00143         double u0=10000;
00144         double v0=10000;
00145         double z0=10000;        
00146         double u1=-10000;
00147         double v1=-10000;
00148         double z1=-10000;
00149 
00150 
00151         for(unsigned int i=0;i<particles3d.size();i++)
00152         {
00153                 Particle3D * p3 = (Particle3D *)&particles3d[i];
00154                 if(p3 <=0)continue;
00155                 
00156                 if(p3->entries <1)continue;
00157                 
00158                 TPolyLine3D * line = new TPolyLine3D(p3->entries);
00159                 int color=2;
00160                 if(p3->particletype)
00161                 {
00162                         if(p3->particletype==Particle3D::muon)
00163                         {
00164                                 color=3;
00165                         }
00166                         if(p3->particletype==Particle3D::electron)
00167                         {
00168                                 color=4;
00169                         }
00170                         if(p3->particletype==Particle3D::proton)
00171                         {
00172                                 color=5;
00173                         }
00174                         if(p3->particletype==Particle3D::neutron)
00175                         {
00176                                 color=6;
00177                         }
00178                 }
00179                 
00180                 line->SetLineColor(color);      
00181                 
00182                 for(int j=0;j<p3->entries;j++)
00183                 {
00184                                 line->SetPoint(j,p3->z[j],p3->u[j],p3->v[j]);
00185 
00186 
00187                                 double s = p3->e[j]/100*0.1;
00188                                 TMarker3DBox *m = new TMarker3DBox(p3->z[j],p3->u[j],p3->v[j],s,s,s,0,0);
00189                                 
00190 
00191                                 
00192                                 m->SetFillColor(color);
00193                                 m->SetLineColor(color);
00194                                 
00195                                 if(p3->shared[j]>0)m->SetLineColor(5);
00196                                 
00197                                 m->Draw("same");
00198                         
00199                                 u0 = u0 < p3->u[j] ? u0 :  p3->u[j];
00200                                 v0 = v0 < p3->v[j] ? v0 :  p3->v[j];
00201                                 z0 = z0 < p3->z[j] ? z0 :  p3->z[j];            
00202 
00203                         
00204                                 u1 = u1 > p3->u[j] ? u1 :  p3->u[j];
00205                                 v1 = v1 > p3->v[j] ? v1 :  p3->v[j];
00206                                 z1 = z1 > p3->z[j] ? z1 :  p3->z[j];
00207                 
00208                 }
00209         
00210                 line->Draw();
00211         }
00212 
00213 
00214         double du = (u1-u0)*0.1;
00215         u1+=du;
00216         u0-=du;
00217 
00218         double dv = (v1-v0)*0.1;
00219         v1+=dv;
00220         v0-=dv;
00221 
00222         double dz = (z1-z0)*0.1;
00223         z1+=dz;
00224         z0-=dz;
00225 
00226 
00227 
00228         TMarker3DBox *m = new TMarker3DBox(poh->event.vtx_z, poh->event.vtx_u, poh->event.vtx_v,0.005,0.005,0.005,0,0);
00229         m->SetFillColor(1);
00230         m->SetLineColor(1);
00231         m->Draw("same");
00232 
00233 
00234 
00235 
00236 //      view3d->SetRange(u0,v0,z0,u1,v1,z1);
00237 //      view3d->ShowAxis();
00238 //      view3d->ToggleRulers();
00239         
00240         t3->GetYaxis()->SetRangeUser(u0,u1);
00241         t3->GetZaxis()->SetRangeUser(v0,v1);
00242         t3->GetXaxis()->SetRangeUser(z0,z1);
00243 
00244         t3->SetStats(0);
00245 
00246 
00247 
00248 
00249 
00250 }

void ViewParticle3D::DrawParticlesDetail ( ParticleObjectHolder poh,
PRecord precord 
)

Definition at line 72 of file ViewParticle3D.cxx.

References DrawTextLine(), Particle3D::electron, Particle3D::end_u, Particle3D::end_v, Particle3D::end_z, it, meupergev, Particle3D::muon, Particle3D::neutron, Particle3D::other, PRecord::particles, ParticleObjectHolder::particles3d, Particle3D::particletype, Particle3D::proton, Particle3D::start_u, Particle3D::start_v, Particle3D::start_z, Particle3D::sum_e, and Particles::totvise.

Referenced by DrawEvent().

00073 {
00074         if(!poh)return;
00075 
00076         //TClonesArray * particles3d = poh->particles3d1;
00077         std::vector<Particle3D>  particles3d = poh->particles3d;
00078                 
00079                 
00080         int ln=1;
00081         std::string text="List of particles:";
00082         DrawTextLine(text,ln++);
00083 
00084 
00085         std::map<double,int> emap;
00086         for(unsigned int i=0;i<particles3d.size();i++)
00087         {
00088                 Particle3D * p3 = (Particle3D *)&particles3d[i];
00089                 if(p3 <=0)continue;
00090                 emap.insert(std::pair<double,int>(p3->sum_e,i));
00091         }
00092 
00093         char t[200];    
00094         std::map<double,int>::reverse_iterator it;
00095         for(it=emap.rbegin();it!=emap.rend();it++)
00096         {
00097                 Particle3D * p3 = (Particle3D *)&particles3d[it->second];
00098 
00099                 if(p3->particletype==Particle3D::other)sprintf(t,"Other");
00100                 if(p3->particletype==Particle3D::muon)sprintf(t,"Muon");
00101                 if(p3->particletype==Particle3D::electron)sprintf(t,"Electron");                
00102                 if(p3->particletype==Particle3D::proton)sprintf(t,"Proton");    
00103                 if(p3->particletype==Particle3D::neutron)sprintf(t,"Neutron");  
00104 
00105                 sprintf(t,"%s %2.1f GeV ",t,(p3->sum_e/meupergev));
00106         
00107                 sprintf(t,"%s (%2.1f,%2.1f,%2.1f)",t,p3->start_u,p3->start_v,p3->start_z);
00108                 sprintf(t,"%s (%2.1f,%2.1f,%2.1f)",t,p3->end_u,p3->end_v,p3->end_z);
00109         
00110 
00111                 DrawTextLine(std::string(t),ln++);
00112         }
00113         
00114         DrawTextLine("",ln++);
00115         DrawTextLine("",ln++);
00116         DrawTextLine("Details",ln++);
00117         
00118         if(precord)
00119         {
00120                 sprintf(t,"Total Visible Energy: %2.1f GeV",precord->particles.totvise/meupergev);
00121                 DrawTextLine(std::string(t),ln++);      
00122         }
00123                 
00124 }

void ViewParticle3D::DrawTextLine ( std::string  text,
int  ln 
)

Definition at line 126 of file ViewParticle3D.cxx.

Referenced by DrawParticlesDetail().

00127 {
00128     TLatex *tex;
00129     tex = new TLatex(0,1-ln*0.03,text.c_str());
00130     tex->SetTextFont(132);
00131     tex->SetTextSize(0.05);
00132     tex->Draw();
00133 }       


Member Data Documentation

TPad* ViewParticle3D::detail [private]

Definition at line 32 of file ViewParticle3D.h.

Referenced by BuildDisplay(), and DrawEvent().

TPad* ViewParticle3D::leg [private]

Definition at line 30 of file ViewParticle3D.h.

Referenced by BuildDisplay(), DrawEvent(), and DrawLegend().

TPad* ViewParticle3D::main [private]

Definition at line 31 of file ViewParticle3D.h.

Referenced by BuildDisplay(), and DrawEvent().

double ViewParticle3D::meupergev [private]

Definition at line 34 of file ViewParticle3D.h.

Referenced by DrawParticlesDetail(), and ViewParticle3D().

TH3F* ViewParticle3D::t3 [private]

Definition at line 29 of file ViewParticle3D.h.

Referenced by BuildDisplay(), DrawEvent(), and DrawParticles().


The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1