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

GfxMCVec.cxx

Go to the documentation of this file.
00001 #include "GfxMCVec.h"
00002 #include "GfxMCVecList.h"
00003 #include "GfxMCVecListCfg.h"
00004 #include "ViewState.h"
00005 
00006 #include <UgliGeometry/UgliGeomHandle.h>
00007 #include <UgliGeometry/UgliStripHandle.h>
00008 #include <Plex/PlexSEIdAltL.h>
00009 #include <TEllipse.h>
00010 #include <TBox.h>
00011 #include <TPad.h>
00012 #include <TLine.h>
00013 #include <TMarker.h>
00014 #include <TList.h>
00015 #include <TPolyLine.h>
00016 #include <map>
00017 using namespace std;
00018 
00019 ClassImp(GfxMCVec)
00020 
00021 
00022 
00023 GfxMCVec::GfxMCVec(const TParticle& part, const float evntP, GfxMCVecList& parent)
00024     : fParticle(part)
00025     , fEventP(evntP)
00026     , fParent(parent)
00027     , fImp(0)
00028 {
00029 }
00030 
00031 GfxMCVec::GfxMCVec(const GfxMCVec& rhs)
00032     : TObject()
00033       ,fParticle(rhs.fParticle), fEventP(rhs.fEventP), fParent(rhs.fParent), fImp(0)
00034 {
00035 }
00036 
00037 
00038 GfxMCVec::~GfxMCVec()
00039 {
00040   this->Clear();
00041 }
00042 
00043 void GfxMCVec::Clear(Option_t*)
00044 {
00045   if (fImp) delete fImp; fImp=0;
00046 }
00047 
00048 void GfxMCVec::Configure(int ipart)
00049 {
00050     if (fImp) { delete fImp; fImp = 0; }
00051 
00052 
00053     switch (fParent.GetViewState()->GetSpatialMetric()) {
00054     case ViewState::metric_is_continuous:
00055         if (! this->BuildRealImp(ipart)) return;
00056         break;
00057     case ViewState::metric_is_discreet: default:
00058         if (! this->BuildDiscreteImp(ipart)) return;
00059         break;
00060     }
00061 
00062 }
00063 
00064 
00065 bool GfxMCVec::BuildRealImp( int /*ipart*/)
00066 {
00067    
00068     float motherlength;
00069 
00070     TList* MCVec = new TList;
00071     MCVec->SetOwner();
00072 
00073     double x1=0;
00074     double x2=0;
00075     double y1=0;
00076     double y2=0;
00077 
00078     int sign=1;
00079     if((abs(fParticle.GetPdgCode())==12 || 
00080        abs(fParticle.GetPdgCode())==14 ||
00081        abs(fParticle.GetPdgCode())==16) && fParticle.GetStatusCode()==0) sign=-1;
00082     
00083 
00084     if (fParent.GetGraphicsView() == GraphicsView::kUZ) 
00085       {
00086         motherlength=4;
00087         x1 = fParticle.Vz();
00088         y1 = 0.7071678*(fParticle.Vx()+fParticle.Vy());
00089         double len=0.2*fParticle.P();
00090         double pu = 0.7071678*(fParticle.Px()+fParticle.Py());
00091         double pz = fParticle.Pz();
00092         double P=fParticle.P();
00093         if(P>0 && fEventP>0)
00094           {
00095             len= motherlength*(fParticle.P()/fEventP);    
00096             x2=x1+sign*len*pz/P;
00097             y2=y1+sign*len*pu/P;
00098           }
00099       }
00100     else if(fParent.GetGraphicsView() == GraphicsView::kVZ) 
00101       {  
00102         motherlength=4;
00103         x1  = fParticle.Vz();
00104         y1 = 0.7071678*(fParticle.Vy()-fParticle.Vx());
00105         double len=0.2*fParticle.P();
00106         double pv = 0.7071678*(fParticle.Py()-fParticle.Px());
00107         double pz = fParticle.Pz();
00108         double P=fParticle.P();
00109         if(P>0 && fEventP>0)
00110           {
00111             len= motherlength*(fParticle.P()/fEventP);
00112             x2=x1+sign*len*pz/P;
00113             y2=y1+sign*len*pv/P;
00114           }
00115       }
00116     else if(fParent.GetGraphicsView() == GraphicsView::kXY) 
00117       {                
00118         motherlength=6;
00119         x1 = fParticle.Vx();
00120         y1 = fParticle.Vy();
00121         double px =fParticle.Px(); 
00122         double py =fParticle.Py();
00123         double P=fParticle.P();
00124 
00125         double len=0.2*fParticle.P();
00126         if(P>0 && fEventP>0)
00127           {
00128             len= motherlength*(fParticle.P()/fEventP);
00129             x2=x1+sign*len*px/P;
00130             y2=y1+sign*len*py/P;
00131           }
00132     }
00133     else if(fParent.GetGraphicsView() == GraphicsView::kUV) 
00134       {                
00135         motherlength=6;
00136         x1 = 0.7071678*(fParticle.Vx()+fParticle.Vy());
00137         y1 = 0.7071678*(fParticle.Vy()-fParticle.Vx());
00138         double pu =0.7071678*(fParticle.Px()+fParticle.Py()); 
00139         double pv =0.7071678*(fParticle.Py()-fParticle.Px());
00140         double P=fParticle.P();
00141         double len=0.2*fParticle.P();
00142         if(P>0 && fEventP>0)
00143           {
00144             len= motherlength*(fParticle.P()/fEventP);
00145             x2=x1+sign*len*pu/P;
00146             y2=y1+sign*len*pv/P;
00147           }
00148       }
00149     TLine * Vec = new TLine(x1,y1,x2,y2);
00150     Vec->SetLineColor(15);
00151     if(abs(fParticle.GetPdgCode())==2212) Vec->SetLineColor(45);
00152     if(abs(fParticle.GetPdgCode())==12 || 
00153        abs(fParticle.GetPdgCode())==14 ||
00154        abs(fParticle.GetPdgCode())==16)  Vec->SetLineColor(1);
00155     if(abs(fParticle.GetPdgCode())==11)  Vec->SetLineColor(2);  
00156     if(abs(fParticle.GetPdgCode())==13)  Vec->SetLineColor(3);
00157     MCVec->Add(Vec);
00158     
00159     fImp = MCVec;
00160 
00161 
00162     return true;
00163 }
00164 
00165 bool GfxMCVec::BuildDiscreteImp(int /*ipart */)
00166 {
00167   TList* MCVec = new TList;
00168   MCVec->SetOwner();
00169 
00170   if(fParent.GetGraphicsView() != GraphicsView::kXY && 
00171      fParent.GetGraphicsView() != GraphicsView::kUV)
00172       {
00173       }
00174 
00175     else if(fParent.GetGraphicsView() == GraphicsView::kXY) 
00176       {                     
00177      }
00178     else if(fParent.GetGraphicsView() == GraphicsView::kUV) 
00179       {                     
00180   
00181       }
00182 
00183  
00184     fImp = MCVec;
00185 
00186     return true;
00187 }
00188 
00189 void GfxMCVec::ExecuteEvent(int event, int px, int py)
00190 {
00191     fParent.ExecuteEvent(event,px,py,this);
00192 }
00193 void GfxMCVec::Paint(Option_t* option)
00194 {
00195     if (!fImp) return;
00196 
00197     fImp->Paint(option);
00198 }
00199 int GfxMCVec::DistancetoPrimitive(int px, int py)
00200 {
00201     int dist = 0xdead;
00202     if (fImp) {
00203         TList* l = dynamic_cast<TList*>(fImp);
00204         if (!l) 
00205             dist = fImp->DistancetoPrimitive(px,py);
00206         else {
00207             TIter next(l);
00208             TObject* obj;
00209             while ((obj=next())) {
00210                 int d = obj->DistancetoPrimitive(px,py);
00211                 if (d < dist) dist = d;
00212             }
00213         }
00214     }
00215     return dist;
00216 }
00217 

Generated on Mon Feb 15 11:06:46 2010 for loon by  doxygen 1.3.9.1