Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

GfxShower Class Reference

Graphical representation of a CandShower. More...

#include <GfxShower.h>

List of all members.

Public Member Functions

 GfxShower (const CandShowerHandle &cth, GfxShowerList &parent)
 GfxShower (const GfxShower &rhs)
 ~GfxShower ()
void Clear (Option_t *="")
void Configure ()
void ExecuteEvent (int event, int px, int py)
void Paint (Option_t *option="")
int DistancetoPrimitive (int px, int py)
const CandShowerHandleGetShower ()
Int_t GetColor ()

Private Member Functions

GfxShoweroperator= (const GfxShower &)
int GetCandShowerData (float *u, float *v, float *x, float *y, float *z, float *q, float *t, int *strip_number, int *plane_number)
bool BuildRealImp ()
bool BuildDiscreteImp ()

Private Attributes

const CandShowerHandlefShower
GfxShowerListfParent
TObject * fImp
Int_t fColor


Detailed Description

Graphical representation of a CandShower.

Id
GfxShower.h,v 1.5 2004/04/13 18:04:49 gmieg Exp

EVD

Contact: bv@bnl.gov

Created on: Wed Oct 2 15:43:48 2002

Definition at line 25 of file GfxShower.h.


Constructor & Destructor Documentation

GfxShower::GfxShower const CandShowerHandle cth,
GfxShowerList parent
 

Definition at line 27 of file GfxShower.cxx.

00028     : fShower(cth)
00029     , fParent(parent)
00030     , fImp(0)
00031 {
00032 //    cerr << "Creating GfxShower with " << cth.GetNDaughters() << " strips\n";
00033 }

GfxShower::GfxShower const GfxShower rhs  ) 
 

Definition at line 35 of file GfxShower.cxx.

00036     : TObject()
00037       ,fShower(rhs.fShower), fParent(rhs.fParent), fImp(0)
00038 {
00039 }

GfxShower::~GfxShower  ) 
 

Definition at line 42 of file GfxShower.cxx.

References Clear().

00043 {
00044   this->Clear();
00045 }


Member Function Documentation

bool GfxShower::BuildDiscreteImp  )  [private]
 

Definition at line 300 of file GfxShower.cxx.

References done(), fColor, fImp, fParent, fShower, PlexSEIdAltL::GetBestItem(), EVD::GetCandEvent(), GetCandShowerData(), CandRecoHandle::GetCandSlice(), EVD::GetCandSlice(), CandHandle::GetDaughterIterator(), GfxShowerList::GetEVD(), EVD::GetGhostColor(), GfxBase::GetGraphicsView(), CandEventHandle::GetLastShower(), CandHandle::GetNDaughters(), PlexPlaneId::GetPlane(), CandStripHandle::GetPlaneView(), GfxBase::GetPlaneView(), CandDigitHandle::GetPlexSEIdAltL(), PlexSEIdAltLItem::GetSEId(), CandEventHandle::GetShower(), PlexStripEndId::GetStrip(), CandRecoHandle::GetVtxPlane(), CandRecoHandle::GetVtxU(), CandRecoHandle::GetVtxV(), and CandHandle::IsCloneOf().

Referenced by Configure().

