#include <TEveTrack.h>
#include <TEveElement.h>
-#include <algorithm>
#include <map>
//______________________________________________________________________________
// AliEveKineTools
//
+// Tools for import of kinematics. Preliminary version.
+//
using namespace std;
ClassImp(AliEveKineTools)
-AliEveKineTools::AliEveKineTools()
-{}
-/******************************************************************************/
+namespace {
+
+ typedef std::map<Int_t, TEveTrack*> TrackMap_t;
+
+ void MapTracks(TrackMap_t& map, TEveElement* cont, Bool_t recurse)
+ {
+ TEveElement::List_i i = cont->BeginChildren();
+ while (i != cont->EndChildren()) {
+ TEveTrack* track = dynamic_cast<TEveTrack*>(*i);
+ map[track->GetLabel()] = track;
+ if (recurse)
+ MapTracks(map, track, recurse);
+ ++i;
+ }
+ }
+}
+
+/**************************************************************************/
void AliEveKineTools::SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse)
{
// Import daughters birth points.
TEveElement::List_i iter = cont->BeginChildren();
-
while(iter != cont->EndChildren())
{
TEveTrack* track = dynamic_cast<TEveTrack*>(*iter);
}
}
-/******************************************************************************/
-
-namespace {
-struct cmp_pathmark
-{
- bool operator()(TEvePathMark* const & a, TEvePathMark* const & b)
- { return a->fTime < b->fTime; }
-};
-
-void slurp_tracks(std::map<Int_t, TEveTrack*>& tracks, TEveElement* cont, Bool_t recurse)
-{
- TEveElement::List_i citer = cont->BeginChildren();
- while(citer != cont->EndChildren())
- {
- TEveTrack* track = dynamic_cast<TEveTrack*>(*citer);
- tracks[track->GetLabel()] = track;
- if (recurse)
- slurp_tracks(tracks, track, recurse);
- ++citer;
- }
-}
-
-}
+/**************************************************************************/
void AliEveKineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_t recurse)
{
- // set decay and reference points
+ // Set decay and track reference path-marks.
static const TEveException eH("AliEveKineTools::ImportPathMarks");
- // Fill map
- std::map<Int_t, TEveTrack*> tracks;
- slurp_tracks(tracks, cont, recurse);
+ TrackMap_t map;
+ MapTracks(map, cont, recurse);
Int_t nPrimaries = (Int_t) treeTR->GetEntries();
TIter next(treeTR->GetListOfBranches());
el->GetEntry(iPrimPart);
Int_t last_label = -1;
- std::map<Int_t, TEveTrack*>::iterator iter = tracks.end();
+ TrackMap_t::iterator iter = map.end();
Int_t Nent = arr->GetEntriesFast();
for (Int_t iTrackRef = 0; iTrackRef < Nent; iTrackRef++)
{
iTrackRef, el->GetName()));
if(label != last_label) {
- iter = tracks.find(label);
+ iter = map.find(label);
last_label = label;
}
- if (iter != tracks.end()) {
+ if (iter != map.end()) {
TEvePathMark* pm = new TEvePathMark(isRef ? TEvePathMark::kReference : TEvePathMark::kDecay);
pm->fV.Set(atr->X(),atr->Y(), atr->Z());
pm->fP.Set(atr->Px(),atr->Py(), atr->Pz());
track->AddPathMark(pm);
}
} // loop track refs
- } // loop primaries, clones arrays
+ } // loop primaries in clones arrays
delete arr;
} // end loop through top branches
}
-void AliEveKineTools::SortPathMarks(TEveElement* cont, Bool_t recurse)
+/**************************************************************************/
+
+void AliEveKineTools::SortPathMarks(TEveElement* el, Bool_t recurse)
{
// Sort path-marks for all tracks by time.
- // Fill map
- std::map<Int_t, TEveTrack*> tracks;
- slurp_tracks(tracks, cont, recurse);
+ TEveTrack* track = dynamic_cast<TEveTrack*>(el);
+ if(track) track->SortPathMarksByTime();
- // sort
- for(std::map<Int_t, TEveTrack*>::iterator j=tracks.begin(); j!=tracks.end(); ++j)
- {
- j->second->SortPathMarksByTime();
+ TEveElement::List_i i = el->BeginChildren();
+ while (i != el->EndChildren() && recurse) {
+ track = dynamic_cast<TEveTrack*>(el);
+ if (track) track->SortPathMarksByTime();
+ i++;
}
}
* full copyright notice. *
**************************************************************************/
-// Tools for import of kinematics.
-// Preliminary/minimal solution.
-
#ifndef ALIEVE_KineTools_H
#define ALIEVE_KineTools_H
class TTree;
class AliStack;
-class TEveTrackList;
-
-
class AliEveKineTools
{
private:
AliEveKineTools(const AliEveKineTools&); // Not implemented
AliEveKineTools& operator=(const AliEveKineTools&); // Not implemented
-protected:
- // data from TreeK
public:
- AliEveKineTools();
+ AliEveKineTools(){}
virtual ~AliEveKineTools(){}
- // data from TreeTR
void SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse=kFALSE);
void SetTrackReferences (TEveElement* cont, TTree* treeTR=0, Bool_t recurse=kFALSE);
void SortPathMarks (TEveElement* cont, Bool_t recurse=kFALSE);
- ClassDef(AliEveKineTools, 1);
-}; // endclass AliEveKineTools
+ ClassDef(AliEveKineTools, 1); // Tools for import of kinematics.
+};
#endif
//______________________________________________________________________________
// AliEveTrackFitter
//
-// AliEveTrackFitter is an interface to helix fit. It creates a set of
-// points, listening to signal PointCtrlClicked() of any
-// TEvePointSet. Via editor it fits selected points and creates a
-// reconstructed track.
+// AliEveTrackFitter is an interface to TEvePointSet allowing AliRieman fit.
+// It builds a list of points by listening to selection signal of any object of type
+// TEvePointSet. After selection the list is feeded to AliRieman fitter,
+// which returns helix parameters visualized with TEveTrack.
//
ClassImp(AliEveTrackFitter)
AliEveTrackFitter::AliEveTrackFitter(const Text_t* name, Int_t n_points) :
TEvePointSet (name, n_points),
- fGraphSelected (0),
- fGraphFitted (0),
fAlpha (0),
fRieman (0),
+
fConnected (kFALSE),
+ fSPMap (),
fTrackList (0),
- fMapPS ()
+
+ fGraphPicked (0),
+ fGraphHelix (0)
{
// Constructor.
SetMarkerColor(3);
SetOwnIds(kFALSE);
- fGraphSelected = new TGraph();
- fGraphSelected->SetName("Selected points");
- fGraphSelected->SetMarkerColor(4);
- fGraphSelected->SetMarkerStyle(4);
- fGraphSelected->SetMarkerSize(2);
-
- fGraphFitted = new TGraphErrors();
- fGraphFitted->SetName("Fitted points");
- fGraphFitted->SetMarkerColor(2);
-
fTrackList = new TEveTrackList("Tracks");
fTrackList->SetLineWidth(2);
fTrackList->SetLineColor(8);
fTrackList->GetPropagator()->SetEditPathMarks(kTRUE);
gEve->AddElement(fTrackList, this);
UpdateItems();
+
+ fGraphPicked = new TGraph();
+ fGraphPicked->SetName("Selected points");
+ fGraphPicked->SetMarkerColor(4);
+ fGraphPicked->SetMarkerStyle(4);
+ fGraphPicked->SetMarkerSize(2);
+
+ fGraphHelix = new TGraphErrors();
+ fGraphHelix->SetName("Fitted points");
+ fGraphHelix->SetMarkerColor(2);
}
AliEveTrackFitter::~AliEveTrackFitter()
// Destructor.
if(fRieman) delete fRieman;
+
fTrackList->DecDenyDestroy();
delete fTrackList;
}
-/******************************************************************************/
-void AliEveTrackFitter::DestroyElements()
-{
- // Virtual method of base class TEveElement.
- // It preserves track list to have coomon track propagator attributes.
-
- TEveElement::DestroyElements();
- gEve->AddElement(fTrackList, this);
- fTrackList->DestroyElements();
- UpdateItems();
-}
-
/******************************************************************************/
void AliEveTrackFitter::Start()
{
- // Start selection of points.
+ // Clear existing point selection and maintain connection to the
+ // TEvePointSet signal.
Reset();
if(fConnected == kFALSE)
{
TQObject::Connect("TEvePointSet", "PointCtrlClicked(TEvePointSet*,Int_t)",
"AliEveTrackFitter", this, "AddFitPoint(TEvePointSet*,Int_t)");
-
fConnected = kTRUE;
}
}
void AliEveTrackFitter::Stop()
{
- // Stop selection of points.
+ // Stop adding points for the fit.
if(fConnected)
{
}
}
+void AliEveTrackFitter::Reset(Int_t n, Int_t ids)
+{
+ // Reset selection.
+
+ if(fRieman) fRieman->Reset();
+ TEvePointSet::Reset(n, ids);
+ fSPMap.clear();
+}
+
/******************************************************************************/
void AliEveTrackFitter::AddFitPoint(TEvePointSet* ps, Int_t n)
{
- // Add/remove given point depending if exists in the fMapPS.
+ // Add or remove given point depending if exists in the map.
Float_t x, y, z;
- std::map<Point_t, Int_t>::iterator g = fMapPS.find(Point_t(ps, n));
- if(g != fMapPS.end())
+ PointMap_t::iterator g = fSPMap.find(Point_t(ps, n));
+ if(g != fSPMap.end())
{
Int_t idx = g->second;
if(idx != fLastPoint)
GetPoint(fLastPoint, x, y, z);
SetPoint(idx, x, y, z);
}
- fMapPS.erase(g);
+ fSPMap.erase(g);
fLastPoint--;
}
else
{
- fMapPS[Point_t(ps, n)] = Size();
+ fSPMap[Point_t(ps, n)] = Size();
ps->GetPoint(n, x, y, z);
SetNextPoint(x, y, z);
SetPointId(ps->GetPointId(n));
}
+
ResetBBox();
ElementChanged(kTRUE, kTRUE);
}
}
-void AliEveTrackFitter::Reset(Int_t n, Int_t ids)
+/******************************************************************************/
+void AliEveTrackFitter::DestroyElements()
{
- // Reset selection.
+ // Virtual method of base class TEveElement.
+ // Preserves TEveTrackPropagator object for fitted helices.
- if(fRieman) fRieman->Reset();
- TEvePointSet::Reset(n, ids);
- fMapPS.clear();
+ TEveElement::DestroyElements();
+
+ gEve->AddElement(fTrackList, this);
+ fTrackList->DestroyElements();
+ UpdateItems();
}
/******************************************************************************/
-void AliEveTrackFitter::DrawRiemanGraph()
+void AliEveTrackFitter::DrawDebugGraph()
{
- // Draw graph of rieman fit.
+ // Draw graph of picked points and helix points.
- static const TEveException eH("AliEveTrackFitter::DrawRiemanGraph ");
+ static const TEveException eH("AliEveTrackFitter::DrawRiemanGraph ");
if(fRieman == 0)
throw(eH + "fitter not set.");
Int_t nR = fRieman->GetN();
- fGraphSelected->Set(nR);
- fGraphFitted->Set(nR);
+ fGraphPicked->Set(nR);
+ fGraphHelix->Set(nR);
- Double_t* x = fRieman->GetX();
- Double_t* y = fRieman->GetY();
+ Double_t* x = fRieman->GetX();
+ Double_t* y = fRieman->GetY();
Double_t* sy = fRieman->GetSy();
for (Int_t i=0; i<nR; i++)
{
- fGraphSelected->SetPoint(i, x[i], y[i]);
- fGraphFitted->SetPoint(i, x[i], fRieman->GetYat(x[i]));
- fGraphFitted->SetPointError(i, 0.1, sy[i]);
+ fGraphPicked->SetPoint(i, x[i], y[i]);
+ fGraphHelix->SetPoint (i, x[i], fRieman->GetYat(x[i]));
+ fGraphHelix->SetPointError(i, 0.1, sy[i]); // now faked
}
- if (gPad) gPad->Clear();
- fGraphSelected->Draw("AP");
- fGraphFitted->Draw("SAME P");
+ if (gPad)
+ gPad->Clear();
+
+ fGraphPicked->Draw("AP");
+ fGraphHelix->Draw("SAME P");
gPad->GetCanvas()->SetTitle(Form("AliRieman alpha: %f", fAlpha));
gPad->Modified();
gPad->Update();
#define ALIEVE_TrackFitter_H
#include <TEvePointSet.h>
-#include <TQObject.h>
#include <map>
class TGraphErrors;
class TEveTrackList;
-
class AliEveTrackFitter : public TEvePointSet
{
private:
AliEveTrackFitter(const AliEveTrackFitter&); // Not implemented
AliEveTrackFitter& operator=(const AliEveTrackFitter&); // Not implemented
- TGraph *fGraphSelected; // graph of selected points
- TGraphErrors *fGraphFitted; // graph of fitted points
-
protected:
+
struct Point_t
{
- // inner structure to check duplicates
- TEvePointSet *fPS; // selected pointset
- Int_t fIdx; // location in the point set array
+ TEvePointSet *fPS; // point set
+ Int_t fIdx; // id in point set
- Point_t(TEvePointSet* ps, Int_t i) : fPS(ps), fIdx(i) {}
+ Point_t(TEvePointSet* ps=0, Int_t i=0) : fPS(ps), fIdx(i) {}
Point_t(const Point_t& p) : fPS(p.fPS), fIdx(p.fIdx) {}
- Point_t& operator=(const Point_t& p)
- { fPS = p.fPS; fIdx = p.fIdx; return *this; }
- bool operator<(const Point_t& o) const
- { if (fPS != o.fPS) return fPS < o.fPS; return fIdx < o.fIdx; }
+ Point_t& operator=(const Point_t& p) {
+ fPS = p.fPS; fIdx = p.fIdx; return *this;
+ }
+
+ bool operator<(const Point_t& o) const {
+ if (fPS != o.fPS) return fPS < o.fPS;
+ return fIdx < o.fIdx;
+ }
};
- Float_t fAlpha; // transformation agle to local system (where x>>y)
- AliRieman* fRieman; // rieman fitter
+ typedef std::map<Point_t, Int_t> PointMap_t;
+
+ Float_t fAlpha; // transformation angle to AliRieman local system (where x>>y)
+ AliRieman* fRieman; // rieman fitter
- Bool_t fConnected; // object connected to pointset Ctrl-shift signal
+ Bool_t fConnected; // connection to the TEvePointSet signal
- TEveTrackList* fTrackList; // track list created with rieman fit
+ PointMap_t fSPMap; // map of selected points
+ TEveTrackList* fTrackList; // list of tracks removed in the destructor
- std::map<Point_t, Int_t> fMapPS; // map of selected points from different TEvePointSet
+ TGraph *fGraphPicked; // graph of selected points debug info
+ TGraphErrors *fGraphHelix; // graph of fitted points for debug info
public:
- AliEveTrackFitter(const Text_t* name, Int_t n_points=0);
+ AliEveTrackFitter(const Text_t* name = "TrackFitter", Int_t n_points=0);
virtual ~AliEveTrackFitter();
- virtual void AddFitPoint(TEvePointSet*,Int_t); // slot for PointCtrlClicked() signal
-
- virtual void DestroyElements(); // *MENU*
+ virtual void AddFitPoint(TEvePointSet*,Int_t); // slot for PointCtrlClicked() signal
- virtual void Start();
- virtual void Stop();
- virtual void FitTrack();
- virtual void Reset(Int_t n_points=0, Int_t n_int_ids=0);
+ virtual void Start();
+ virtual void Stop();
+ virtual void FitTrack();
+ virtual void Reset(Int_t n_points=0, Int_t n_int_ids=0);
Bool_t GetConnected(){ return fConnected; }
AliRieman* GetRieman(){ return fRieman; }
- void DrawRiemanGraph();
+ TGraph* GetGraphPicked() { return fGraphPicked; }
+ TGraphErrors* GetGraphHelix() { return fGraphHelix; }
+ void DrawDebugGraph();
- TGraph* GetGraphSelected() { return fGraphSelected; }
- TGraphErrors* GetGraphFitted() { return fGraphFitted; }
+ virtual void DestroyElements(); // *MENU*
- ClassDef(AliEveTrackFitter, 0); // Interface to AliRieman fit.
-}; // endclass AliEveTrackFitter
+ ClassDef(AliEveTrackFitter, 0); // Interface of TEvePointSet allowing helix fit.
+};
#endif
ClassImp(AliEveTrackFitterEditor)
AliEveTrackFitterEditor::AliEveTrackFitterEditor(const TGWindow *p, Int_t width, Int_t height,
- UInt_t options, Pixel_t back) :
+ UInt_t options, Pixel_t back) :
TGedFrame(p, width, height, options | kVerticalFrame, back),
fM(0),
fFit(0),
MakeTitle("AliEveTrackFitter");
fStart = new TGTextButton(this, "Start");
- AddFrame(fStart, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 1, 1));
+ AddFrame(fStart, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 3, 1));
fStart->Connect("Clicked()",
"AliEveTrackFitterEditor", this, "DoStart()");
"AliEveTrackFitterEditor", this, "DoReset()");
fStop = new TGTextButton(this, "Stop");
- AddFrame(fStop, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 1, 1));
+ AddFrame(fStop, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 1, 1, 4));
fStop->Connect("Clicked()",
"AliEveTrackFitterEditor", this, "DoStop()");
- fGraph = new TGTextButton(this, " RiemanGraph ");
- AddFrame(fGraph, new TGLayoutHints(kLHintsLeft, 4, 2, 4, 1));
+ fGraph = new TGTextButton(this, "DebugGraph");
+ AddFrame(fGraph, new TGLayoutHints(kLHintsLeft | kLHintsExpandX, 4, 2, 4, 1));
fGraph->Connect("Clicked()",
"AliEveTrackFitterEditor", this, "DoGraph()");
}
}
}
+/**************************************************************************/
+
void AliEveTrackFitterEditor::DoFit()
{
// Fit slot.
fStart->SetState(kButtonUp);
}
-/******************************************************************************/
-
void AliEveTrackFitterEditor::DoGraph()
{
// Draw graph slot.
- fM->DrawRiemanGraph();
+ fM->DrawDebugGraph();
Update();
}
protected:
AliEveTrackFitter* fM; // fModel dynamic-casted to AliEveTrackFitterEditor
- TGTextButton* fFit; // button to fit selection
- TGTextButton* fReset; // button to reset selection
- TGTextButton* fStart; // button to connect to signal
- TGTextButton* fStop; // button to disconnect from signal
- TGTextButton* fGraph; // button to draw graph
+ TGTextButton* fFit; // button to fit selection
+ TGTextButton* fReset; // button to reset selection
+ TGTextButton* fStart; // button to connect to signal
+ TGTextButton* fStop; // button to disconnect from signal
+ TGTextButton* fGraph; // button to draw graph
public:
AliEveTrackFitterEditor(const TGWindow* p=0, Int_t width=170, Int_t height=30, UInt_t options = kChildFrame, Pixel_t back=GetDefaultFrameBackground());
void DoGraph();
ClassDef(AliEveTrackFitterEditor, 0); // Editor for AliEveTrackFitter class.
-}; // endclass AliEveTrackFitterEditor
+};
#endif