7 #include <TBranchElement.h>
8 #include <TClonesArray.h>
11 #include <AliTrackReference.h>
13 #include "Reve/Track.h"
14 #include "Reve/RenderElement.h"
19 //______________________________________________________________________
24 using namespace Alieve;
29 KineTools::KineTools()
34 /**************************************************************************/
35 void KineTools::SetDaughterPathMarks(TrackList* cont, AliStack* stack )
37 // import daughters birth points
38 RenderElement::List_i iter = cont->BeginChildren();
40 while(iter != cont->EndChildren())
42 Track* track = dynamic_cast<Track*>(*iter);
43 TParticle* p = stack->Particle(track->GetLabel());
44 if(p->GetNDaughters()) {
45 Int_t d0 = p->GetDaughter(0), d1 = p->GetDaughter(1);
46 for(int d=d0; d>0 && d<=d1;++d)
48 TParticle* dp = stack->Particle(d);
49 Reve::PathMark* pm = new PathMark( PathMark::Daughter);
50 pm->V.Set(dp->Vx(),dp->Vy(), dp->Vz());
51 pm->P.Set(dp->Px(),dp->Py(), dp->Pz());
53 track->AddPathMark(pm);
60 /**************************************************************************/
64 bool operator()(PathMark* const & a, PathMark* const & b)
65 { return a->time < b->time; }
69 void KineTools::SetPathMarks(TrackList* cont, AliStack* stack , TTree* treeTR)
71 // set decay and reference points
73 static const Exc_t eH("KineTools::ImportPathMarks");
76 SetDaughterPathMarks(cont, stack);
80 map<Int_t, Track::vpPathMark_t > refs;
82 Int_t nPrimaries = (Int_t) treeTR->GetEntries();
83 TIter next(treeTR->GetListOfBranches());
86 treeTR->SetBranchStatus("*",0);
88 while ((el = (TBranchElement*) next()))
90 if (strcmp("AliRun",el->GetName()) == 0)
93 treeTR->SetBranchStatus(Form("%s*", el->GetName()), 1);
94 for (Int_t iPrimPart = 0; iPrimPart<nPrimaries; iPrimPart++)
97 TClonesArray* arr = 0;
98 treeTR->SetBranchAddress(el->GetName(), &arr);
99 treeTR->GetEntry(iPrimPart);
101 for (Int_t iTrackRef = 0; iTrackRef < arr->GetEntriesFast(); iTrackRef++)
103 AliTrackReference* atr = (AliTrackReference*)arr->At(iTrackRef);
104 Int_t track = atr->GetTrack();
105 if(atr->TestBit(TObject::kNotDeleted)) {
110 pm = new PathMark(PathMark::Reference);
112 pm = new PathMark(PathMark::Decay);
114 pm->V.Set(atr->X(),atr->Y(), atr->Z());
115 pm->P.Set(atr->Px(),atr->Py(), atr->Pz());
116 pm->time = atr->GetTime();
118 Track::vpPathMark_t& v = refs[track];
122 throw(eH + "negative label for entry " + Form("%d",iTrackRef) + " in branch " + el->GetName()+ ".");
125 treeTR->SetBranchAddress(el->GetName(), 0);
126 } // loop primaries, clones arrays
127 treeTR->SetBranchStatus(Form("%s*", el->GetName()), 0);
128 } // end loop through top branches
131 // sort references and add it to tracks
132 RenderElement::List_i cit = cont->BeginChildren();
133 while(cit != cont->EndChildren())
135 Track* track = dynamic_cast<Track*>(*cit);
137 // add daughters path marks in the map
138 TParticle* p = stack->Particle(track->GetLabel());
139 if(p->GetNDaughters()) {
140 for(int d=p->GetFirstDaughter(); d>0 && d<=p->GetLastDaughter();++d)
142 TParticle* dp = stack->Particle(d);
143 Reve::PathMark* pm = new PathMark( PathMark::Daughter);
144 pm->V.Set(dp->Vx(),dp->Vy(), dp->Vz());
145 pm->P.Set(dp->Px(),dp->Py(), dp->Pz());
147 Track::vpPathMark_t& v = refs[track->GetLabel()];
152 map<Int_t, Track::vpPathMark_t > ::iterator mi = refs.find(track->GetLabel());
153 if(mi != refs.end()) {
154 Track::vpPathMark_t& v = mi->second;
155 sort(v.begin(), v.end(), cmp_pathmark());
156 for(Track::vpPathMark_i i=v.begin(); i!=v.end(); ++i){
157 track->AddPathMark(*i);