00300                                 {
00301   double cx,cy,dx,dy;
00302   int      n = fShower.GetNDaughters();
00303   
00304   // using new [] here causes bizzare segv in unrelated parts of the
00305   // code, so lets get all FORTRAN about it.
00306   const int maxstrips = 10000;
00307   int strip[maxstrips], plane[maxstrips];
00308   float q[maxstrips];
00309   float x[maxstrips],y[maxstrips];
00310   int vtxColor=28;
00311   int shwrStripColor=46;
00312   fColor=vtxColor;
00313   if(fParent.GetEVD()->GetCandEvent()){
00314     Bool_t found=false;
00315     CandEventHandle * ev = fParent.GetEVD()->GetCandEvent();
00316     Int_t nShowers = ev->GetLastShower()+1;
00317     for (Int_t it=0;it<nShowers;it++){
00318       const CandShowerHandle * evshw = ev->GetShower(it);
00319       if(evshw->IsCloneOf(fShower))found=true;
00320     }
00321     if(!found){
00322       vtxColor=fParent.GetEVD()->GetGhostColor();
00323       shwrStripColor=fParent.GetEVD()->GetGhostColor();
00324       fColor=fParent.GetEVD()->GetGhostColor();
00325     }
00326   }
00327   else    if(fParent.GetEVD()->GetCandSlice()){
00328     CandSliceHandle slc1 =  *(fParent.GetEVD()->GetCandSlice());
00329     CandSliceHandle slc2;
00330     if(fShower.GetCandSlice())slc2=*(fShower.GetCandSlice());
00331     if(slc1!=slc2 && !slc1.IsCloneOf(slc2)){
00332       vtxColor=fParent.GetEVD()->GetGhostColor();
00333       shwrStripColor=fParent.GetEVD()->GetGhostColor();
00334       fColor=fParent.GetEVD()->GetGhostColor();
00335     }
00336   }
00337 
00338  
00339     TList* shower = new TList;
00340     shower->SetOwner();
00341 
00342     int ind;
00343 
00344     if(fParent.GetGraphicsView() != GraphicsView::kXY && 
00345        fParent.GetGraphicsView() != GraphicsView::kUV)
00346       {
00347         n = this->GetCandShowerData(0,0,0,0,0,q,0,strip,plane);
00348         if (n > maxstrips) n = maxstrips;
00349         
00350         map<int,float> mean_strip, norm_strip;
00351         for (ind = 0; ind < n; ++ind) {
00352           if (mean_strip.find(plane[ind]) == mean_strip.end()) {
00353             mean_strip[plane[ind]] = 0;
00354             norm_strip[plane[ind]] = 0;
00355           }
00356           mean_strip[plane[ind]] += strip[ind]*q[ind];
00357           norm_strip[plane[ind]] += q[ind];
00358         }
00359         int vtx_plane = fShower.GetVtxPlane();
00360         int vtx_ind = -1;
00361         
00362         map<int,float>::iterator it, done = mean_strip.end();
00363         for (ind=0, it = mean_strip.begin(); it != done && n < maxstrips; ++it, ++ind) {
00364           int plane = it->first;
00365           float qstrip = it->second;
00366           float norm = norm_strip[plane];
00367           x[ind] = plane;
00368           y[ind] = qstrip/norm;
00369           if (plane == vtx_plane) {
00370             vtx_ind = ind;
00371             //            cerr << Form("vertex: %d: plane=%.0f strip=%.1f\n",ind,x[ind],y[ind]);
00372           }
00373         }
00374         if(vtx_ind>-1 && vtx_ind<=ind){
00375           TMarker * Vx = new TMarker(x[vtx_ind],y[vtx_ind],29);
00376           Vx->SetMarkerSize(1);
00377           Vx->SetMarkerColor(vtxColor);
00378         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00379         if (att_line) att_line->SetLineWidth(1);
00380           shower->Add(Vx);
00381         }       
00382       }
00383 
00384     else if(fParent.GetGraphicsView() == GraphicsView::kXY) 
00385       {                     
00386         ind = this->GetCandShowerData(0,0,x,y,0,0,0,0,plane);
00387         float vx =  0.70710678*(fShower.GetVtxU()-fShower.GetVtxV());
00388         float vy =  0.70710678*(fShower.GetVtxU()+fShower.GetVtxV());
00389         TMarker * Vx = new TMarker(vx,vy,29);
00390         Vx->SetMarkerSize(1);
00391         Vx->SetMarkerColor(vtxColor);
00392         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00393         if (att_line) att_line->SetLineWidth(1);
00394         shower->Add(Vx);
00395     }
00396     else if(fParent.GetGraphicsView() == GraphicsView::kUV) 
00397       {                     
00398         ind = this->GetCandShowerData(y,x,0,0,0,0,0,0,plane);
00399         float vx = fShower.GetVtxV();
00400         float vy = fShower.GetVtxU();
00401         TMarker * Vx = new TMarker(vx,vy,29);
00402         Vx->SetMarkerSize(1);
00403         Vx->SetMarkerColor(vtxColor);
00404         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00405         if (att_line) att_line->SetLineWidth(1);
00406         shower->Add(Vx);
00407 
00408     }
00409 
00410  
00411     TIter titr(fShower.GetDaughterIterator());
00412     PlaneView::PlaneView_t view = fParent.GetPlaneView();
00413     GraphicsView::GraphicsView_t gview = fParent.GetGraphicsView();
00414     ind=0;
00415     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(titr())) 
00416       {
00417         if (csh->GetPlaneView() == view)
00418           {
00419             if(gview !=GraphicsView::kXY && gview !=GraphicsView::kUV)
00420               { 
00421                 
00422                 TIter digitItr(csh->GetDaughterIterator());
00423                 while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())) {
00424                   
00425 
00426                   cx = cdh->GetPlexSEIdAltL().GetBestItem().GetSEId().GetPlane();
00427                   cy = cdh->GetPlexSEIdAltL().GetBestItem().GetSEId().GetStrip();
00428                   dx = .5;
00429                   dy = .5;
00430                   TEllipse* box = new TEllipse(cx,cy,dx,dy);
00431                  
00432                   box->SetFillColor(2);
00433                   shower->Add(box);
00434                   
00435                 }
00436               }
00437             else
00438               {
00439 
00440                 for(int i=0;i<ind;i++){
00441        
00442                   cx = x[i];
00443                   cy = y[i];
00444                   dx = 0.5;
00445                   dy = 0.5;
00446                   TEllipse* box = new TEllipse(cx,cy,dx,dy);
00447                   box->SetFillColor(shwrStripColor);
00448                   shower->Add(box);
00449                 }
00450                 
00451               }
00452           }
00453       }
00454 
00455 
00456     fImp = shower;
00457 
00458     return true;
00459 }

