GUI/TFndEvdTrack.cxx

00001 // @(#)fROOT/GUI:$Name:  $:$Id: TFndEvdTrack.cxx,v 1.10 2007/09/24 07:32:41 Diego_Faso Exp $
00002 // Author: Diego Faso <mailto:faso@to.infn.it>, 2007/04/04
00003 
00005 //                                                       //
00006 // This class has been developed in order to provide a   //
00007 //    simple interface from the FINDA standard track     //
00008 //    description to the ROOT one. In principle tracks   //
00009 //    are helyces, but they can be simple lines (if B=0) //
00010 //                                                       //
00012 
00013 
00014 #include "TFndEvdTrack.h"
00015 #include <Riostream.h>
00016 
00017 ClassImp(TFndEvdTrack)
00018 
00019 //___________________________
00020 TFndEvdTrack::TFndEvdTrack():
00021   fLine(),fHelix(),fHelixPoints(),
00022   fB(),fPID(),fMode((Int_t)E_FndTrack_None)
00023 {
00024   
00025   Info("TFndEvdTrack","creating new dummy evd-track: nothing will happen...");
00026 }
00027 
00028 //___________________________
00029 TFndEvdTrack::TFndEvdTrack(Double_t Bx,Double_t By,Double_t Bz):
00030   fLine(),fHelix(),fHelixPoints(),
00031   fB(),fPID(),fMode((Int_t)E_FndTrack_None)
00032 {
00033 
00034   fB[0] = Bx;
00035   fB[1] = By;
00036   fB[2] = Bz;
00037 
00038 }
00039 
00040 //___________________________
00041 TFndEvdTrack::~TFndEvdTrack(){
00042   
00043   //Info("~TFndEvdTrack","destroying evd-track");
00044 
00045   delete fLine;
00046   delete fHelix;
00047   delete fHelixPoints;
00048 }
00049 
00050 //___________________________
00051 void TFndEvdTrack::BuildLine(const Double_t &x,const Double_t &y,const Double_t &z,const Double_t &phi_d, const Double_t &lam_d,const Double_t &length){
00052   // note:
00053   //
00054   // both phi_d and lam_d : degrees
00055   //
00056   //        lambda = 90 - theta (theta >= 0)
00057   //        lambda = - 90 + theta (theta < 0)
00058   
00059   if(fMode == (Int_t)E_FndTrack_Helix){
00060     Warning("InitLine","Can not build line: helix already defined");
00061     return;
00062   }
00063   
00064   if(fLine) delete fLine;
00065   fLine = new TPolyLine3D(2);
00066   
00067   Double_t theta_rad = TMath::DegToRad() * ( (Double_t)(90 -lam_d) );
00068 
00069   fLine->SetNextPoint(x,y,z);
00070   Double_t xl = x + length * TMath::Sin(theta_rad) * TMath::Cos(TMath::DegToRad() * phi_d);
00071   Double_t yl = y + length * TMath::Sin(theta_rad) * TMath::Sin(TMath::DegToRad() * phi_d);
00072   Double_t zl = z + length * TMath::Cos(theta_rad);
00073   
00074   fLine->SetNextPoint(xl,yl,zl);
00075   fMode = (Int_t)E_FndTrack_Line;
00076 
00077   SetWidth(3);
00078 }
00079 
00080 //___________________________
00081 void TFndEvdTrack::BuildLine(const Double_t &x,const Double_t &y,const Double_t &z,const Double_t &cx,const Double_t &cy,const Double_t &cz,const Double_t &length){
00082   // this method uses director-cosines
00083   
00084   Double_t theta_r = 0;
00085   Double_t phi_r = 0;
00086   RefSys_CosDir_To_Spheric(cx,cy,cz,theta_r,phi_r);
00087 
00088   Double_t phi_d = (Double_t) (TMath::RadToDeg() * phi_r);
00089   Double_t lam_d = (Double_t) ( 90 - (TMath::RadToDeg() * theta_r) );
00090 
00091   BuildLine(x,y,z,phi_d, lam_d,length);
00092 
00093 }
00094 
00095 //___________________________
00096 void TFndEvdTrack::BuildHelix(const Double_t &x,const Double_t &y,const Double_t &z,const Int_t &charge,const Double_t &rad, const Double_t &phi_d, const Double_t &lam_d, const Double_t &Length){
00097   // note:
00098   //
00099   // both phi_d and lam_d : degrees
00100   //
00101   //        lambda = 90 - theta (theta >= 0)
00102   //        lambda = - 90 + theta (theta < 0)  
00103   
00104   Double_t Bmod_sq = 0;
00105   for(Int_t i=0;i<3;i++) Bmod_sq += fB[i] * fB[i] ;
00106   if(Bmod_sq==0){
00107     Warning("BuildHelix","Null magnetic field: Must use a line instead of a helix");
00108     return;  
00109   }
00110   
00111   if(fMode == (Int_t)E_FndTrack_Line){
00112     Warning("InitHelix","Can not build helix: straight track already defined");
00113     return;
00114   }
00115   
00116   InitHelix(charge,rad, lam_d); 
00117   Double_t z_sig = (lam_d >=0 ) ? 1 : -1;
00118   
00119   SetHelix(x,y,z,phi_d,z_sig);
00120   LoadHelixPoints(Length);
00121 
00122   SetWidth(3);
00123 }
00124 
00125 //___________________________
00126 void TFndEvdTrack::BuildHelix(const Double_t &x,const Double_t &y,const Double_t &z,const Int_t &charge,const Double_t &rad, const Double_t &cx,const Double_t &cy,const Double_t &cz, const Double_t &Length){
00127   // note:
00128   //        lambda = 90 - theta (theta >= 0)
00129   //        lambda = - (90 + theta) (theta < 0)
00130 
00131   Double_t theta_r = 0;
00132   Double_t phi_r = 0;
00133   RefSys_CosDir_To_Spheric(cx,cy,cz,theta_r,phi_r);
00134   
00135   Double_t phi_d = (Double_t) (TMath::RadToDeg() * phi_r);
00136   //   Double_t lam_d = (theta_r >=0) ? 
00137   //     (Double_t) ( 90 - (TMath::RadToDeg() * theta_r) ):
00138   //     (Double_t) ( 90 + (TMath::RadToDeg() * theta_r) );
00139   Double_t lam_d = (Double_t) ( 90 - (TMath::RadToDeg() * theta_r) );
00140   
00141   BuildHelix(x,y,z,charge,rad, phi_d, lam_d, Length);
00142 }
00143 
00144 //___________________________
00145 void TFndEvdTrack::InitHelix(const Int_t &charge,const Double_t &rad, const Double_t &lam_d){
00146   
00147   
00148   if(fHelix) delete fHelix;
00149   Double_t curv  =  1/rad;
00150   Double_t lambda = TMath::DegToRad() * lam_d;
00151   Double_t zstep= TMath::Abs( TMath::TwoPi() * rad * TMath::Tan(lambda) );  
00152   //
00153   fHelix = new TGeoHelix(curv, zstep, charge);
00154   fHelix->SetField(fB[0], fB[1], fB[2]);
00155   //
00156   fMode = (Int_t)E_FndTrack_Helix;
00157 }
00158 //___________________________
00159 void TFndEvdTrack::SetHelix(const Double_t &x,const Double_t &y,const Double_t &z, const Double_t &phi_d,const Double_t &z_sig){
00160 
00161   if(!fHelix){
00162     Warning("SetHelix","Could not set helix parameters: helix not available");
00163     return;
00164   }
00165   Double_t phi   = TMath::DegToRad() * phi_d; // phi initial angle
00166   fHelix->InitPoint(x,y,z);
00167   fHelix->InitDirection(TMath::Cos(phi), TMath::Sin(phi), z_sig, kFALSE);
00168 }
00169 
00170 //___________________________
00171 void TFndEvdTrack::LoadHelixPoints(const Double_t &MaxLength,const Double_t step,const Int_t N_max_points){
00172   
00173   if(!fHelix){
00174     Warning("LoadHelixPoints","Could not load helix points: helix not available");
00175     return;
00176   }
00177   
00178   delete fHelixPoints;
00179   fHelixPoints = new TPointSet3D(2000);
00180   
00181   const Double_t* p = fHelix->GetCurrentPoint();
00182   Int_t N_all = 0;  
00183   for(N_all=0; N_all<=N_max_points; N_all++) {
00184     fHelixPoints->SetNextPoint( p[0], p[1], p[2] );    
00185     fHelix->Step(step);
00186     if(fHelix->GetStep() > MaxLength) break;
00187   }
00188   
00189   fHelixPoints->SetMarkerColor(E_FndTrCol_Default);
00190   //  Printf("Helix points ready , number of points %d.\n", N_all);
00191   
00192 }
00193 
00194 //___________________________
00195 void TFndEvdTrack::SetPID(const Int_t &pid){
00196 
00197   fPID = pid;
00198 
00199   //  cout << "Setting PID: " << fPID << endl;
00200 
00201   //  UInt_t mod_pid = TMath::Abs(fPID);
00202   Int_t col;
00203   switch(fPID){
00204   case (Int_t)(FPh_PID_Electron) : col = E_FndTrCol_Elec;    break;
00205   case (Int_t)(FPh_PID_Positron) : col = E_FndTrCol_Posit;   break;
00206   case (Int_t)(FPh_PID_Kaon_min) : col = E_FndTrCol_KaonMin; break;
00207   case (Int_t)(FPh_PID_Kaon_plu) : col = E_FndTrCol_KaonPlu; break;
00208   case (Int_t)(FPh_PID_Muon_min) : col = E_FndTrCol_MuonMin; break;
00209   case (Int_t)(FPh_PID_Muon_plu) : col = E_FndTrCol_MuonPlu; break;
00210   case (Int_t)(FPh_PID_Pi_min)   : col = E_FndTrCol_PiMin;   break;
00211   case (Int_t)(FPh_PID_Pi_plu)   : col = E_FndTrCol_PiPlu;   break;
00212   case (Int_t)(FPh_PID_Proton)   : col = E_FndTrCol_Prot;    break;
00213   case (Int_t)(FPh_PID_Neutron)  : col = E_FndTrCol_Neut;    break;
00214   case (Int_t)(FPh_PID_Gamma)    : col = E_FndTrCol_Phot;    break;
00215   default: col = (Int_t)E_FndTrCol_Default; break;
00216     
00217   }
00218   SetColor(col);
00219 
00220 }
00221 
00222 //___________________________
00223 void TFndEvdTrack::SetColor(const Int_t &col){
00224   // will update current drawable object
00225   
00226   if(fHelixPoints) fHelixPoints->SetMarkerColor(col);
00227   if(fLine) fLine->SetLineColor(col);
00228   
00229 }
00230 //___________________________
00231 void TFndEvdTrack::SetWidth(const Double_t &w){
00232 
00233   if(fHelixPoints){
00234     fHelixPoints->SetMarkerStyle(4);
00235     fHelixPoints->SetMarkerSize(w/8);
00236   }
00237   if(fLine) fLine->SetLineWidth((Width_t)w);
00238 }
00239 
00240 //___________________________
00241 TObject *TFndEvdTrack::GetDrawable(){
00242   // can be used for irect drawing
00243   //  mytrack->GetDrawableTrack()->Draw();
00244 
00245   switch(fMode){
00246   case (Int_t)E_FndTrack_Line : return fLine;
00247   case (Int_t)E_FndTrack_Helix: return fHelixPoints;
00248   default: return 0;
00249   }
00250 
00251 }
00252 
00253 //___________________________
00254 void TFndEvdTrack::DrawTrack(Option_t *option){
00255   
00256   if(GetDrawable()) GetDrawable()->Draw(option); 
00257 }

Generated on Tue Oct 16 15:40:46 2007 by  doxygen 1.5.2