]>
Commit | Line | Data |
---|---|---|
5a5a1232 | 1 | // $Header$ |
2 | ||
3 | #include "Track.h" | |
4 | #include "MCHelixLine.hi" | |
7cbaaebd | 5 | #include "PointSet.h" |
5a5a1232 | 6 | |
7 | #include <TPolyLine3D.h> | |
32e219c2 | 8 | #include <TMarker.h> |
5a5a1232 | 9 | #include <TPolyMarker3D.h> |
10 | #include <TColor.h> | |
11 | ||
12 | // Updates | |
32e219c2 | 13 | #include <Reve/ReveManager.h> |
17038a14 | 14 | #include <Reve/RGBrowser.h> |
32e219c2 | 15 | #include <Reve/NLTTrack.h> |
5a5a1232 | 16 | #include <TCanvas.h> |
17 | ||
18 | #include <vector> | |
5ba491d8 | 19 | #include <algorithm> |
20 | #include <functional> | |
21 | #include <iostream> | |
5a5a1232 | 22 | |
23 | using namespace Reve; | |
24 | ||
2b801b28 | 25 | //______________________________________________________________________________ |
5a5a1232 | 26 | // Track |
27 | // | |
17038a14 | 28 | // Visual representation of a track. |
29 | // | |
5a5a1232 | 30 | |
31 | ClassImp(Reve::Track) | |
32 | ||
2b801b28 | 33 | //______________________________________________________________________________ |
265ecb21 | 34 | Track::Track() : |
eadaa89b | 35 | Line(), |
5a5a1232 | 36 | |
265ecb21 | 37 | fV(), |
38 | fP(), | |
39 | fBeta(0), | |
40 | fCharge(0), | |
17038a14 | 41 | fLabel(kMinInt), |
42 | fIndex(kMinInt), | |
265ecb21 | 43 | fPathMarks(), |
44 | ||
eadaa89b | 45 | fRnrStyle(0) |
265ecb21 | 46 | {} |
47 | ||
2b801b28 | 48 | //______________________________________________________________________________ |
3d75306d | 49 | Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs): |
eadaa89b | 50 | Line(), |
3d75306d | 51 | |
52 | fV(t->Vx(), t->Vy(), t->Vz()), | |
53 | fP(t->Px(), t->Py(), t->Pz()), | |
54 | fBeta(t->P()/t->Energy()), | |
55 | fCharge(0), | |
56 | fLabel(label), | |
17038a14 | 57 | fIndex(kMinInt), |
3d75306d | 58 | fPathMarks(), |
59 | ||
32e219c2 | 60 | fRnrStyle(0) |
3d75306d | 61 | { |
32e219c2 | 62 | SetRnrStyle(rs); |
3d75306d | 63 | fMainColorPtr = &fLineColor; |
64 | ||
65 | TParticlePDG* pdgp = t->GetPDG(); | |
66 | if (pdgp) | |
67 | fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3); | |
eadaa89b | 68 | |
69 | SetName(t->GetName()); | |
3d75306d | 70 | } |
71 | ||
2b801b28 | 72 | //______________________________________________________________________________ |
265ecb21 | 73 | Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs): |
eadaa89b | 74 | Line(), |
5a5a1232 | 75 | |
265ecb21 | 76 | fV(t->Vx(), t->Vy(), t->Vz()), |
77 | fP(t->Px(), t->Py(), t->Pz()), | |
78 | fBeta(t->P()/t->Energy()), | |
79 | fCharge(0), | |
80 | fLabel(t->label), | |
fa446a68 | 81 | fIndex(t->index), |
265ecb21 | 82 | fPathMarks(), |
83 | ||
32e219c2 | 84 | fRnrStyle(0) |
265ecb21 | 85 | { |
32e219c2 | 86 | SetRnrStyle(rs); |
5a5a1232 | 87 | fMainColorPtr = &fLineColor; |
88 | ||
5a5a1232 | 89 | TParticlePDG* pdgp = t->GetPDG(); |
90 | if(pdgp == 0) { | |
91 | t->ResetPdgCode(); pdgp = t->GetPDG(); | |
92 | } | |
48dc973d | 93 | fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3); |
eadaa89b | 94 | |
95 | SetName(t->GetName()); | |
5a5a1232 | 96 | } |
97 | ||
2b801b28 | 98 | //______________________________________________________________________________ |
265ecb21 | 99 | Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) : |
eadaa89b | 100 | Line(), |
265ecb21 | 101 | |
102 | fV(t->V), | |
103 | fP(t->P), | |
104 | fBeta(t->beta), | |
105 | fCharge(t->sign), | |
106 | fLabel(t->label), | |
fa446a68 | 107 | fIndex(t->index), |
265ecb21 | 108 | fPathMarks(), |
109 | ||
32e219c2 | 110 | fRnrStyle(0) |
5a5a1232 | 111 | { |
32e219c2 | 112 | SetRnrStyle(rs); |
5a5a1232 | 113 | fMainColorPtr = &fLineColor; |
eadaa89b | 114 | |
115 | SetName(t->GetName()); | |
5a5a1232 | 116 | } |
117 | ||
2b801b28 | 118 | //______________________________________________________________________________ |
5a5a1232 | 119 | Track::~Track() |
265ecb21 | 120 | { |
32e219c2 | 121 | SetRnrStyle(0); |
265ecb21 | 122 | for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) |
123 | delete *i; | |
124 | } | |
5a5a1232 | 125 | |
2b801b28 | 126 | //______________________________________________________________________________ |
32e219c2 | 127 | Track::Track(const Track& t) : |
128 | Line(), | |
129 | TQObject(), | |
130 | fV(t.fV), | |
131 | fP(t.fP), | |
132 | fBeta(t.fBeta), | |
133 | fCharge(t.fCharge), | |
134 | fLabel(t.fLabel), | |
135 | fIndex(t.fIndex), | |
136 | fPathMarks(), | |
137 | fRnrStyle(0) | |
138 | { | |
2b801b28 | 139 | // Copy constructor. |
140 | ||
32e219c2 | 141 | SetMainColor(t.GetMainColor()); |
142 | // Line | |
2b801b28 | 143 | fRnrLine = t.fRnrLine; |
32e219c2 | 144 | fRnrPoints = t.fRnrPoints; |
145 | // TLineAttrib | |
146 | fLineColor = t.fLineColor; | |
147 | fLineStyle = t.fLineStyle; | |
148 | fLineWidth = t.fLineWidth; | |
2b801b28 | 149 | SetPathMarks(t); |
150 | SetRnrStyle (t.fRnrStyle); | |
32e219c2 | 151 | } |
152 | ||
2b801b28 | 153 | //______________________________________________________________________________ |
32e219c2 | 154 | void Track::SetTrackParams(const Track& t) |
155 | { | |
2b801b28 | 156 | // Copy track parameters from t. |
157 | // PathMarks are cleared. | |
158 | ||
159 | fV = t.fV; | |
160 | fP = t.fP; | |
161 | fBeta = t.fBeta; | |
162 | fCharge = t.fCharge; | |
163 | fLabel = t.fLabel; | |
164 | fIndex = t.fIndex; | |
32e219c2 | 165 | |
166 | SetMainColor(t.GetMainColor()); | |
167 | // Line | |
168 | fRnrLine = t.fRnrLine; | |
169 | fRnrPoints = t.fRnrPoints; | |
170 | // TLineAttrib | |
171 | fLineColor = t.fLineColor; | |
172 | fLineStyle = t.fLineStyle; | |
173 | fLineWidth = t.fLineWidth; | |
2b801b28 | 174 | fPathMarks.clear(); |
32e219c2 | 175 | SetRnrStyle(t.fRnrStyle); |
176 | } | |
177 | ||
2b801b28 | 178 | //______________________________________________________________________________ |
179 | void Track::SetPathMarks(const Track& t) | |
5a5a1232 | 180 | { |
2b801b28 | 181 | // Copy path-marks from t. |
182 | ||
183 | const std::vector<PathMark*>& refs = t.GetPathMarksRef(); | |
184 | for(std::vector<PathMark*>::const_iterator i=refs.begin(); i!=refs.end(); ++i) | |
185 | { | |
186 | fPathMarks.push_back(new PathMark(**i)); | |
187 | } | |
5a5a1232 | 188 | } |
189 | ||
2b801b28 | 190 | /******************************************************************************/ |
191 | ||
192 | //______________________________________________________________________________ | |
32e219c2 | 193 | void Track::SetRnrStyle(TrackRnrStyle* rs) |
194 | { | |
195 | if (fRnrStyle == rs) return; | |
196 | if (fRnrStyle) fRnrStyle->DecRefCount(this); | |
197 | fRnrStyle = rs; | |
198 | if (fRnrStyle) rs->IncRefCount(this); | |
199 | } | |
200 | ||
2b801b28 | 201 | /******************************************************************************/ |
202 | ||
203 | //______________________________________________________________________________ | |
32e219c2 | 204 | void Track::SetAttLineAttMarker(TrackList* tl) |
205 | { | |
206 | SetLineColor(tl->GetLineColor()); | |
207 | SetLineStyle(tl->GetLineStyle()); | |
208 | SetLineWidth(tl->GetLineWidth()); | |
209 | ||
210 | SetMarkerColor(tl->GetMarkerColor()); | |
211 | SetMarkerStyle(tl->GetMarkerStyle()); | |
212 | SetMarkerSize(tl->GetMarkerSize()); | |
213 | } | |
214 | ||
2b801b28 | 215 | /******************************************************************************/ |
5a5a1232 | 216 | |
2b801b28 | 217 | //______________________________________________________________________________ |
a8a51cc7 | 218 | void Track::MakeTrack(Bool_t recurse) |
5a5a1232 | 219 | { |
5a5a1232 | 220 | TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle); |
221 | ||
222 | Float_t px = fP.x, py = fP.y, pz = fP.z; | |
223 | ||
224 | MCVertex mc_v0; | |
225 | mc_v0.x = fV.x; | |
226 | mc_v0.y = fV.y; | |
227 | mc_v0.z = fV.z; | |
228 | mc_v0.t = 0; | |
229 | ||
230 | std::vector<MCVertex> track_points; | |
48dc973d | 231 | Bool_t decay = kFALSE; |
5a5a1232 | 232 | |
233 | if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR)) | |
234 | goto make_polyline; | |
235 | ||
32e219c2 | 236 | if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5 && fP.Perp2() > 1e-6) |
237 | { | |
238 | // Charged particle in magnetic field with non-zero pT. | |
5a5a1232 | 239 | |
48dc973d | 240 | Float_t a = RS.fgkB2C * RS.fMagField * fCharge; |
5a5a1232 | 241 | |
242 | MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm | |
243 | helix.Init(TMath::Sqrt(px*px+py*py), pz); | |
b855ed81 | 244 | // Set max number of points for loop-to-vertex. |
245 | // loop-to-bounds (last step) does this separately. | |
246 | helix.NMax = 4096; | |
5a5a1232 | 247 | |
b855ed81 | 248 | if (!fPathMarks.empty()) |
7cbaaebd | 249 | { |
250 | for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) | |
251 | { | |
5a5a1232 | 252 | Reve::PathMark* pm = *i; |
253 | ||
7cbaaebd | 254 | if (RS.fFitReferences && pm->type == Reve::PathMark::Reference) |
255 | { | |
b855ed81 | 256 | if(TMath::Abs(pm->V.z) > RS.fMaxZ || |
32e219c2 | 257 | TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR) |
5a5a1232 | 258 | goto helix_bounds; |
259 | ||
7cbaaebd | 260 | // printf("%s fit reference \n", fName.Data()); |
261 | helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z); | |
32e219c2 | 262 | px = pm->P.x; |
263 | py = pm->P.y; | |
264 | pz = pm->P.z; | |
5a5a1232 | 265 | } |
7cbaaebd | 266 | else if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter) |
267 | { | |
32e219c2 | 268 | if(TMath::Abs(pm->V.z) > RS.fMaxZ || |
269 | TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR) | |
5a5a1232 | 270 | goto helix_bounds; |
7cbaaebd | 271 | |
272 | // printf("%s fit daughter \n", fName.Data()); | |
273 | helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z); | |
32e219c2 | 274 | px -= pm->P.x; |
275 | py -= pm->P.y; | |
276 | pz -= pm->P.z; | |
7cbaaebd | 277 | } |
278 | else if(RS.fFitDecay && pm->type == Reve::PathMark::Decay) | |
279 | { | |
32e219c2 | 280 | if(TMath::Abs(pm->V.z) > RS.fMaxZ || |
281 | TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR) | |
7cbaaebd | 282 | goto helix_bounds; |
283 | helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z); | |
5a5a1232 | 284 | decay = true; |
285 | break; | |
286 | } | |
b855ed81 | 287 | if (track_points.size() > 4096) |
288 | { | |
289 | Warning("Track::MakeTrack", "exceeding 4k points (%u) for '%s'; aborting extrapolation.", | |
290 | track_points.size(), GetName()); | |
291 | goto make_polyline; | |
292 | } | |
5a5a1232 | 293 | } |
294 | } | |
295 | helix_bounds: | |
7cbaaebd | 296 | // go to bounds |
32e219c2 | 297 | if(!decay || RS.fFitDecay == kFALSE) |
298 | { | |
5a5a1232 | 299 | helix.LoopToBounds(px,py,pz); |
300 | // printf("%s loop to bounds \n",fName.Data() ); | |
301 | } | |
302 | ||
01024c63 | 303 | } else { |
304 | ||
305 | // Neutral particle or no field | |
5a5a1232 | 306 | |
307 | MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points); | |
308 | ||
32e219c2 | 309 | if(!fPathMarks.empty()) |
310 | { | |
311 | for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) | |
312 | { | |
5a5a1232 | 313 | Reve::PathMark* pm = *i; |
314 | ||
32e219c2 | 315 | if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter) |
316 | { | |
317 | if(TMath::Abs(pm->V.z) > RS.fMaxZ || | |
318 | TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR) | |
319 | { | |
5a5a1232 | 320 | goto line_bounds; |
32e219c2 | 321 | } |
5a5a1232 | 322 | line.GotoVertex(pm->V.x, pm->V.y, pm->V.z); |
32e219c2 | 323 | fP.x -= pm->P.x; |
324 | fP.y -= pm->P.y; | |
325 | fP.z -= pm->P.z; | |
5a5a1232 | 326 | } |
327 | ||
32e219c2 | 328 | if(RS.fFitDecay && pm->type == Reve::PathMark::Decay) |
329 | { | |
330 | if(TMath::Abs(pm->V.z) > RS.fMaxZ || | |
331 | TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR) | |
332 | { | |
5a5a1232 | 333 | goto line_bounds; |
32e219c2 | 334 | } |
5a5a1232 | 335 | line.GotoVertex(pm->V.x, pm->V.y, pm->V.z); |
336 | decay = true; | |
337 | break; | |
338 | } | |
339 | } | |
340 | } | |
341 | ||
342 | line_bounds: | |
48dc973d | 343 | if(!decay || RS.fFitDecay == kFALSE) |
5a5a1232 | 344 | line.GotoBounds(px,py,pz); |
345 | ||
346 | } | |
347 | make_polyline: | |
b855ed81 | 348 | { |
349 | Int_t size = TMath::Min(4096, (Int_t) track_points.size()); | |
350 | // printf("track '%s' N = %u\n", GetName(), track_points.size()); | |
351 | Reset(size); | |
352 | for(Int_t i=0; i<size; ++i) | |
353 | { | |
2b801b28 | 354 | const MCVertex& v = track_points[i]; |
b855ed81 | 355 | SetNextPoint(v.x, v.y, v.z); |
356 | } | |
357 | } | |
2fbbf445 | 358 | |
32e219c2 | 359 | if(recurse) |
360 | { | |
a8a51cc7 | 361 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) |
362 | { | |
363 | Track* t = dynamic_cast<Track*>(*i); | |
364 | if(t) t->MakeTrack(recurse); | |
2fbbf445 | 365 | } |
366 | } | |
32e219c2 | 367 | } |
368 | ||
2b801b28 | 369 | /******************************************************************************/ |
370 | ||
371 | //______________________________________________________________________________ | |
32e219c2 | 372 | TClass* Track::ProjectedClass() const |
373 | { | |
374 | return NLTTrack::Class(); | |
5a5a1232 | 375 | } |
376 | ||
2b801b28 | 377 | /******************************************************************************/ |
a8a51cc7 | 378 | |
ba008f46 | 379 | namespace { |
a8a51cc7 | 380 | |
381 | struct cmp_pathmark | |
382 | { | |
ba008f46 | 383 | bool operator()(PathMark* const & a, PathMark* const & b) |
384 | { return a->time < b->time; } | |
385 | }; | |
a8a51cc7 | 386 | |
ba008f46 | 387 | } |
388 | ||
2b801b28 | 389 | //______________________________________________________________________________ |
ba008f46 | 390 | void Track::SortPathMarksByTime() |
391 | { | |
b855ed81 | 392 | std::sort(fPathMarks.begin(), fPathMarks.end(), cmp_pathmark()); |
ba008f46 | 393 | } |
394 | ||
2b801b28 | 395 | /******************************************************************************/ |
5a5a1232 | 396 | |
2b801b28 | 397 | //______________________________________________________________________________ |
48dc973d | 398 | void Track::ImportHits() |
399 | { | |
400 | Reve::LoadMacro("hits_from_label.C"); | |
2fbbf445 | 401 | gROOT->ProcessLine(Form("hits_from_label(%d, (Reve::RenderElement*)%p);", |
402 | fLabel, this)); | |
48dc973d | 403 | } |
404 | ||
2b801b28 | 405 | //______________________________________________________________________________ |
48dc973d | 406 | void Track::ImportClusters() |
407 | { | |
408 | Reve::LoadMacro("clusters_from_label.C"); | |
2fbbf445 | 409 | gROOT->ProcessLine(Form("clusters_from_label(%d, (Reve::RenderElement*)%p);", |
410 | fLabel, this)); | |
48dc973d | 411 | } |
412 | ||
2b801b28 | 413 | //______________________________________________________________________________ |
fa446a68 | 414 | void Track::ImportClustersFromIndex() |
415 | { | |
7cbaaebd | 416 | static const Exc_t eH("Track::ImportClustersFromIndex "); |
417 | ||
17038a14 | 418 | if (fIndex == kMinInt) |
7cbaaebd | 419 | throw(eH + "index not set."); |
420 | ||
fa446a68 | 421 | Reve::LoadMacro("clusters_from_index.C"); |
2fbbf445 | 422 | gROOT->ProcessLine(Form("clusters_from_index(%d, (Reve::RenderElement*)%p);", |
423 | fIndex, this)); | |
fa446a68 | 424 | } |
425 | ||
2b801b28 | 426 | /******************************************************************************/ |
b8879e69 | 427 | |
2b801b28 | 428 | //______________________________________________________________________________ |
b8879e69 | 429 | void Track::ImportKine() |
430 | { | |
431 | static const Exc_t eH("Track::ImportKine "); | |
432 | ||
17038a14 | 433 | if (fLabel == kMinInt) |
b8879e69 | 434 | throw(eH + "label not set."); |
435 | ||
17038a14 | 436 | Int_t label; |
437 | if (fLabel < 0) { | |
438 | Warning(eH, "label negative, taking absolute value."); | |
439 | label = -fLabel; | |
440 | } else { | |
441 | label = fLabel; | |
442 | } | |
443 | ||
b8879e69 | 444 | Reve::LoadMacro("kine_tracks.C"); |
2fbbf445 | 445 | gROOT->ProcessLine(Form("kine_track(%d, kFALSE, kTRUE, (Reve::RenderElement*)%p);", |
17038a14 | 446 | label, this)); |
2fbbf445 | 447 | |
b8879e69 | 448 | } |
449 | ||
2b801b28 | 450 | //______________________________________________________________________________ |
b8879e69 | 451 | void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters) |
a525aa60 | 452 | { |
b8879e69 | 453 | static const Exc_t eH("Track::ImportKineWithArgs "); |
a525aa60 | 454 | |
17038a14 | 455 | if (fLabel == kMinInt) |
a525aa60 | 456 | throw(eH + "label not set."); |
457 | ||
17038a14 | 458 | Int_t label; |
459 | if (fLabel < 0) { | |
460 | Warning(eH, "label negative, taking absolute value."); | |
461 | label = -fLabel; | |
462 | } else { | |
463 | label = fLabel; | |
464 | } | |
465 | ||
b8879e69 | 466 | Reve::LoadMacro("kine_tracks.C"); |
2fbbf445 | 467 | gROOT->ProcessLine(Form("kine_track(%d, %d, %d, (Reve::RenderElement*)%p);", |
17038a14 | 468 | label, importMother, importDaugters, this)); |
a525aa60 | 469 | } |
470 | ||
2b801b28 | 471 | /******************************************************************************/ |
a525aa60 | 472 | |
2b801b28 | 473 | //______________________________________________________________________________ |
b1f08706 | 474 | void Track::PrintKineStack() |
475 | { | |
476 | Reve::LoadMacro("print_kine_from_label.C"); | |
477 | gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel)); | |
478 | } | |
479 | ||
2b801b28 | 480 | //______________________________________________________________________________ |
a525aa60 | 481 | void Track::PrintPathMarks() |
482 | { | |
483 | static const Exc_t eH("Track::PrintPathMarks "); | |
484 | ||
b855ed81 | 485 | printf("Track '%s', number of path marks %d, label %d\n", |
486 | GetName(), fPathMarks.size(), fLabel); | |
a525aa60 | 487 | |
488 | PathMark* pm; | |
489 | for(vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); i++) | |
490 | { | |
491 | pm = *i; | |
b855ed81 | 492 | printf(" %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g \n", |
a525aa60 | 493 | pm->type_name(), |
494 | pm->P.x, pm->P.y, pm->P.z, | |
495 | pm->V.x, pm->V.y, pm->V.z, | |
496 | pm->time); | |
497 | } | |
498 | } | |
499 | ||
2b801b28 | 500 | /******************************************************************************/ |
9c39ede9 | 501 | |
2b801b28 | 502 | //______________________________________________________________________________ |
9c39ede9 | 503 | void Track::CtrlClicked(Reve::Track* track) |
504 | { | |
505 | Emit("CtrlClicked(Reve::Track*)", (Long_t)track); | |
506 | } | |
507 | ||
2b801b28 | 508 | //______________________________________________________________________________ |
32e219c2 | 509 | void Track::SetLineStyle(Style_t lstyle) |
510 | { | |
511 | TAttLine::SetLineStyle(lstyle); | |
512 | std::list<NLTProjected*>::iterator pi = fProjectedList.begin(); | |
513 | while (pi != fProjectedList.end()) | |
514 | { | |
515 | Track* pt = dynamic_cast<Track*>(*pi); | |
516 | if (pt) | |
517 | { | |
518 | pt->SetLineStyle(lstyle); | |
519 | pt->ElementChanged(); | |
520 | } | |
521 | ++pi; | |
522 | } | |
523 | } | |
48dc973d | 524 | |
48dc973d | 525 | |
2b801b28 | 526 | /******************************************************************************/ |
527 | /******************************************************************************/ | |
528 | ||
2b801b28 | 529 | //______________________________________________________________________________ |
5a5a1232 | 530 | // TrackRnrStyle |
531 | // | |
17038a14 | 532 | // Holding structure for a number of track rendering parameters. |
533 | // | |
534 | // This is decoupled from Track/TrackList to allow sharing of the | |
535 | // RnrStyle among several instances. Back references are kept so the | |
536 | // tracks can be recreated when the parameters change. | |
537 | // | |
538 | // TrackList has Get/Set methods for RnrStlye. TrackEditor and | |
539 | // TrackListEditor provide editor access. | |
5a5a1232 | 540 | |
541 | ClassImp(Reve::TrackRnrStyle) | |
542 | ||
48dc973d | 543 | Float_t TrackRnrStyle::fgDefMagField = 5; |
544 | const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3; | |
5a5a1232 | 545 | TrackRnrStyle TrackRnrStyle::fgDefStyle; |
546 | ||
17038a14 | 547 | //______________________________________________________________________________ |
265ecb21 | 548 | TrackRnrStyle::TrackRnrStyle() : |
549 | TObject(), | |
32e219c2 | 550 | ReferenceBackPtr(), |
5a5a1232 | 551 | |
265ecb21 | 552 | fMagField(fgDefMagField), |
5a5a1232 | 553 | |
265ecb21 | 554 | fMaxR (350), |
555 | fMaxZ (450), | |
5a5a1232 | 556 | |
265ecb21 | 557 | fMaxOrbs (0.5), |
558 | fMinAng (45), | |
559 | fDelta (0.1), | |
5a5a1232 | 560 | |
32e219c2 | 561 | fEditPathMarks(kFALSE), |
562 | fPMAtt(), | |
4f5ee1c6 | 563 | |
7cbaaebd | 564 | fFitDaughters (kTRUE), |
565 | fFitReferences (kTRUE), | |
566 | fFitDecay (kTRUE), | |
5a5a1232 | 567 | |
7cbaaebd | 568 | fRnrDaughters (kTRUE), |
569 | fRnrReferences (kTRUE), | |
32e219c2 | 570 | fRnrDecay (kTRUE), |
571 | ||
572 | fRnrFV(kFALSE), | |
573 | fFVAtt() | |
574 | { | |
17038a14 | 575 | // Default constructor. |
576 | ||
32e219c2 | 577 | fPMAtt.SetMarkerColor(4); |
578 | fPMAtt.SetMarkerStyle(2); | |
579 | ||
580 | fFVAtt.SetMarkerSize(0.6); | |
581 | fFVAtt.SetMarkerColor(4); | |
582 | fFVAtt.SetMarkerStyle(2); | |
583 | } | |
584 | ||
5a5a1232 | 585 | /**************************************************************************/ |
586 | ||
17038a14 | 587 | //______________________________________________________________________________ |
32e219c2 | 588 | void TrackRnrStyle::RebuildTracks() |
589 | { | |
17038a14 | 590 | // Rebuild all tracks using this render-style. |
591 | ||
32e219c2 | 592 | Track* track; |
593 | std::list<RenderElement*>::iterator i = fBackRefs.begin(); | |
594 | while (i != fBackRefs.end()) | |
595 | { | |
596 | track = dynamic_cast<Track*>(*i); | |
597 | track->MakeTrack(); | |
598 | ++i; | |
599 | } | |
600 | } | |
5a5a1232 | 601 | |
17038a14 | 602 | /******************************************************************************/ |
5a5a1232 | 603 | |
17038a14 | 604 | //______________________________________________________________________________ |
32e219c2 | 605 | void TrackRnrStyle::SetMaxR(Float_t x) |
5a5a1232 | 606 | { |
17038a14 | 607 | // Set maximum radius and rebuild tracks. |
608 | ||
32e219c2 | 609 | fMaxR = x; |
610 | RebuildTracks(); | |
611 | } | |
5a5a1232 | 612 | |
17038a14 | 613 | //______________________________________________________________________________ |
32e219c2 | 614 | void TrackRnrStyle::SetMaxZ(Float_t x) |
615 | { | |
17038a14 | 616 | // Set maximum z and rebuild tracks. |
617 | ||
32e219c2 | 618 | fMaxZ = x; |
619 | RebuildTracks(); | |
5a5a1232 | 620 | } |
621 | ||
17038a14 | 622 | //______________________________________________________________________________ |
32e219c2 | 623 | void TrackRnrStyle::SetMaxOrbs(Float_t x) |
624 | { | |
17038a14 | 625 | // Set maximum number of orbits and rebuild tracks. |
626 | ||
32e219c2 | 627 | fMaxOrbs = x; |
628 | RebuildTracks(); | |
629 | } | |
265ecb21 | 630 | |
17038a14 | 631 | //______________________________________________________________________________ |
32e219c2 | 632 | void TrackRnrStyle::SetMinAng(Float_t x) |
633 | { | |
17038a14 | 634 | // Set minimum step angle and rebuild tracks. |
635 | ||
32e219c2 | 636 | fMinAng = x; |
637 | RebuildTracks(); | |
638 | } | |
265ecb21 | 639 | |
17038a14 | 640 | //______________________________________________________________________________ |
32e219c2 | 641 | void TrackRnrStyle::SetDelta(Float_t x) |
5a5a1232 | 642 | { |
17038a14 | 643 | // Set maximum error and rebuild tracks. |
644 | ||
32e219c2 | 645 | fDelta = x; |
646 | RebuildTracks(); | |
5a5a1232 | 647 | } |
648 | ||
17038a14 | 649 | //______________________________________________________________________________ |
32e219c2 | 650 | void TrackRnrStyle::SetFitDaughters(Bool_t x) |
651 | { | |
17038a14 | 652 | // Set daughter creation point fitting and rebuild tracks. |
653 | ||
32e219c2 | 654 | fFitDaughters = x; |
655 | RebuildTracks(); | |
656 | } | |
265ecb21 | 657 | |
17038a14 | 658 | //______________________________________________________________________________ |
32e219c2 | 659 | void TrackRnrStyle::SetFitReferences(Bool_t x) |
5a5a1232 | 660 | { |
17038a14 | 661 | // Set track-reference fitting and rebuild tracks. |
662 | ||
32e219c2 | 663 | fFitReferences = x; |
664 | RebuildTracks(); | |
5a5a1232 | 665 | } |
666 | ||
17038a14 | 667 | //______________________________________________________________________________ |
32e219c2 | 668 | void TrackRnrStyle::SetFitDecay(Bool_t x) |
5a5a1232 | 669 | { |
17038a14 | 670 | // Set decay fitting and rebuild tracks. |
671 | ||
32e219c2 | 672 | fFitDecay = x; |
673 | RebuildTracks(); | |
5a5a1232 | 674 | } |
675 | ||
17038a14 | 676 | //______________________________________________________________________________ |
32e219c2 | 677 | void TrackRnrStyle::SetRnrDecay(Bool_t rnr) |
678 | { | |
17038a14 | 679 | // Set decay rendering and rebuild tracks. |
680 | ||
32e219c2 | 681 | fRnrDecay = rnr; |
682 | RebuildTracks(); | |
683 | } | |
684 | ||
17038a14 | 685 | //______________________________________________________________________________ |
32e219c2 | 686 | void TrackRnrStyle::SetRnrDaughters(Bool_t rnr) |
687 | { | |
17038a14 | 688 | // Set daughter rendering and rebuild tracks. |
689 | ||
32e219c2 | 690 | fRnrDaughters = rnr; |
691 | RebuildTracks(); | |
692 | } | |
693 | ||
17038a14 | 694 | //______________________________________________________________________________ |
32e219c2 | 695 | void TrackRnrStyle::SetRnrReferences(Bool_t rnr) |
696 | { | |
17038a14 | 697 | // Set track-reference rendering and rebuild tracks. |
698 | ||
32e219c2 | 699 | fRnrReferences = rnr; |
700 | RebuildTracks(); | |
701 | } | |
702 | ||
703 | ||
5a5a1232 | 704 | /**************************************************************************/ |
32e219c2 | 705 | /**************************************************************************/ |
17038a14 | 706 | |
707 | //______________________________________________________________________________ | |
32e219c2 | 708 | // TrackList |
709 | // | |
710 | ||
711 | ClassImp(Reve::TrackList) | |
5a5a1232 | 712 | |
17038a14 | 713 | //______________________________________________________________________________ |
32e219c2 | 714 | TrackList::TrackList(TrackRnrStyle* rs) : |
715 | RenderElementList(), | |
716 | TAttMarker(1, 20, 1), | |
717 | TAttLine(1,1,1), | |
718 | ||
719 | fRecurse(kTRUE), | |
720 | fRnrStyle(0), | |
721 | fRnrLine(kTRUE), | |
722 | fRnrPoints(kFALSE), | |
723 | ||
724 | fMinPt (0), fMaxPt (0), fLimPt (0), | |
725 | fMinP (0), fMaxP (0), fLimP (0) | |
5a5a1232 | 726 | { |
17038a14 | 727 | // Constructor. If TrackRenderStyle argument is 0, a new default |
728 | // render-style is created. | |
729 | ||
32e219c2 | 730 | fChildClass = Track::Class(); // override member from base RenderElementList |
731 | ||
732 | fMainColorPtr = &fLineColor; | |
733 | if (fRnrStyle== 0) rs = new TrackRnrStyle; | |
734 | SetRnrStyle(rs); | |
735 | } | |
736 | ||
17038a14 | 737 | //______________________________________________________________________________ |
32e219c2 | 738 | TrackList::TrackList(const Text_t* name, TrackRnrStyle* rs) : |
739 | RenderElementList(name), | |
740 | TAttMarker(1, 20, 1), | |
741 | TAttLine(1,1,1), | |
742 | ||
743 | fRecurse(kTRUE), | |
744 | fRnrStyle (0), | |
745 | fRnrLine(kTRUE), | |
746 | fRnrPoints(kFALSE), | |
747 | ||
748 | fMinPt (0), fMaxPt (0), fLimPt (0), | |
749 | fMinP (0), fMaxP (0), fLimP (0) | |
750 | { | |
17038a14 | 751 | // Constructor. If TrackRenderStyle argument is 0, a new default |
752 | // render-style is created. | |
753 | ||
32e219c2 | 754 | fChildClass = Track::Class(); // override member from base RenderElementList |
755 | ||
756 | fMainColorPtr = &fLineColor; | |
757 | if (fRnrStyle== 0) rs = new TrackRnrStyle; | |
758 | SetRnrStyle(rs); | |
759 | } | |
760 | ||
17038a14 | 761 | //______________________________________________________________________________ |
32e219c2 | 762 | TrackList::~TrackList() |
763 | { | |
17038a14 | 764 | // Destructor. |
765 | ||
32e219c2 | 766 | SetRnrStyle(0); |
5a5a1232 | 767 | } |
768 | ||
17038a14 | 769 | /******************************************************************************/ |
5a5a1232 | 770 | |
17038a14 | 771 | //______________________________________________________________________________ |
32e219c2 | 772 | void TrackList::SetRnrStyle(TrackRnrStyle* rs) |
5a5a1232 | 773 | { |
17038a14 | 774 | // Set default render-style for tracks. |
775 | // This is not enforced onto the tracks themselves but this is the | |
776 | // render-style that is show in the TrackListEditor. | |
777 | ||
32e219c2 | 778 | if (fRnrStyle == rs) return; |
779 | if (fRnrStyle) fRnrStyle->DecRefCount(); | |
780 | fRnrStyle = rs; | |
781 | if (fRnrStyle) rs->IncRefCount(); | |
5a5a1232 | 782 | } |
783 | ||
784 | /**************************************************************************/ | |
785 | ||
17038a14 | 786 | //______________________________________________________________________________ |
a8a51cc7 | 787 | void TrackList::MakeTracks(Bool_t recurse) |
5a5a1232 | 788 | { |
17038a14 | 789 | // Regenerate the visual representations of tracks. |
790 | // The momentum limits are rescanned during the same traversal. | |
791 | ||
32e219c2 | 792 | fLimPt = fLimP = 0; |
793 | ||
17038a14 | 794 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) |
a8a51cc7 | 795 | { |
32e219c2 | 796 | Track* track = (Track*)(*i); |
797 | track->MakeTrack(recurse); | |
798 | ||
799 | fLimPt = TMath::Max(fLimPt, track->fP.Perp()); | |
800 | fLimP = TMath::Max(fLimP, track->fP.Mag()); | |
801 | if (recurse) | |
802 | FindMomentumLimits(*i, recurse); | |
5a5a1232 | 803 | } |
32e219c2 | 804 | |
805 | fLimPt = RoundMomentumLimit(fLimPt); | |
806 | fLimP = RoundMomentumLimit(fLimP); | |
807 | if (fMaxPt == 0) fMaxPt = fLimPt; | |
808 | if (fMaxP == 0) fMaxP = fLimP; | |
809 | ||
5a5a1232 | 810 | gReve->Redraw3D(); |
811 | } | |
812 | ||
17038a14 | 813 | //______________________________________________________________________________ |
32e219c2 | 814 | void TrackList::FindMomentumLimits(RenderElement* el, Bool_t recurse) |
5a5a1232 | 815 | { |
17038a14 | 816 | // Loop over track elements of argument el and find highest pT and p. |
817 | // These are stored in members fLimPt and fLimP. | |
818 | ||
819 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) | |
32e219c2 | 820 | { |
821 | Track* track = dynamic_cast<Track*>(*i); | |
822 | if (track) | |
823 | { | |
824 | fLimPt = TMath::Max(fLimPt, track->fP.Perp()); | |
825 | fLimP = TMath::Max(fLimP, track->fP.Mag()); | |
826 | if (recurse) | |
827 | FindMomentumLimits(*i, recurse); | |
828 | } | |
5a5a1232 | 829 | } |
32e219c2 | 830 | } |
831 | ||
17038a14 | 832 | //______________________________________________________________________________ |
32e219c2 | 833 | Float_t TrackList::RoundMomentumLimit(Float_t x) |
834 | { | |
17038a14 | 835 | // Round the momentum limit up to a nice value. |
836 | ||
32e219c2 | 837 | using namespace TMath; |
838 | Double_t fac = Power(10, 1 - Floor(Log10(x))); | |
839 | return Ceil(fac*x) / fac; | |
5a5a1232 | 840 | } |
841 | ||
842 | /**************************************************************************/ | |
5a5a1232 | 843 | |
17038a14 | 844 | //______________________________________________________________________________ |
32e219c2 | 845 | void TrackList::SetRnrLine(Bool_t rnr) |
2074deef | 846 | { |
17038a14 | 847 | // Set rendering of track as line for the list and the elements. |
848 | ||
849 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 850 | { |
851 | Track* track = (Track*)(*i); | |
17038a14 | 852 | if (track->GetRnrLine() == fRnrLine) |
853 | track->SetRnrLine(rnr); | |
854 | if (fRecurse) | |
855 | SetRnrLine(rnr, *i); | |
2074deef | 856 | } |
32e219c2 | 857 | fRnrLine = rnr; |
2074deef | 858 | } |
859 | ||
17038a14 | 860 | //______________________________________________________________________________ |
32e219c2 | 861 | void TrackList::SetRnrLine(Bool_t rnr, RenderElement* el) |
ec019a35 | 862 | { |
17038a14 | 863 | // Set rendering of track as line for children of el. |
864 | ||
32e219c2 | 865 | Track* track; |
17038a14 | 866 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 867 | { |
868 | track = dynamic_cast<Track*>(*i); | |
869 | if (track && (track->GetRnrLine() == fRnrLine)) | |
870 | track->SetRnrLine(rnr); | |
871 | if (fRecurse) | |
872 | SetRnrLine(rnr, *i); | |
ec019a35 | 873 | } |
874 | } | |
875 | ||
17038a14 | 876 | /******************************************************************************/ |
32e219c2 | 877 | |
17038a14 | 878 | //______________________________________________________________________________ |
32e219c2 | 879 | void TrackList::SetRnrPoints(Bool_t rnr) |
880 | { | |
17038a14 | 881 | // Set rendering of track as points for the list and the elements. |
882 | ||
883 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 884 | { |
885 | Track* track = (Track*)(*i); | |
17038a14 | 886 | if (track->GetRnrPoints() == fRnrPoints) |
887 | track->SetRnrPoints(rnr); | |
888 | if (fRecurse) | |
889 | SetRnrPoints(rnr, *i); | |
32e219c2 | 890 | } |
891 | fRnrPoints = rnr; | |
892 | } | |
893 | ||
17038a14 | 894 | //______________________________________________________________________________ |
32e219c2 | 895 | void TrackList::SetRnrPoints(Bool_t rnr, RenderElement* el) |
5a5a1232 | 896 | { |
17038a14 | 897 | // Set rendering of track as points for children of el. |
898 | ||
32e219c2 | 899 | Track* track; |
17038a14 | 900 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 901 | { |
902 | track = dynamic_cast<Track*>(*i); | |
903 | if (track) | |
17038a14 | 904 | if (track->GetRnrPoints() == fRnrPoints) |
905 | track->SetRnrPoints(rnr); | |
906 | if (fRecurse) | |
907 | SetRnrPoints(rnr, *i); | |
32e219c2 | 908 | } |
5a5a1232 | 909 | } |
910 | ||
17038a14 | 911 | /******************************************************************************/ |
912 | ||
913 | //______________________________________________________________________________ | |
32e219c2 | 914 | void TrackList::SetMainColor(Color_t col) |
5a5a1232 | 915 | { |
17038a14 | 916 | // Set main (line) color for the list and the elements. |
917 | ||
918 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 919 | { |
920 | Track* track = (Track*)(*i); | |
17038a14 | 921 | if (track->GetLineColor() == fLineColor) |
922 | track->SetLineColor(col); | |
923 | if (fRecurse) | |
924 | SetLineColor(col, *i); | |
32e219c2 | 925 | } |
926 | RenderElement::SetMainColor(col); | |
5a5a1232 | 927 | } |
928 | ||
17038a14 | 929 | //______________________________________________________________________________ |
32e219c2 | 930 | void TrackList::SetLineColor(Color_t col, RenderElement* el) |
5a5a1232 | 931 | { |
17038a14 | 932 | // Set line color for children of el. |
933 | ||
32e219c2 | 934 | Track* track; |
17038a14 | 935 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 936 | { |
937 | track = dynamic_cast<Track*>(*i); | |
938 | if (track && track->GetLineColor() == fLineColor) | |
939 | track->SetLineColor(col); | |
940 | if (fRecurse) | |
941 | SetLineColor(col, *i); | |
942 | } | |
5a5a1232 | 943 | } |
944 | ||
17038a14 | 945 | /******************************************************************************/ |
32e219c2 | 946 | |
17038a14 | 947 | //______________________________________________________________________________ |
32e219c2 | 948 | void TrackList::SetLineWidth(Width_t width) |
5a5a1232 | 949 | { |
17038a14 | 950 | // Set line width for the list and the elements. |
951 | ||
952 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 953 | { |
954 | Track* track = (Track*)(*i); | |
17038a14 | 955 | if (track->GetLineWidth() == fLineWidth) |
956 | track->SetLineWidth(width); | |
957 | if (fRecurse) | |
958 | SetLineWidth(width, *i); | |
32e219c2 | 959 | } |
960 | fLineWidth=width; | |
5a5a1232 | 961 | } |
962 | ||
17038a14 | 963 | //______________________________________________________________________________ |
32e219c2 | 964 | void TrackList::SetLineWidth(Width_t width, RenderElement* el) |
5a5a1232 | 965 | { |
17038a14 | 966 | // Set line width for children of el. |
967 | ||
32e219c2 | 968 | Track* track; |
17038a14 | 969 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 970 | { |
971 | track = dynamic_cast<Track*>(*i); | |
972 | if (track && track->GetLineWidth() == fLineWidth) | |
973 | track->SetLineWidth(width); | |
974 | if (fRecurse) | |
975 | SetLineWidth(width, *i); | |
976 | } | |
5a5a1232 | 977 | } |
978 | ||
17038a14 | 979 | /******************************************************************************/ |
32e219c2 | 980 | |
17038a14 | 981 | //______________________________________________________________________________ |
32e219c2 | 982 | void TrackList::SetLineStyle(Style_t style) |
5a5a1232 | 983 | { |
17038a14 | 984 | // Set line style for the list and the elements. |
985 | ||
986 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 987 | { |
988 | Track* track = (Track*)(*i); | |
17038a14 | 989 | if (track->GetLineStyle() == fLineStyle) |
990 | track->SetLineStyle(style); | |
991 | if (fRecurse) | |
992 | SetLineStyle(style, *i); | |
32e219c2 | 993 | } |
994 | fLineStyle=style; | |
5a5a1232 | 995 | } |
996 | ||
17038a14 | 997 | //______________________________________________________________________________ |
32e219c2 | 998 | void TrackList::SetLineStyle(Style_t style, RenderElement* el) |
7cbaaebd | 999 | { |
17038a14 | 1000 | // Set line style for children of el. |
1001 | ||
32e219c2 | 1002 | Track* track; |
17038a14 | 1003 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 1004 | { |
1005 | track = dynamic_cast<Track*>(*i); | |
1006 | if (track && track->GetLineStyle() == fLineStyle) | |
1007 | track->SetLineStyle(style); | |
1008 | if (fRecurse) | |
1009 | SetLineStyle(style, *i); | |
1010 | } | |
7cbaaebd | 1011 | } |
1012 | ||
17038a14 | 1013 | /******************************************************************************/ |
32e219c2 | 1014 | |
17038a14 | 1015 | //______________________________________________________________________________ |
32e219c2 | 1016 | void TrackList::SetMarkerStyle(Style_t style) |
5a5a1232 | 1017 | { |
17038a14 | 1018 | // Set marker style for the list and the elements. |
1019 | ||
1020 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 1021 | { |
1022 | Track* track = (Track*)(*i); | |
17038a14 | 1023 | if (track->GetMarkerStyle() == fMarkerStyle) |
1024 | track->SetMarkerStyle(style); | |
1025 | if (fRecurse) | |
1026 | SetMarkerStyle(style, *i); | |
32e219c2 | 1027 | } |
1028 | fMarkerStyle=style; | |
5a5a1232 | 1029 | } |
1030 | ||
17038a14 | 1031 | //______________________________________________________________________________ |
32e219c2 | 1032 | void TrackList::SetMarkerStyle(Style_t style, RenderElement* el) |
7cbaaebd | 1033 | { |
17038a14 | 1034 | // Set marker style for children of el. |
1035 | ||
32e219c2 | 1036 | Track* track; |
17038a14 | 1037 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 1038 | { |
1039 | track = dynamic_cast<Track*>(*i); | |
1040 | if (track && track->GetMarkerStyle() == fMarkerStyle) | |
1041 | track->SetMarkerStyle(style); | |
1042 | if(fRecurse) | |
1043 | SetMarkerStyle(style, *i); | |
1044 | } | |
7cbaaebd | 1045 | } |
1046 | ||
17038a14 | 1047 | /******************************************************************************/ |
32e219c2 | 1048 | |
17038a14 | 1049 | //______________________________________________________________________________ |
32e219c2 | 1050 | void TrackList::SetMarkerColor(Color_t col) |
7cbaaebd | 1051 | { |
17038a14 | 1052 | // Set marker color for the list and the elements. |
1053 | ||
1054 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 1055 | { |
1056 | Track* track = (Track*)(*i); | |
17038a14 | 1057 | if (track->GetMarkerColor() == fMarkerColor) |
1058 | track->SetMarkerColor(col); | |
1059 | if (fRecurse) | |
1060 | SetMarkerColor(col, *i); | |
32e219c2 | 1061 | } |
1062 | fMarkerColor=col; | |
7cbaaebd | 1063 | } |
1064 | ||
17038a14 | 1065 | //______________________________________________________________________________ |
32e219c2 | 1066 | void TrackList::SetMarkerColor(Color_t col, RenderElement* el) |
7cbaaebd | 1067 | { |
17038a14 | 1068 | // Set marker color for children of el. |
1069 | ||
32e219c2 | 1070 | Track* track; |
17038a14 | 1071 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 1072 | { |
1073 | track = dynamic_cast<Track*>(*i); | |
1074 | if (track && track->GetMarkerColor() == fMarkerColor) | |
1075 | track->SetMarkerColor(col); | |
1076 | if (fRecurse) | |
1077 | SetMarkerColor(col, *i); | |
1078 | } | |
7cbaaebd | 1079 | } |
32e219c2 | 1080 | |
17038a14 | 1081 | /******************************************************************************/ |
32e219c2 | 1082 | |
17038a14 | 1083 | //______________________________________________________________________________ |
32e219c2 | 1084 | void TrackList::SetMarkerSize(Size_t size) |
7cbaaebd | 1085 | { |
17038a14 | 1086 | // Set marker size for the list and the elements. |
1087 | ||
1088 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) | |
32e219c2 | 1089 | { |
1090 | Track* track = (Track*)(*i); | |
17038a14 | 1091 | if (track->GetMarkerSize() == fMarkerSize) |
1092 | track->SetMarkerSize(size); | |
1093 | if (fRecurse) | |
1094 | SetMarkerSize(size, *i); | |
32e219c2 | 1095 | } |
1096 | fMarkerSize=size; | |
7cbaaebd | 1097 | } |
1098 | ||
17038a14 | 1099 | //______________________________________________________________________________ |
32e219c2 | 1100 | void TrackList::SetMarkerSize(Size_t size, RenderElement* el) |
7cbaaebd | 1101 | { |
17038a14 | 1102 | // Set marker size for children of el. |
1103 | ||
32e219c2 | 1104 | Track* track; |
17038a14 | 1105 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 1106 | { |
1107 | track = dynamic_cast<Track*>(*i); | |
1108 | if (track && track->GetMarkerSize() == fMarkerSize) | |
1109 | track->SetMarkerSize(size); | |
1110 | if (fRecurse) | |
1111 | SetMarkerSize(size, *i); | |
1112 | } | |
7cbaaebd | 1113 | } |
1114 | ||
17038a14 | 1115 | /******************************************************************************/ |
5a5a1232 | 1116 | |
17038a14 | 1117 | //______________________________________________________________________________ |
5a5a1232 | 1118 | void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt) |
1119 | { | |
32e219c2 | 1120 | fMinPt = min_pt; |
1121 | fMaxPt = max_pt; | |
22df2a83 | 1122 | |
32e219c2 | 1123 | const Float_t minptsq = min_pt*min_pt; |
1124 | const Float_t maxptsq = max_pt*max_pt; | |
5a5a1232 | 1125 | |
17038a14 | 1126 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) |
32e219c2 | 1127 | { |
1128 | const Float_t ptsq = ((Track*)(*i))->fP.Perp2(); | |
a8a51cc7 | 1129 | Bool_t on = ptsq >= minptsq && ptsq <= maxptsq; |
32e219c2 | 1130 | (*i)->SetRnrState(on); |
1131 | if (on && fRecurse) | |
1132 | SelectByPt(min_pt, max_pt, *i); | |
1133 | } | |
1134 | } | |
1135 | ||
17038a14 | 1136 | //______________________________________________________________________________ |
32e219c2 | 1137 | void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt, RenderElement* el) |
1138 | { | |
1139 | const Float_t minptsq = min_pt*min_pt; | |
1140 | const Float_t maxptsq = max_pt*max_pt; | |
1141 | ||
17038a14 | 1142 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 1143 | { |
1144 | Track* track = dynamic_cast<Track*>(*i); | |
1145 | if (track) | |
1146 | { | |
1147 | const Float_t ptsq = track->fP.Perp2(); | |
1148 | Bool_t on = ptsq >= minptsq && ptsq <= maxptsq; | |
1149 | track->SetRnrState(on); | |
1150 | if (on && fRecurse) | |
1151 | SelectByPt(min_pt, max_pt, *i); | |
1152 | } | |
5a5a1232 | 1153 | } |
1154 | } | |
1155 | ||
17038a14 | 1156 | //______________________________________________________________________________ |
4f5ee1c6 | 1157 | void TrackList::SelectByP(Float_t min_p, Float_t max_p) |
1158 | { | |
32e219c2 | 1159 | fMinP = min_p; |
1160 | fMaxP = max_p; | |
4f5ee1c6 | 1161 | |
32e219c2 | 1162 | const Float_t minpsq = min_p*min_p; |
1163 | const Float_t maxpsq = max_p*max_p; | |
4f5ee1c6 | 1164 | |
17038a14 | 1165 | for (List_i i=BeginChildren(); i!=EndChildren(); ++i) |
32e219c2 | 1166 | { |
1167 | const Float_t psq = ((Track*)(*i))->fP.Mag2(); | |
bfcc55e4 | 1168 | Bool_t on = psq >= minpsq && psq <= maxpsq; |
32e219c2 | 1169 | (*i)->SetRnrState(psq >= minpsq && psq <= maxpsq); |
1170 | if (on && fRecurse) | |
1171 | SelectByP(min_p, max_p, *i); | |
1172 | } | |
1173 | } | |
1174 | ||
17038a14 | 1175 | //______________________________________________________________________________ |
32e219c2 | 1176 | void TrackList::SelectByP(Float_t min_p, Float_t max_p, RenderElement* el) |
1177 | { | |
1178 | const Float_t minpsq = min_p*min_p; | |
1179 | const Float_t maxpsq = max_p*max_p; | |
1180 | ||
17038a14 | 1181 | for (List_i i=el->BeginChildren(); i!=el->EndChildren(); ++i) |
32e219c2 | 1182 | { |
1183 | Track* track = dynamic_cast<Track*>(*i); | |
1184 | if (track) | |
1185 | { | |
1186 | const Float_t psq = ((Track*)(*i))->fP.Mag2(); | |
1187 | Bool_t on = psq >= minpsq && psq <= maxpsq; | |
1188 | track->SetRnrState(on); | |
1189 | if (on && fRecurse) | |
1190 | SelectByP(min_p, max_p, *i); | |
1191 | } | |
4f5ee1c6 | 1192 | } |
1193 | } | |
1194 | ||
17038a14 | 1195 | /******************************************************************************/ |
5a5a1232 | 1196 | |
17038a14 | 1197 | //______________________________________________________________________________ |
1198 | Track* TrackList::FindTrackByLabel(Int_t label) | |
1199 | { | |
1200 | // Find track by label, select it and display it in the editor. | |
1201 | ||
1202 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { | |
1203 | if (((Track*)(*i))->GetLabel() == label) { | |
1204 | TGListTree *lt = gReve->GetLTEFrame()->GetListTree(); | |
1205 | TGListTreeItem *mlti = lt->GetSelected(); | |
1206 | if (mlti->GetUserData() != this) | |
1207 | mlti = FindListTreeItem(lt); | |
1208 | TGListTreeItem *tlti = (*i)->FindListTreeItem(lt, mlti); | |
1209 | lt->HighlightItem(tlti); | |
1210 | lt->SetSelected(tlti); | |
1211 | gReve->EditRenderElement(*i); | |
1212 | return (Track*) *i; | |
1213 | } | |
1214 | } | |
1215 | return 0; | |
1216 | } | |
1217 | ||
1218 | //______________________________________________________________________________ | |
1219 | Track* TrackList::FindTrackByIndex(Int_t index) | |
1220 | { | |
1221 | // Find track by index, select it and display it in the editor. | |
1222 | ||
1223 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { | |
1224 | if (((Track*)(*i))->GetIndex() == index) { | |
1225 | TGListTree *lt = gReve->GetLTEFrame()->GetListTree(); | |
1226 | TGListTreeItem *mlti = lt->GetSelected(); | |
1227 | if (mlti->GetUserData() != this) | |
1228 | mlti = FindListTreeItem(lt); | |
1229 | TGListTreeItem *tlti = (*i)->FindListTreeItem(lt, mlti); | |
1230 | lt->HighlightItem(tlti); | |
1231 | lt->SetSelected(tlti); | |
1232 | gReve->EditRenderElement(*i); | |
1233 | return (Track*) *i; | |
1234 | } | |
1235 | } | |
1236 | return 0; | |
1237 | } | |
1238 | ||
1239 | //______________________________________________________________________________ | |
b99aed53 | 1240 | void TrackList::ImportHits() |
5a5a1232 | 1241 | { |
17038a14 | 1242 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
b99aed53 | 1243 | ((Track*)(*i))->ImportHits(); |
1244 | } | |
5a5a1232 | 1245 | } |
1246 | ||
17038a14 | 1247 | //______________________________________________________________________________ |
b99aed53 | 1248 | void TrackList::ImportClusters() |
5a5a1232 | 1249 | { |
17038a14 | 1250 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
b99aed53 | 1251 | ((Track*)(*i))->ImportClusters(); |
1252 | } | |
5a5a1232 | 1253 | } |
9c39ede9 | 1254 | |
17038a14 | 1255 | /******************************************************************************/ |
32e219c2 | 1256 | |
17038a14 | 1257 | //______________________________________________________________________________ |
32e219c2 | 1258 | TClass* TrackList::ProjectedClass() const |
1259 | { | |
1260 | return NLTTrackList::Class(); | |
1261 | } | |
17038a14 | 1262 | |
1263 | ||
1264 | /******************************************************************************/ | |
1265 | /******************************************************************************/ | |
9c39ede9 | 1266 | |
1267 | #include "RGEditor.h" | |
1268 | ||
17038a14 | 1269 | //______________________________________________________________________________ |
9c39ede9 | 1270 | // TrackCounter |
1271 | // | |
1272 | ||
1273 | ClassImp(TrackCounter) | |
1274 | ||
b1f08706 | 1275 | TrackCounter* TrackCounter::fgInstance = 0; |
1276 | ||
9c39ede9 | 1277 | TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) : |
1278 | RenderElement(), | |
1279 | TNamed(name, title), | |
1280 | ||
1281 | fBadLineStyle (6), | |
1282 | fClickAction (CA_ToggleTrack), | |
1283 | fAllTracks (0), | |
1284 | fGoodTracks (0), | |
1285 | fTrackLists () | |
1286 | { | |
b1f08706 | 1287 | if (fgInstance == 0) fgInstance = this; |
9c39ede9 | 1288 | TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)", |
1289 | "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)"); | |
1290 | } | |
1291 | ||
1292 | TrackCounter::~TrackCounter() | |
1293 | { | |
1294 | TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)"); | |
b1f08706 | 1295 | if (fgInstance == this) fgInstance = 0; |
9c39ede9 | 1296 | } |
1297 | ||
1298 | /**************************************************************************/ | |
1299 | ||
1300 | void TrackCounter::Reset() | |
1301 | { | |
1302 | printf("TrackCounter::Reset()\n"); | |
1303 | fAllTracks = 0; | |
1304 | fGoodTracks = 0; | |
1305 | TIter next(&fTrackLists); | |
1306 | TrackList* tlist; | |
1307 | while ((tlist = dynamic_cast<TrackList*>(next()))) | |
32e219c2 | 1308 | tlist->DecDenyDestroy(); |
2b801b28 | 1309 | fTrackLists.Clear("nodelete"); |
9c39ede9 | 1310 | } |
1311 | ||
1312 | void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks) | |
1313 | { | |
1314 | // printf("TrackCounter::RegisterTracks '%s', %s\n", | |
1315 | // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad"); | |
1316 | ||
32e219c2 | 1317 | tlist->IncDenyDestroy(); |
9c39ede9 | 1318 | fTrackLists.Add(tlist); |
1319 | ||
1320 | List_i i = tlist->BeginChildren(); | |
1321 | while (i != tlist->EndChildren()) | |
1322 | { | |
1323 | Track* t = dynamic_cast<Track*>(*i); | |
1324 | if (t != 0) | |
1325 | { | |
1326 | if (goodTracks) | |
1327 | { | |
1328 | ++fGoodTracks; | |
1329 | } else { | |
1330 | t->SetLineStyle(fBadLineStyle); | |
1331 | } | |
1332 | ++fAllTracks; | |
1333 | } | |
1334 | ++i; | |
1335 | } | |
1336 | } | |
1337 | ||
1338 | void TrackCounter::DoTrackAction(Track* track) | |
1339 | { | |
1340 | // !!!! No check done if ok. | |
1341 | // !!!! Should also override RemoveElementLocal | |
32e219c2 | 1342 | // !!!! But then ... should also store local information if track is ok. |
9c39ede9 | 1343 | |
1344 | switch (fClickAction) | |
1345 | { | |
1346 | ||
1347 | case CA_PrintTrackInfo: | |
1348 | { | |
1349 | printf("Track '%s'\n", track->GetObject()->GetName()); | |
1350 | Vector &v = track->fV, &p = track->fP; | |
1351 | printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n", | |
1352 | v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi()); | |
1353 | printf(" <other information should be printed ... full AliESDtrack>\n"); | |
1354 | break; | |
1355 | } | |
1356 | ||
1357 | case CA_ToggleTrack: | |
1358 | { | |
1359 | if (track->GetLineStyle() == 1) | |
1360 | { | |
1361 | track->SetLineStyle(fBadLineStyle); | |
1362 | --fGoodTracks; | |
1363 | } else { | |
1364 | track->SetLineStyle(1); | |
1365 | ++fGoodTracks; | |
1366 | } | |
32e219c2 | 1367 | track->ElementChanged(); |
9c39ede9 | 1368 | gReve->Redraw3D(); |
1369 | ||
1370 | printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n", | |
1371 | fAllTracks, fGoodTracks, fAllTracks-fGoodTracks); | |
1372 | ||
1373 | if (gReve->GetEditor()->GetModel() == GetObject()) | |
1374 | gReve->EditRenderElement(this); | |
1375 | ||
1376 | break; | |
1377 | } | |
1378 | ||
1379 | } // end switch fClickAction | |
1380 | } | |
7af62191 | 1381 | |
1382 | /**************************************************************************/ | |
1383 | ||
1384 | void TrackCounter::OutputEventTracks(FILE* out) | |
1385 | { | |
1386 | if (out == 0) | |
1387 | { | |
1388 | out = stdout; | |
1389 | fprintf(out, "TrackCounter::FinalizeEvent()\n"); | |
1390 | } | |
1391 | ||
1392 | fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks); | |
1393 | ||
1394 | TIter tlists(&fTrackLists); | |
1395 | TrackList* tlist; | |
1396 | Int_t cnt = 0; | |
1397 | while ((tlist = (TrackList*) tlists()) != 0) | |
1398 | { | |
1399 | List_i i = tlist->BeginChildren(); | |
1400 | while (i != tlist->EndChildren()) | |
1401 | { | |
1402 | Track* t = dynamic_cast<Track*>(*i); | |
1403 | if (t != 0 && t->GetLineStyle() == 1) | |
1404 | { | |
1405 | ++cnt; | |
1406 | fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n", | |
1407 | cnt, t->fCharge, t->fP.Perp(), t->fP.Eta()); | |
1408 | } | |
1409 | ++i; | |
1410 | } | |
7af62191 | 1411 | } |
1412 | } |