bool GfxShower::BuildRealImp  )  [private]
 

Definition at line 151 of file GfxShower.cxx.

References fColor, fImp, fParent, fShower, PlexSEIdAltL::GetBestItem(), EVD::GetCandEvent(), GetCandShowerData(), CandRecoHandle::GetCandSlice(), EVD::GetCandSlice(), CandHandle::GetDaughterIterator(), GfxShowerList::GetEVD(), EVD::GetGhostColor(), GfxBase::GetGraphicsView(), UgliStripHandle::GetHalfThickness(), UgliStripHandle::GetHalfWidth(), CandEventHandle::GetLastShower(), CandHandle::GetNDaughters(), CandStripHandle::GetPlaneView(), GfxBase::GetPlaneView(), CandDigitHandle::GetPlexSEIdAltL(), PlexSEIdAltLItem::GetSEId(), CandEventHandle::GetShower(), UgliStripHandle::GetTPos(), CandHandle::GetVldContext(), CandRecoHandle::GetVtxU(), CandRecoHandle::GetVtxV(), CandRecoHandle::GetVtxZ(), UgliStripHandle::GlobalPos(), CandHandle::IsCloneOf(), and UgliStripHandle::IsValid().

Referenced by Configure().

00151                             {
00152   float *x=0, *y=0;
00153   int *plane_number;
00154   int npoints=0;
00155   
00156   int vtxColor=28;
00157   int shwrStripColor=46;
00158   fColor=vtxColor;
00159   
00160   if(fParent.GetEVD()->GetCandEvent()){
00161     Bool_t found=false;
00162     CandEventHandle * ev = fParent.GetEVD()->GetCandEvent();
00163     Int_t nShowers = ev->GetLastShower()+1;
00164     for (Int_t it=0;it<nShowers;it++){
00165       const CandShowerHandle * evshw = ev->GetShower(it);
00166       if(evshw->IsCloneOf(fShower))found=true;
00167     }
00168     if(!found){
00169       vtxColor=fParent.GetEVD()->GetGhostColor();
00170       shwrStripColor=fParent.GetEVD()->GetGhostColor();
00171       fColor=fParent.GetEVD()->GetGhostColor();
00172     }
00173   }
00174   else  if(fParent.GetEVD()->GetCandSlice()){
00175     CandSliceHandle slc1 =  *(fParent.GetEVD()->GetCandSlice());
00176     CandSliceHandle slc2;
00177     if(fShower.GetCandSlice())slc2=*(fShower.GetCandSlice());
00178     if(slc1!=slc2 && !slc1.IsCloneOf(slc2)){
00179       vtxColor=fParent.GetEVD()->GetGhostColor();
00180       shwrStripColor=fParent.GetEVD()->GetGhostColor();
00181       fColor=fParent.GetEVD()->GetGhostColor();
00182     }
00183   }
00184 
00185     double cx,cy,dx,dy;
00186     int n = fShower.GetNDaughters();
00187     x = new float[n];
00188     y = new float[n];
00189     
00190     plane_number = new int[n];
00191     TList* shower = new TList;
00192     shower->SetOwner();
00193     double vx, vy;
00194 
00195     if (fParent.GetGraphicsView() == GraphicsView::kUZ) {
00196         vx = fShower.GetVtxZ();
00197         vy = fShower.GetVtxU();
00198 
00199         TMarker * Vx = new TMarker(vx,vy,29);
00200         Vx->SetMarkerSize(1);
00201         Vx->SetMarkerColor(vtxColor);
00202         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00203         if (att_line) att_line->SetLineWidth(1);
00204         shower->Add(Vx); 
00205    }
00206     else if(fParent.GetGraphicsView() == GraphicsView::kVZ) 
00207       {                      // kV
00208         vx = fShower.GetVtxZ();
00209         vy = fShower.GetVtxV();
00210         TMarker * Vx = new TMarker(vx,vy,29);
00211         Vx->SetMarkerSize(1);
00212         Vx->SetMarkerColor(vtxColor);
00213         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00214         if (att_line) att_line->SetLineWidth(1);
00215         shower->Add(Vx); 
00216     }
00217     else if(fParent.GetGraphicsView() == GraphicsView::kXY) 
00218       {                     
00219         npoints = this->GetCandShowerData(0,0,x,y,0,0,0,0,plane_number);
00220         vx =  0.70710678*(fShower.GetVtxU()-fShower.GetVtxV());
00221         vy =  0.70710678*(fShower.GetVtxU()+fShower.GetVtxV());
00222         TMarker * Vx = new TMarker(vx,vy,29);
00223         Vx->SetMarkerSize(1);
00224         Vx->SetMarkerColor(vtxColor);
00225         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00226         if (att_line) att_line->SetLineWidth(1);
00227         shower->Add(Vx); 
00228     }
00229     else if(fParent.GetGraphicsView() == GraphicsView::kUV) 
00230       {                     
00231         npoints = this->GetCandShowerData(y,x,0,0,0,0,0,0,plane_number);
00232         vx = fShower.GetVtxV();
00233         vy = fShower.GetVtxU();
00234         TMarker * Vx = new TMarker(vx,vy,29);
00235         Vx->SetMarkerSize(1);
00236         Vx->SetMarkerColor(vtxColor);
00237         TAttLine* att_line = dynamic_cast<TAttLine*>(Vx);
00238         if (att_line) att_line->SetLineWidth(1);
00239         shower->Add(Vx);
00240     }
00241  
00242     TIter titr(fShower.GetDaughterIterator());
00243     PlaneView::PlaneView_t view = fParent.GetPlaneView();
00244     GraphicsView::GraphicsView_t gview = fParent.GetGraphicsView();
00245     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(titr())) 
00246       {
00247         if (csh->GetPlaneView() == view)
00248           {
00249             if(gview !=GraphicsView::kXY && gview !=GraphicsView::kUV)
00250               {                 
00251                 TIter digitItr(csh->GetDaughterIterator());
00252                 while (CandDigitHandle *cdh = dynamic_cast<CandDigitHandle*>(digitItr())) {
00253                   
00254                   UgliGeomHandle ugh(*cdh->GetVldContext());
00255                   UgliStripHandle ush;
00256                   
00257                   ush = ugh.GetStripHandle(cdh->GetPlexSEIdAltL().GetBestItem().GetSEId());
00258                   
00259                   if (!ush.IsValid()) return false;
00260                   
00261                   cx = ush.GlobalPos(0).Z();
00262                   cy = ush.GetTPos();
00263                   dx = 1.25*ush.GetHalfThickness();
00264                   dy = 1.25*ush.GetHalfWidth();
00265                   TEllipse* box = new TEllipse(cx,cy,dx,dy);
00266                   box->SetFillColor(shwrStripColor);
00267                   box->SetLineColor(shwrStripColor);
00268                   shower->Add(box);
00269                   
00270                 }
00271               }
00272             else
00273               {
00274 
00275                 for(int i=0;i<npoints;i++){
00276        
00277                   cx = x[i];
00278                   cy = y[i];
00279                   dx = 0.01;
00280                   dy = 0.01;
00281                   TEllipse* box = new TEllipse(cx,cy,dx,dy);
00282                   box->SetFillColor(shwrStripColor);
00283                   box->SetLineColor(shwrStripColor);
00284                   shower->Add(box);
00285                 }
00286                 
00287               }
00288           }
00289       }
00290 
00291     fImp = shower;
00292 
00293     delete [] x;
00294     delete [] y;
00295     delete [] plane_number;
00296 
00297     return true;
00298 }

