7 #include <TBranchElement.h>
8 #include <TClonesArray.h>
11 #include <AliTrackReference.h>
13 #include <TEveTrack.h>
14 #include <TEveElement.h>
19 //______________________________________________________________________
22 using namespace Alieve;
27 KineTools::KineTools()
30 /**************************************************************************/
32 void KineTools::SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse)
34 // Import daughters birth points.
36 TEveElement::List_i iter = cont->BeginChildren();
38 while(iter != cont->EndChildren())
40 TEveTrack* track = dynamic_cast<TEveTrack*>(*iter);
41 TParticle* p = stack->Particle(track->GetLabel());
42 if(p->GetNDaughters()) {
43 Int_t d0 = p->GetDaughter(0), d1 = p->GetDaughter(1);
44 for(int d=d0; d>0 && d<=d1; ++d)
46 TParticle* dp = stack->Particle(d);
47 TEvePathMark* pm = new TEvePathMark(TEvePathMark::kDaughter);
48 pm->fV.Set(dp->Vx(), dp->Vy(), dp->Vz());
49 pm->fP.Set(dp->Px(), dp->Py(), dp->Pz());
51 track->AddPathMark(pm);
54 SetDaughterPathMarks(track, stack, recurse);
60 /**************************************************************************/
65 bool operator()(TEvePathMark* const & a, TEvePathMark* const & b)
66 { return a->fTime < b->fTime; }
69 void slurp_tracks(map<Int_t, TEveTrack*>& tracks, TEveElement* cont, Bool_t recurse)
71 TEveElement::List_i citer = cont->BeginChildren();
72 while(citer != cont->EndChildren())
74 TEveTrack* track = dynamic_cast<TEveTrack*>(*citer);
75 tracks[track->GetLabel()] = track;
77 slurp_tracks(tracks, track, recurse);
84 void KineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_t recurse)
86 // set decay and reference points
88 static const TEveException eH("KineTools::ImportPathMarks");
91 map<Int_t, TEveTrack*> tracks;
92 slurp_tracks(tracks, cont, recurse);
94 Int_t nPrimaries = (Int_t) treeTR->GetEntries();
95 TIter next(treeTR->GetListOfBranches());
99 while ((el = (TBranchElement*) next()))
101 if (strcmp("AliRun",el->GetName()) == 0)
104 TClonesArray* arr = 0;
105 el->SetAddress(&arr);
106 for (Int_t iPrimPart = 0; iPrimPart<nPrimaries; iPrimPart++)
108 el->GetEntry(iPrimPart);
110 Int_t last_label = -1;
111 map<Int_t, TEveTrack*>::iterator iter = tracks.end();
112 Int_t Nent = arr->GetEntriesFast();
113 for (Int_t iTrackRef = 0; iTrackRef < Nent; iTrackRef++)
115 AliTrackReference* atr = (AliTrackReference*)arr->UncheckedAt(iTrackRef);
117 Int_t label = atr->GetTrack();
119 throw(eH + Form("negative label for entry %d in branch %s.",
120 iTrackRef, el->GetName()));
122 if(label != last_label) {
123 iter = tracks.find(label);
127 if (iter != tracks.end()) {
128 TEvePathMark* pm = new TEvePathMark(isRef ? TEvePathMark::kReference : TEvePathMark::kDecay);
129 pm->fV.Set(atr->X(),atr->Y(), atr->Z());
130 pm->fP.Set(atr->Px(),atr->Py(), atr->Pz());
131 pm->fTime = atr->GetTime();
132 TEveTrack* track = iter->second;
133 track->AddPathMark(pm);
136 } // loop primaries, clones arrays
138 } // end loop through top branches
141 void KineTools::SortPathMarks(TEveElement* cont, Bool_t recurse)
143 // Sort path-marks for all tracks by time.
146 map<Int_t, TEveTrack*> tracks;
147 slurp_tracks(tracks, cont, recurse);
150 for(map<Int_t, TEveTrack*>::iterator j=tracks.begin(); j!=tracks.end(); ++j)
152 j->second->SortPathMarksByTime();