]>
Commit | Line | Data |
---|---|---|
d810d0de | 1 | // $Id$ |
2 | // Main authors: Matevz Tadel & Alja Mrak-Tadel: 2006, 2007 | |
c63fcc1d | 3 | |
d810d0de | 4 | /************************************************************************** |
5 | * Copyright(c) 1998-2008, ALICE Experiment at CERN, all rights reserved. * | |
6 | * See http://aliceinfo.cern.ch/Offline/AliRoot/License.html for * | |
51346b82 | 7 | * full copyright notice. * |
d810d0de | 8 | **************************************************************************/ |
9 | ||
10 | #include "AliEveKineTools.h" | |
0e33c639 | 11 | #include "AliEveTrack.h" |
7704f096 | 12 | |
c63fcc1d | 13 | #include <AliStack.h> |
14 | #include <AliTrackReference.h> | |
15 | ||
0e33c639 | 16 | #include <TTree.h> |
17 | #include <TBranchElement.h> | |
18 | #include <TClonesArray.h> | |
d05591ca | 19 | #include <TParticle.h> |
c63fcc1d | 20 | |
7704f096 | 21 | #include <map> |
c63fcc1d | 22 | |
57ffa5fb | 23 | //______________________________________________________________________________ |
d810d0de | 24 | // AliEveKineTools |
c63fcc1d | 25 | // |
d4369ead | 26 | // Tools for import of kinematics. |
40790e5b | 27 | // |
d810d0de | 28 | |
d810d0de | 29 | ClassImp(AliEveKineTools) |
c63fcc1d | 30 | |
40790e5b | 31 | namespace { |
32 | ||
2142305c | 33 | // Map to store label-to-track association. |
34 | // | |
35 | // multimap is used as there are cases when initial particles (in | |
36 | // particular resonances) are not assigned proper status-codes | |
37 | // and can thus be found several times in the eve-track-list. | |
38 | ||
0e33c639 | 39 | typedef std::multimap<Int_t, AliEveTrack*> TrackMap_t; |
40 | typedef std::multimap<Int_t, AliEveTrack*>::const_iterator TrackMap_ci; | |
40790e5b | 41 | |
42 | void MapTracks(TrackMap_t& map, TEveElement* cont, Bool_t recurse) | |
43 | { | |
44 | TEveElement::List_i i = cont->BeginChildren(); | |
45 | while (i != cont->EndChildren()) { | |
04a6d27f | 46 | AliEveTrack* track = static_cast<AliEveTrack*>(*i); |
2142305c | 47 | map.insert(std::make_pair(track->GetLabel(), track)); |
40790e5b | 48 | if (recurse) |
49 | MapTracks(map, track, recurse); | |
50 | ++i; | |
51 | } | |
52 | } | |
53 | } | |
54 | ||
55 | /**************************************************************************/ | |
76461dad | 56 | |
d810d0de | 57 | void AliEveKineTools::SetDaughterPathMarks(TEveElement* cont, AliStack* stack, Bool_t recurse) |
c63fcc1d | 58 | { |
76461dad | 59 | // Import daughters birth points. |
60 | ||
84aff7a4 | 61 | TEveElement::List_i iter = cont->BeginChildren(); |
c63fcc1d | 62 | while(iter != cont->EndChildren()) |
63 | { | |
04a6d27f | 64 | AliEveTrack* track = static_cast<AliEveTrack*>(*iter); |
c63fcc1d | 65 | TParticle* p = stack->Particle(track->GetLabel()); |
a15e6d7d | 66 | if (p->GetNDaughters()) |
67 | { | |
c63fcc1d | 68 | Int_t d0 = p->GetDaughter(0), d1 = p->GetDaughter(1); |
a15e6d7d | 69 | for(int d = d0; d > 0 && d <= d1; ++d) |
51346b82 | 70 | { |
c63fcc1d | 71 | TParticle* dp = stack->Particle(d); |
a15e6d7d | 72 | track->AddPathMark(TEvePathMark(TEvePathMark::kDaughter, |
73 | TEveVector(dp->Vx(), dp->Vy(), dp->Vz()), | |
74 | TEveVector(dp->Px(), dp->Py(), dp->Pz()), | |
75 | dp->T())); | |
d4369ead | 76 | // printf("Daughter path-mark for %d, %d, t=%e, r=%f,%f,%f\n", |
77 | // track->GetLabel(), d, dp->T(), dp->Vx(), dp->Vy(), dp->Vz()); | |
c63fcc1d | 78 | } |
804bb570 | 79 | |
80 | // Check last process, set decay if needed. | |
81 | Int_t lp = stack->Particle(d1)->GetUniqueID(); | |
82 | if (lp != kPBrem && lp != kPDeltaRay && lp < kPCerenkov) | |
83 | { | |
84 | TParticle* dp = stack->Particle(d1); | |
85 | track->AddPathMark(TEvePathMark(TEvePathMark::kDecay, | |
86 | TEveVector(dp->Vx(), dp->Vy(), dp->Vz()), | |
87 | TEveVector(0, 0,0), dp->T())); | |
88 | } | |
89 | ||
27aa96b0 | 90 | if (recurse) |
91 | SetDaughterPathMarks(track, stack, recurse); | |
c63fcc1d | 92 | } |
93 | ++iter; | |
94 | } | |
95 | } | |
96 | ||
40790e5b | 97 | /**************************************************************************/ |
974767e6 | 98 | |
d810d0de | 99 | void AliEveKineTools::SetTrackReferences(TEveElement* cont, TTree* treeTR, Bool_t recurse) |
974767e6 | 100 | { |
40790e5b | 101 | // Set decay and track reference path-marks. |
974767e6 | 102 | |
a15e6d7d | 103 | static const TEveException kEH("AliEveKineTools::ImportPathMarks"); |
974767e6 | 104 | |
40790e5b | 105 | TrackMap_t map; |
106 | MapTracks(map, cont, recurse); | |
51346b82 | 107 | |
d4369ead | 108 | TClonesArray* arr = 0; |
109 | treeTR->SetBranchAddress("TrackReferences", &arr); | |
c63fcc1d | 110 | |
d4369ead | 111 | Int_t nTreeEntries = (Int_t) treeTR->GetEntries(); |
112 | ||
113 | for (Int_t te = 0; te < nTreeEntries; ++te) | |
c63fcc1d | 114 | { |
d4369ead | 115 | treeTR->GetEntry(te); |
116 | ||
117 | Int_t last_label = -1; | |
2142305c | 118 | std::pair<TrackMap_ci, TrackMap_ci> range; |
d4369ead | 119 | Int_t nArrEntries = arr->GetEntriesFast(); |
120 | ||
121 | // printf("tree-entry %d, n-arr-entries %d\n", te, nArrEntries); | |
c63fcc1d | 122 | |
d4369ead | 123 | for (Int_t ae = 0; ae < nArrEntries; ++ae) |
c63fcc1d | 124 | { |
d4369ead | 125 | AliTrackReference* atr = (AliTrackReference*)arr->UncheckedAt(ae); |
126 | Bool_t isRef = (atr->DetectorId() != -1); | |
127 | Int_t label = atr->GetTrack(); | |
128 | ||
129 | // printf(" arr-entry %d, label %d, detid %d, len=%f, t=%e r=%f,%f,%f\n", | |
130 | // ae, label, atr->DetectorId(), | |
131 | // atr->GetLength(), atr->GetTime(), atr->X(), atr->Y(), atr->Z()); | |
132 | ||
133 | if (label < 0) | |
134 | throw(kEH + Form("negative label for array-entry %d in tree-entry %d.", | |
135 | ae, te)); | |
136 | ||
137 | if (label != last_label) | |
138 | { | |
2142305c | 139 | range = map.equal_range(label); |
d4369ead | 140 | last_label = label; |
141 | } | |
1d74e2b0 | 142 | |
2142305c | 143 | for (TrackMap_ci i = range.first; i != range.second; ++i) |
c63fcc1d | 144 | { |
2142305c | 145 | i->second->AddPathMark |
d4369ead | 146 | (TEvePathMark(isRef ? TEvePathMark::kReference : TEvePathMark::kDecay, |
147 | TEveVector(atr->X(), atr->Y(), atr->Z()), | |
148 | TEveVector(atr->Px(), atr->Py(), atr->Pz()), | |
149 | atr->GetTime())); | |
150 | } | |
151 | } | |
152 | } | |
153 | delete arr; | |
27aa96b0 | 154 | } |
155 | ||
40790e5b | 156 | /**************************************************************************/ |
157 | ||
158 | void AliEveKineTools::SortPathMarks(TEveElement* el, Bool_t recurse) | |
27aa96b0 | 159 | { |
d4369ead | 160 | // Sort path-marks for track by time. |
161 | // If recurse is true, descends down all track children. | |
a15e6d7d | 162 | |
0e33c639 | 163 | AliEveTrack* track = dynamic_cast<AliEveTrack*>(el); |
d4369ead | 164 | if (track) |
165 | track->SortPathMarksByTime(); | |
c63fcc1d | 166 | |
d4369ead | 167 | if (recurse) |
a15e6d7d | 168 | { |
d4369ead | 169 | for (TEveElement::List_i i = el->BeginChildren(); i != el->EndChildren(); ++i) |
170 | SortPathMarks(*i, kTRUE); | |
c63fcc1d | 171 | } |
172 | } |