void GfxShower::Clear Option_t *  = ""  ) 
 

Definition at line 47 of file GfxShower.cxx.

References fImp.

Referenced by ~GfxShower().

00048 {
00049   if (fImp) delete fImp; fImp=0;
00050 }

void GfxShower::Configure  ) 
 

Definition at line 51 of file GfxShower.cxx.

References BuildDiscreteImp(), BuildRealImp(), fImp, fParent, ViewState::GetSpatialMetric(), and GfxBase::GetViewState().

00052 {
00053 
00054     if (fImp) { delete fImp; fImp = 0; }
00055 
00056 
00057     switch (fParent.GetViewState()->GetSpatialMetric()) {
00058     case ViewState::metric_is_continuous:
00059         if (! this->BuildRealImp()) return;
00060         break;
00061     case ViewState::metric_is_discreet: default:
00062         if (! this->BuildDiscreteImp()) return;
00063         break;
00064     }
00065 
00066 }

int GfxShower::DistancetoPrimitive int  px,
int  py
 

Definition at line 471 of file GfxShower.cxx.

References fImp.

00472 {
00473     int dist = 0xdead;
00474     if (fImp) {
00475         TList* l = dynamic_cast<TList*>(fImp);
00476         if (!l) 
00477             dist = fImp->DistancetoPrimitive(px,py);
00478         else {
00479             TIter next(l);
00480             TObject* obj;
00481             while ((obj=next())) {
00482                 int d = obj->DistancetoPrimitive(px,py);
00483                 if (d < dist) dist = d;
00484             }
00485         }
00486     }
00487     return dist;
00488 }

