#include <AliStack.h>
#include <AliTrackReference.h>
-#include "Reve/Track.h"
-#include "Reve/RenderElement.h"
+#include <TEveTrack.h>
+#include <TEveElement.h>
#include <algorithm>
#include <map>
//______________________________________________________________________
// KineTools
//
-
-using namespace Reve;
using namespace Alieve;
using namespace std;
/**************************************************************************/
-void KineTools::SetDaughterPathMarks(TrackList* cont, AliStack* stack)
+void KineTools::SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse)
{
// Import daughters birth points.
- RenderElement::List_i iter = cont->BeginChildren();
+ TEveElement::List_i iter = cont->BeginChildren();
while(iter != cont->EndChildren())
{
- Track* track = dynamic_cast<Track*>(*iter);
+ TEveTrack* track = dynamic_cast<TEveTrack*>(*iter);
TParticle* p = stack->Particle(track->GetLabel());
if(p->GetNDaughters()) {
Int_t d0 = p->GetDaughter(0), d1 = p->GetDaughter(1);
- for(int d=d0; d>0 && d<=d1;++d)
+ for(int d=d0; d>0 && d<=d1; ++d)
{
TParticle* dp = stack->Particle(d);
- Reve::PathMark* pm = new PathMark( PathMark::Daughter);
- pm->V.Set(dp->Vx(),dp->Vy(), dp->Vz());
- pm->P.Set(dp->Px(),dp->Py(), dp->Pz());
- pm->time = dp->T();
+ TEvePathMark* pm = new TEvePathMark(TEvePathMark::kDaughter);
+ pm->fV.Set(dp->Vx(), dp->Vy(), dp->Vz());
+ pm->fP.Set(dp->Px(), dp->Py(), dp->Pz());
+ pm->fTime = dp->T();
track->AddPathMark(pm);
}
+ if (recurse)
+ SetDaughterPathMarks(track, stack, recurse);
}
++iter;
}
/**************************************************************************/
namespace {
-struct cmp_pathmark {
- bool operator()(PathMark* const & a, PathMark* const & b)
- { return a->time < b->time; }
+struct cmp_pathmark
+{
+ bool operator()(TEvePathMark* const & a, TEvePathMark* const & b)
+ { return a->fTime < b->fTime; }
};
-}
-void KineTools::SetPathMarks(TrackList* cont, AliStack* stack , TTree* treeTR)
+void slurp_tracks(map<Int_t, TEveTrack*>& tracks, TEveElement* cont, Bool_t recurse)
{
- // set decay and reference points
+ 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;
+ }
+}
- static const Exc_t eH("KineTools::ImportPathMarks");
+}
- if(treeTR == 0) {
- SetDaughterPathMarks(cont, stack);
- return;
- }
+void KineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_t recurse)
+{
+ // set decay and reference points
- map<Int_t, Track::vpPathMark_t > refs;
+ static const TEveException eH("KineTools::ImportPathMarks");
+ // Fill map
+ map<Int_t, TEveTrack*> tracks;
+ slurp_tracks(tracks, cont, recurse);
+
Int_t nPrimaries = (Int_t) treeTR->GetEntries();
TIter next(treeTR->GetListOfBranches());
TBranchElement* el;
Bool_t isRef = kTRUE;
- treeTR->SetBranchStatus("*", 0);
while ((el = (TBranchElement*) next()))
{
if (strcmp("AliRun",el->GetName()) == 0)
isRef = kFALSE;
- treeTR->SetBranchStatus(Form("%s*", el->GetName()), 1);
+ TClonesArray* arr = 0;
+ el->SetAddress(&arr);
for (Int_t iPrimPart = 0; iPrimPart<nPrimaries; iPrimPart++)
{
-
- TClonesArray* arr = 0;
- treeTR->SetBranchAddress(el->GetName(), &arr);
- treeTR->GetEntry(iPrimPart);
-
- for (Int_t iTrackRef = 0; iTrackRef < arr->GetEntriesFast(); iTrackRef++)
+ el->GetEntry(iPrimPart);
+
+ Int_t last_label = -1;
+ map<Int_t, TEveTrack*>::iterator iter = tracks.end();
+ Int_t Nent = arr->GetEntriesFast();
+ for (Int_t iTrackRef = 0; iTrackRef < Nent; iTrackRef++)
{
- AliTrackReference* atr = (AliTrackReference*)arr->At(iTrackRef);
- Int_t track = atr->GetTrack();
- if(atr->TestBit(TObject::kNotDeleted)) {
- if(track > 0)
- {
- PathMark* pm;
- if(isRef)
- pm = new PathMark(PathMark::Reference);
- else
- pm = new PathMark(PathMark::Decay);
-
- pm->V.Set(atr->X(),atr->Y(), atr->Z());
- pm->P.Set(atr->Px(),atr->Py(), atr->Pz());
- pm->time = atr->GetTime();
-
- Track::vpPathMark_t& v = refs[track];
- v.push_back(pm);
- }
- else
- throw(eH + Form("negative label for entry %d in branch %s.",
- iTrackRef, el->GetName());
+ AliTrackReference* atr = (AliTrackReference*)arr->UncheckedAt(iTrackRef);
+
+ Int_t label = atr->GetTrack();
+ if (label < 0)
+ throw(eH + Form("negative label for entry %d in branch %s.",
+ iTrackRef, el->GetName()));
+
+ if(label != last_label) {
+ iter = tracks.find(label);
+ last_label = label;
+ }
+
+ if (iter != tracks.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());
+ pm->fTime = atr->GetTime();
+ TEveTrack* track = iter->second;
+ track->AddPathMark(pm);
}
} // loop track refs
- treeTR->SetBranchAddress(el->GetName(), 0);
} // loop primaries, clones arrays
- treeTR->SetBranchStatus(Form("%s*", el->GetName()), 0);
+ delete arr;
} // end loop through top branches
- treeTR->SetBranchStatus("*", 1);
+}
- // sort references and add it to tracks
- RenderElement::List_i cit = cont->BeginChildren();
- while(cit != cont->EndChildren())
- {
- Track* track = dynamic_cast<Track*>(*cit);
+void KineTools::SortPathMarks(TEveElement* cont, Bool_t recurse)
+{
+ // Sort path-marks for all tracks by time.
- // add daughters path marks in the map
- TParticle* p = stack->Particle(track->GetLabel());
- if(p->GetNDaughters()) {
- for(int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter();++d)
- {
- TParticle* dp = stack->Particle(d);
- Reve::PathMark* pm = new PathMark( PathMark::Daughter);
- pm->V.Set(dp->Vx(),dp->Vy(), dp->Vz());
- pm->P.Set(dp->Px(),dp->Py(), dp->Pz());
- pm->time = dp->T();
- Track::vpPathMark_t& v = refs[track->GetLabel()];
- v.push_back(pm);
- }
- }
-
- map<Int_t, Track::vpPathMark_t > ::iterator mi = refs.find(track->GetLabel());
- if(mi != refs.end()) {
- Track::vpPathMark_t& v = mi->second;
- sort(v.begin(), v.end(), cmp_pathmark());
- for(Track::vpPathMark_i i=v.begin(); i!=v.end(); ++i){
- track->AddPathMark(*i);
- }
- }
- ++cit;
+ // Fill map
+ map<Int_t, TEveTrack*> tracks;
+ slurp_tracks(tracks, cont, recurse);
+
+ // sort
+ for(map<Int_t, TEveTrack*>::iterator j=tracks.begin(); j!=tracks.end(); ++j)
+ {
+ j->second->SortPathMarksByTime();
}
}