// $Header: /data/reve-cvs/reve/gui/GuiTrack.cxx,v 1.7 2005/12/07 20:15:01 mtadel Exp $
#include "GuiTrack.h"
#include "MCHelixLine.h"
#include <Reve/Reve.h>
#include <TPolyLine3D.h>
#include <TColor.h>
// Updates
#include "ReveFrame.h"
#include <TCanvas.h>
#include <vector>
using namespace ReveGui;
//______________________________________________________________________
// GuiTrack
//
ClassImp(ReveGui::GuiTrack);
GuiTrack::GuiTrack()
{
fRnrStyle = 0;
fPolyLine = 0;
}
GuiTrack::GuiTrack(Reve::MCTrack* t, GuiTrackRnrStyle* rs)
{
fDaughters = 0;
fPolyLine = new TPolyLine3D();
fRnrStyle = rs;
fV.Set(t->Vx(), t->Vy(), t->Vz());
fP.Set(t->Px(), t->Py(), t->Pz());
fBeta = t->P()/t->Energy();
TParticlePDG* pdgp = t->GetPDG();
if(pdgp == 0) {
t->ResetPdgCode(); pdgp = t->GetPDG();
}
fCharge = (Int_t) pdgp->Charge();
fLabel = t->label;
}
GuiTrack::GuiTrack(Reve::RecTrack* t, GuiTrackRnrStyle* rs)
{
fDaughters = 0;
fPolyLine = new TPolyLine3D();
fRnrStyle = rs;
fV = t->V;
fP = t->P;
fBeta = t->beta;
fCharge = t->sign;
fLabel = t->label;
}
GuiTrack::~GuiTrack()
{
// Delete Daughter list, polyline.
}
/**************************************************************************/
void GuiTrack::MakeTrack()
{
Float_t
px = fP.x,
py = fP.y,
pz = fP.z;
MCVertex mc_v0;
mc_v0.x = fV.x;
mc_v0.y = fV.y;
mc_v0.z = fV.z;
mc_v0.t = 0;
std::vector<MCVertex> track_points;
if (fCharge) {
Float_t a = 0.2998*fRnrStyle->fMagField*fCharge/300; // m->cm
MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
helix.init(TMath::Sqrt(px*px+py*py), pz);
helix.loop_to_bounds(px,py,pz);
Int_t N = helix.fN;
fPolyLine->SetPolyLine(N);
for(Int_t i=0; i<helix.fN; i++) {
fPolyLine->SetPoint(i,track_points[i].x, track_points[i].y, track_points[i].z);
}
} else {
MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points); // m->cm
line.goto_bounds(px,py,pz);
fPolyLine->SetPolyLine(track_points.size());
Int_t k = 0;
for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i) {
MCVertex& v = *i;
fPolyLine->SetPoint(k, v.x, v.y, v.z);
++k;
}
}
fPolyLine->SetLineColor( fRnrStyle->GetColorIdx());
fRnrSelf = true;
}
/**************************************************************************/
void GuiTrack::Draw(Option_t* opt)
{
fPolyLine->Draw(opt);
}
/**************************************************************************/
void GuiTrack::SetRnrSelf(Bool_t rnr)
{
if(rnr != fRnrSelf) {
fRnrSelf = rnr;
printf("MCTrack::SetRnrSelf %d n ", rnr? 1:0);
if(! fRnrSelf) {
TList* list = gReveGui->GetCC()->GetListOfPrimitives();
TObject* obj = list->FindObject(fPolyLine);
list->Remove(obj);
} else {
Reve::PadHolder _phold(false, gReveGui->GetCC());
fPolyLine->Draw();
}
gReveGui->Redraw3D();
}
}
void GuiTrack::SetRnrDaughtersRec(Bool_t rnr)
{
GuiTrack* child;
TIter nextin(fDaughters);
while ((child = (GuiTrack*)nextin())){
child->SetRnrSelf(rnr);
child->SetRnrDaughtersRec(rnr);
}
}
void GuiTrack::ImportDaughtersRec()
{}
/**************************************************************************/
/**************************************************************************/
//______________________________________________________________________
// GuiTrackRnrStyle
//
ClassImp(ReveGui::GuiTrackRnrStyle);
Float_t GuiTrackRnrStyle::sDefaultMagField = 0.4;
void GuiTrackRnrStyle::_init()
{
fMagField = sDefaultMagField;
fMaxR = 600;
fMaxZ = 550;
fMaxOrbs = 2;
fMinAng = 45;
fDelta = 0.1; //calculate step size depending on helix radius
}
//______________________________________________________________________
// GuiTrackContainer
//
ClassImp(ReveGui::GuiTrackContainer);
void GuiTrackContainer::_init()
{
mRnrStyle = 0;
fRnrTracks = true;
fN = 0;
}
void GuiTrackContainer::SetRnrTracks(Bool_t rnr)
{
printf("GuiTrackContainer::SetRnrTracks rnr %d to state %d n",rnr?1:0, fRnrTracks?1:0 );
if(fRnrTracks != rnr) {
fRnrTracks = rnr;
if (rnr) {
Reve::PadHolder _phold(false, gReveGui->GetCC());
for(std::vector<GuiTrack*>::iterator i=mTracks.begin(); i!=mTracks.end(); ++i) {
(*i)->fPolyLine->Draw();
(*i)->fRnrSelf = rnr;
}
} else {
TList* list = gReveGui->GetCC()->GetListOfPrimitives();
for(std::vector<GuiTrack*>::iterator i=mTracks.begin(); i!=mTracks.end(); ++i) {
(*i)->fRnrSelf = rnr;
TObject* obj = list->FindObject((*i)->fPolyLine);
list->Remove(obj);
}
}
gReveGui->Redraw3D();
}
}
/**************************************************************************/
void GuiTrackContainer::RemakeTracks()
{
for(std::vector<GuiTrack*>::iterator i=mTracks.begin(); i!=mTracks.end(); ++i)
(*i)->MakeTrack();
gReveGui->Redraw3D();
}
void GuiTrackContainer::SetMaxR(Double_t x)
{
mRnrStyle->fMaxR = x;
RemakeTracks();
}
void GuiTrackContainer::SetMaxZ(Double_t x)
{
mRnrStyle->fMaxZ = x;
RemakeTracks();
}
void GuiTrackContainer::SetMaxOrbs(Double_t x)
{
mRnrStyle->fMaxOrbs = x;
RemakeTracks();
}
/**************************************************************************/
/**************************************************************************/
void GuiTrackContainer::SetColorIdx(Int_t col)
{
Int_t idxcol = col;
for(std::vector<GuiTrack*>::iterator i=mTracks.begin(); i!=mTracks.end(); ++i) {
(*i)->fPolyLine->SetLineColor(idxcol);
}
mRnrStyle->SetColorIdx(idxcol);
}
void GuiTrackContainer::SetColor(Pixel_t pixel)
{
Int_t r, g, b;
TColor::Pixel2RGB(pixel, r, g, b);
printf("rgb (%d %d %d) col %d %dn",r,g,b, TColor::GetColor(r,g,b),TColor::GetColor(pixel));
Int_t idxcol = TColor::GetColor(pixel);
// printf("make color %d n", fColor);
for(std::vector<GuiTrack*>::iterator i=mTracks.begin(); i!=mTracks.end(); ++i) {
(*i)->fPolyLine->SetLineColor(idxcol);
}
mRnrStyle->SetColorIdx(idxcol);
}
void GuiTrackContainer::SetColorUpdate(Pixel_t pixel)
{
SetColor(pixel);
gReveGui->Redraw3D();
}
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.