void GfxShower::ExecuteEvent int  event,
int  px,
int  py
 

Definition at line 461 of file GfxShower.cxx.

References GfxShowerList::ExecuteEvent(), and fParent.

00462 {
00463     fParent.ExecuteEvent(event,px,py,this);
00464 }

int GfxShower::GetCandShowerData float *  u,
float *  v,
float *  x,
float *  y,
float *  z,
float *  q,
float *  t,
int *  strip_number,
int *  plane_number
[private]
 

Definition at line 68 of file GfxShower.cxx.

References fParent, fShower, CandStripHandle::GetCorrBegTime(), CandHandle::GetDaughterIterator(), CandShowerHandle::GetEnergy(), GfxBase::GetGraphicsView(), CandStripHandle::GetPlane(), CandStripHandle::GetPlaneView(), GfxBase::GetPlaneView(), CandStripHandle::GetStrip(), CandStripHandle::GetTPos(), CandShowerHandle::GetU(), CandShowerHandle::GetV(), and CandStripHandle::GetZPos().

Referenced by BuildDiscreteImp(), and BuildRealImp().

00073 {
00074     TIter titr(fShower.GetDaughterIterator());
00075     PlaneView::PlaneView_t view = fParent.GetPlaneView();
00076     GraphicsView::GraphicsView_t gview = fParent.GetGraphicsView();
00077 
00078     int ind=0;
00079     titr.Reset();
00080     while (CandStripHandle* csh = dynamic_cast<CandStripHandle*>(titr())) {
00081 
00082       if(csh->GetPlaneView() == view ||
00083           gview == GraphicsView::kUV || gview == GraphicsView::kXY) 
00084         {
00085                 
00086           int plane = csh->GetPlane();
00087           if (plane_number) {
00088             plane_number[ind] = plane;
00089           }
00090           if (strip_number) {
00091             strip_number[ind] = csh->GetStrip();
00092           }
00093           if (u){
00094             if(csh->GetPlaneView() == PlaneView::kV)
00095               {
00096                 u[ind]=csh->GetTPos();
00097               }
00098             else
00099               {
00100                 u[ind] = fShower.GetU(plane);
00101               }
00102           }
00103           if (v) {
00104             if(csh->GetPlaneView() == PlaneView::kU)
00105               {
00106                 v[ind]=csh->GetTPos();
00107               }
00108             else
00109               {
00110                 u[ind] = fShower.GetV(plane);
00111               }
00112 
00113           }
00114           if (x) {
00115             if(csh->GetPlaneView() == PlaneView::kV)
00116               {
00117                 x[ind] = 0.70710678*(fShower.GetU(plane)-csh->GetTPos());
00118               }
00119             else
00120               {
00121                 x[ind] = 0.70710678*(csh->GetTPos()-fShower.GetV(plane));
00122               }
00123            
00124           }
00125           if (y) {
00126             if(csh->GetPlaneView() == PlaneView::kV)
00127               {
00128                 y[ind] = 0.70710678*(fShower.GetU(plane)+csh->GetTPos());
00129               }
00130             else
00131               {
00132                 y[ind] = 0.70710678*(csh->GetTPos()+fShower.GetV(plane));
00133               }
00134            
00135           }
00136           if (z) {
00137             z[ind] = csh->GetZPos();
00138           }
00139           if (t) {
00140             t[ind] = csh->GetCorrBegTime();
00141           }
00142           if (q) {
00143             q[ind] = fShower.GetEnergy();
00144           }     
00145           ++ind;
00146         }
00147     }
00148     return ind;
00149 }

