TEveJetCone.cxx

Go to the documentation of this file.
00001 // @(#)root/eve:$Id: TEveJetCone.cxx 35221 2010-09-10 11:46:37Z matevz $
00002 // Author: Matevz Tadel, Jochen Thaeder 2009
00003 
00004 /*************************************************************************
00005  * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers.               *
00006  * All rights reserved.                                                  *
00007  *                                                                       *
00008  * For the licensing terms see $ROOTSYS/LICENSE.                         *
00009  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
00010  *************************************************************************/
00011 
00012 #include "TEveJetCone.h"
00013 #include "TEveTrans.h"
00014 #include "TEveProjectionManager.h"
00015 
00016 #include "TMath.h"
00017 
00018 
00019 //==============================================================================
00020 // TEveJetCone
00021 //==============================================================================
00022 
00023 //______________________________________________________________________________
00024 //
00025 // Draws a jet cone with leading particle is specified in (eta,phi) and
00026 // cone radius is given.
00027 //
00028 // If Apex is not set, default is (0.,0.,0.)
00029 // In case of cylinder was set, cone is cut at the cylinder edges.
00030 //
00031 // Example :
00032 //
00033 //  Float_t coneEta    = r.Uniform(-0.9, 0.9);
00034 //  Float_t conePhi    = r.Uniform(0.0, TwoPi() );
00035 //  Float_t coneRadius = 0.4;
00036 //
00037 //  TEveJetCone* jetCone = new TEveJetCone("JetCone");
00038 //  jetCone->SetCylinder(250, 250);
00039 //  if (jetCone->AddCone(coneEta, conePhi, coneRadius) != -1)
00040 //    gEve->AddElement(jetCone);
00041 //
00042 //
00043 // Implementation notes
00044 //
00045 // TEveVector fLimits encodes the following information:
00046 //   fY, fZ:  barrel radius and endcap z-position;
00047 //            if both are 0, fX encodes the spherical radius
00048 //   fX    :  scaling for length of the cone
00049 
00050 ClassImp(TEveJetCone);
00051 
00052 //______________________________________________________________________________
00053 TEveJetCone::TEveJetCone(const Text_t* n, const Text_t* t) :
00054    TEveShape(n, t),
00055    fApex(),
00056    fLimits(), fThetaC(10),
00057    fEta(0), fPhi(0), fDEta(0), fDPhi(0), fNDiv(72)
00058 {
00059    // Constructor.
00060 
00061    fColor = kGreen;
00062 }
00063 
00064 //______________________________________________________________________________
00065 void TEveJetCone::ComputeBBox()
00066 {
00067    // Compute bounding-box of the data.
00068 
00069    BBoxInit();
00070    BBoxCheckPoint(fApex);
00071    BBoxCheckPoint(CalcBaseVec(0));
00072    BBoxCheckPoint(CalcBaseVec(TMath::PiOver2()));
00073    BBoxCheckPoint(CalcBaseVec(TMath::Pi()));
00074    BBoxCheckPoint(CalcBaseVec(TMath::Pi() + TMath::PiOver2()));
00075 }
00076 
00077 //______________________________________________________________________________
00078 TClass* TEveJetCone::ProjectedClass(const TEveProjection*) const
00079 {
00080    // Virtual from TEveProjectable, returns TEveJetConeProjected class.
00081 
00082    return TEveJetConeProjected::Class();
00083 }
00084 
00085 
00086 //______________________________________________________________________________
00087 Int_t TEveJetCone::AddCone(Float_t eta, Float_t phi, Float_t cone_r, Float_t length)
00088 {
00089    // Add jet cone.
00090    // parameters are :
00091    // * (eta,phi)    : of the center/leading particle
00092    // * cone_r       : cone radius in eta-phi space
00093    // * length       : length of the cone
00094    //   * if cylinder is set and length is adapted to cylinder.
00095    //     - if length is given, it will be used as scalar factor
00096    //   * if cylinder is not set, length is used as length of the cone
00097    // Return 0 on sucess.
00098 
00099    return AddEllipticCone(eta, phi, cone_r, cone_r, length);
00100 }
00101 
00102 //______________________________________________________________________________
00103 Int_t TEveJetCone::AddEllipticCone(Float_t eta, Float_t phi, Float_t reta, Float_t rphi, Float_t length)
00104 {
00105    // Add jet cone.
00106    // parameters are :
00107    // * (eta,phi)    : of the center/leading particle
00108    // * (reta, rphi) : radius of cone in eta-phi space
00109    // * length       : length of the cone
00110    //   * if cylinder is set and length is adapted to cylinder.
00111    //     - if length is given, it will be used as scalar factor
00112    //   * if cylinder is not set, length is used as length of the cone
00113    // Returns 0 on sucess.
00114 
00115    using namespace TMath;
00116 
00117    if (length != 0) fLimits.fX = length;
00118 
00119    if (fLimits.IsZero())
00120       return -1;
00121 
00122    fEta = eta; fPhi = phi; fDEta = reta; fDPhi = rphi;
00123 
00124    return 0;
00125 }
00126 
00127 //______________________________________________________________________________
00128 TEveVector TEveJetCone::CalcEtaPhiVec(Float_t eta, Float_t phi) const
00129 {
00130    // Fill TEveVector with eta and phi, magnitude 1.
00131 
00132    using namespace TMath;
00133 
00134    return TEveVector(Cos(phi) / CosH(eta), Sin(phi) / CosH(eta), TanH(eta));
00135 }
00136 
00137 //______________________________________________________________________________
00138 TEveVector TEveJetCone::CalcBaseVec(Float_t eta, Float_t phi) const
00139 {
00140    // Returns point on the base of the cone with given eta and phi.
00141 
00142    using namespace TMath;
00143 
00144    TEveVector vec = CalcEtaPhiVec(eta, phi);
00145 
00146    // -- Set length of the contourPoint
00147    if (fLimits.fY != 0 && fLimits.fZ != 0)
00148    {
00149       Float_t theta = vec.Theta();
00150       if (theta < fThetaC)
00151          vec *= fLimits.fZ / Cos(theta);
00152       else if (theta > Pi() - fThetaC)
00153          vec *= fLimits.fZ / Cos(theta - Pi());
00154       else
00155          vec *= fLimits.fY / Sin(theta);
00156 
00157       if (fLimits.fX != 0) vec *= fLimits.fX;
00158    }
00159    else 
00160    {
00161       vec *= fLimits.fX;
00162    }
00163 
00164    return vec;
00165 }
00166 
00167 //______________________________________________________________________________
00168 TEveVector TEveJetCone::CalcBaseVec(Float_t alpha) const
00169 {
00170    // Returns point on the base of the cone with internal angle alpha:
00171    // alpha = 0 -> max eta,  alpha = pi/2 -> max phi, ...
00172 
00173    using namespace TMath;
00174 
00175    return CalcBaseVec(fEta + fDEta * Cos(alpha), fPhi + fDPhi * Sin(alpha));
00176 }
00177 
00178 //______________________________________________________________________________
00179 Bool_t TEveJetCone::IsInTransitionRegion() const
00180 {
00181    // Returns true if the cone is in barrel / endcap transition region.
00182 
00183    using namespace TMath;
00184 
00185    Float_t tm = CalcBaseVec(0).Theta();
00186    Float_t tM = CalcBaseVec(Pi()).Theta();
00187 
00188    return (tM > fThetaC        && tm < fThetaC) ||
00189           (tM > Pi() - fThetaC && tm < Pi() - fThetaC);
00190 }
00191 
00192 //==============================================================================
00193 // TEveJetConeProjected
00194 //==============================================================================
00195 
00196 //______________________________________________________________________________
00197 //
00198 // Projection of TEveJetCone.
00199 
00200 //______________________________________________________________________________
00201 TEveJetConeProjected::TEveJetConeProjected(const char* n, const char* t) :
00202    TEveShape(n, t)
00203 {
00204    // Constructor.
00205 }
00206 
00207 //______________________________________________________________________________
00208 TEveJetConeProjected::~TEveJetConeProjected()
00209 {
00210    // Destructor.
00211 }
00212 
00213 //______________________________________________________________________________
00214 void TEveJetConeProjected::ComputeBBox()
00215 {
00216    // Compute bounding-box, virtual from TAttBBox.
00217 
00218    BBoxInit();
00219 
00220    TEveJetCone    *cone = dynamic_cast<TEveJetCone*>(fProjectable);
00221 //______________________________________________________________________________
00222    TEveProjection *proj = GetManager()->GetProjection();
00223    TEveVector v;
00224    v = cone->fApex;                                       proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00225    v = cone->CalcBaseVec(0);                              proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00226    v = cone->CalcBaseVec(TMath::PiOver2());               proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00227    v = cone->CalcBaseVec(TMath::Pi());                    proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00228    v = cone->CalcBaseVec(TMath::Pi() + TMath::PiOver2()); proj->ProjectVector(v, fDepth); BBoxCheckPoint(v);
00229 }
00230 
00231 //______________________________________________________________________________
00232 void TEveJetConeProjected::SetDepthLocal(Float_t d)
00233 {
00234    // This is virtual method from base-class TEveProjected.
00235 
00236    SetDepthCommon(d, this, fBBox);
00237 }
00238 
00239 //______________________________________________________________________________
00240 void TEveJetConeProjected::SetProjection(TEveProjectionManager* mng, TEveProjectable* model)
00241 {
00242    // This is virtual method from base-class TEveProjected.
00243 
00244    TEveProjected::SetProjection(mng, model);
00245    CopyVizParams(dynamic_cast<TEveElement*>(model));
00246 }
00247 
00248 //______________________________________________________________________________
00249 void TEveJetConeProjected::UpdateProjection()
00250 {
00251    // Re-project the jet-cone.
00252 
00253 }

Generated on Tue Jul 5 14:16:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1