Int_t GfxShower::GetColor  )  [inline]
 

Definition at line 43 of file GfxShower.h.

00043 {return fColor;}

const CandShowerHandle& GfxShower::GetShower  )  [inline]
 

Definition at line 42 of file GfxShower.h.

Referenced by GfxShowerList::ExecuteEvent().

00042 { return fShower; }

GfxShower& GfxShower::operator= const GfxShower  )  [private]
 

void GfxShower::Paint Option_t *  option = ""  ) 
 

Definition at line 465 of file GfxShower.cxx.

References fImp, and option.

00466 {
00467     if (!fImp) return;
00468 
00469     fImp->Paint(option);
00470 }


Member Data Documentation

Int_t GfxShower::fColor [private]
 

Definition at line 59 of file GfxShower.h.

Referenced by BuildDiscreteImp(), and BuildRealImp().

TObject* GfxShower::fImp [private]
 

Definition at line 57 of file GfxShower.h.

Referenced by BuildDiscreteImp(), BuildRealImp(), Clear(), Configure(), DistancetoPrimitive(), and Paint().

GfxShowerList& GfxShower::fParent [private]
 

Definition at line 56 of file GfxShower.h.

Referenced by BuildDiscreteImp(), BuildRealImp(), Configure(), ExecuteEvent(), and GetCandShowerData().

const CandShowerHandle& GfxShower::fShower [private]
 

Definition at line 55 of file GfxShower.h.

Referenced by BuildDiscreteImp(), BuildRealImp(), and GetCandShowerData().


The documentation for this class was generated from the following files:
Generated on Thu Nov 1 11:58:23 2007 for loon by  doxygen 1.3.9.1