]>
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> | |
8 | #include <TPolyMarker3D.h> | |
9 | #include <TColor.h> | |
10 | ||
11 | // Updates | |
12 | #include <Reve/RGTopFrame.h> | |
13 | #include <TCanvas.h> | |
14 | ||
15 | #include <vector> | |
5ba491d8 | 16 | #include <algorithm> |
17 | #include <functional> | |
18 | #include <iostream> | |
5a5a1232 | 19 | |
20 | using namespace Reve; | |
21 | ||
22 | //______________________________________________________________________ | |
23 | // Track | |
24 | // | |
25 | ||
26 | ClassImp(Reve::Track) | |
27 | ||
265ecb21 | 28 | Track::Track() : |
eadaa89b | 29 | Line(), |
5a5a1232 | 30 | |
265ecb21 | 31 | fV(), |
32 | fP(), | |
33 | fBeta(0), | |
34 | fCharge(0), | |
7cbaaebd | 35 | fLabel(-1), |
36 | fIndex(-1), | |
265ecb21 | 37 | fPathMarks(), |
38 | ||
eadaa89b | 39 | fRnrStyle(0) |
265ecb21 | 40 | {} |
41 | ||
3d75306d | 42 | Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs): |
eadaa89b | 43 | Line(), |
3d75306d | 44 | |
45 | fV(t->Vx(), t->Vy(), t->Vz()), | |
46 | fP(t->Px(), t->Py(), t->Pz()), | |
47 | fBeta(t->P()/t->Energy()), | |
48 | fCharge(0), | |
49 | fLabel(label), | |
7cbaaebd | 50 | fIndex(-1), |
3d75306d | 51 | fPathMarks(), |
52 | ||
eadaa89b | 53 | fRnrStyle(rs) |
3d75306d | 54 | { |
55 | fLineColor = fRnrStyle->GetColor(); | |
56 | fMainColorPtr = &fLineColor; | |
57 | ||
58 | TParticlePDG* pdgp = t->GetPDG(); | |
59 | if (pdgp) | |
60 | fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3); | |
eadaa89b | 61 | |
62 | SetName(t->GetName()); | |
3d75306d | 63 | } |
64 | ||
265ecb21 | 65 | Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs): |
eadaa89b | 66 | Line(), |
5a5a1232 | 67 | |
265ecb21 | 68 | fV(t->Vx(), t->Vy(), t->Vz()), |
69 | fP(t->Px(), t->Py(), t->Pz()), | |
70 | fBeta(t->P()/t->Energy()), | |
71 | fCharge(0), | |
72 | fLabel(t->label), | |
fa446a68 | 73 | fIndex(t->index), |
265ecb21 | 74 | fPathMarks(), |
75 | ||
eadaa89b | 76 | fRnrStyle(rs) |
265ecb21 | 77 | { |
5a5a1232 | 78 | fLineColor = fRnrStyle->GetColor(); |
79 | fMainColorPtr = &fLineColor; | |
80 | ||
5a5a1232 | 81 | TParticlePDG* pdgp = t->GetPDG(); |
82 | if(pdgp == 0) { | |
83 | t->ResetPdgCode(); pdgp = t->GetPDG(); | |
84 | } | |
48dc973d | 85 | fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3); |
eadaa89b | 86 | |
87 | SetName(t->GetName()); | |
5a5a1232 | 88 | } |
89 | ||
265ecb21 | 90 | Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) : |
eadaa89b | 91 | Line(), |
265ecb21 | 92 | |
93 | fV(t->V), | |
94 | fP(t->P), | |
95 | fBeta(t->beta), | |
96 | fCharge(t->sign), | |
97 | fLabel(t->label), | |
fa446a68 | 98 | fIndex(t->index), |
265ecb21 | 99 | fPathMarks(), |
100 | ||
eadaa89b | 101 | fRnrStyle(rs) |
5a5a1232 | 102 | { |
5a5a1232 | 103 | fLineColor = fRnrStyle->GetColor(); |
104 | fMainColorPtr = &fLineColor; | |
eadaa89b | 105 | |
106 | SetName(t->GetName()); | |
5a5a1232 | 107 | } |
108 | ||
109 | Track::~Track() | |
265ecb21 | 110 | { |
111 | for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) | |
112 | delete *i; | |
113 | } | |
5a5a1232 | 114 | |
eadaa89b | 115 | /* |
5a5a1232 | 116 | void Track::Reset(Int_t n_points) |
117 | { | |
118 | delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0; | |
119 | fN = n_points; | |
120 | if(fN) TPolyLine3D::fP = new Float_t [3*fN]; | |
121 | memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t)); | |
122 | fLastPoint = -1; | |
123 | } | |
eadaa89b | 124 | */ |
5a5a1232 | 125 | |
2fbbf445 | 126 | /**************************************************************************/ |
5a5a1232 | 127 | |
a8a51cc7 | 128 | void Track::MakeTrack(Bool_t recurse) |
5a5a1232 | 129 | { |
5a5a1232 | 130 | TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle); |
131 | ||
132 | Float_t px = fP.x, py = fP.y, pz = fP.z; | |
133 | ||
134 | MCVertex mc_v0; | |
135 | mc_v0.x = fV.x; | |
136 | mc_v0.y = fV.y; | |
137 | mc_v0.z = fV.z; | |
138 | mc_v0.t = 0; | |
139 | ||
140 | std::vector<MCVertex> track_points; | |
48dc973d | 141 | Bool_t decay = kFALSE; |
5a5a1232 | 142 | |
143 | if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR)) | |
144 | goto make_polyline; | |
145 | ||
01024c63 | 146 | if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) { |
147 | ||
148 | // Charged particle in magnetic field | |
5a5a1232 | 149 | |
48dc973d | 150 | Float_t a = RS.fgkB2C * RS.fMagField * fCharge; |
5a5a1232 | 151 | |
152 | MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm | |
153 | helix.Init(TMath::Sqrt(px*px+py*py), pz); | |
b855ed81 | 154 | // Set max number of points for loop-to-vertex. |
155 | // loop-to-bounds (last step) does this separately. | |
156 | helix.NMax = 4096; | |
5a5a1232 | 157 | |
b855ed81 | 158 | if (!fPathMarks.empty()) |
7cbaaebd | 159 | { |
160 | for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) | |
161 | { | |
5a5a1232 | 162 | Reve::PathMark* pm = *i; |
163 | ||
7cbaaebd | 164 | if (RS.fFitReferences && pm->type == Reve::PathMark::Reference) |
165 | { | |
b855ed81 | 166 | if(TMath::Abs(pm->V.z) > RS.fMaxZ || |
167 | TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR ) | |
5a5a1232 | 168 | goto helix_bounds; |
169 | ||
7cbaaebd | 170 | // printf("%s fit reference \n", fName.Data()); |
171 | helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z); | |
172 | px = pm->P.x; | |
173 | py = pm->P.y; | |
174 | pz = pm->P.z; | |
5a5a1232 | 175 | } |
7cbaaebd | 176 | else if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter) |
177 | { | |
5a5a1232 | 178 | if(TMath::Abs(pm->V.z) > RS.fMaxZ |
179 | || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR ) | |
180 | goto helix_bounds; | |
7cbaaebd | 181 | |
182 | // printf("%s fit daughter \n", fName.Data()); | |
183 | helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z); | |
184 | px -= pm->P.x; | |
185 | py -= pm->P.y; | |
186 | pz -= pm->P.z; | |
187 | } | |
188 | else if(RS.fFitDecay && pm->type == Reve::PathMark::Decay) | |
189 | { | |
190 | if(TMath::Abs(pm->V.z) > RS.fMaxZ | |
191 | || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR ) | |
192 | goto helix_bounds; | |
193 | helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z); | |
5a5a1232 | 194 | decay = true; |
195 | break; | |
196 | } | |
b855ed81 | 197 | if (track_points.size() > 4096) |
198 | { | |
199 | Warning("Track::MakeTrack", "exceeding 4k points (%u) for '%s'; aborting extrapolation.", | |
200 | track_points.size(), GetName()); | |
201 | goto make_polyline; | |
202 | } | |
5a5a1232 | 203 | } |
204 | } | |
205 | helix_bounds: | |
7cbaaebd | 206 | // go to bounds |
48dc973d | 207 | if(!decay || RS.fFitDecay == kFALSE){ |
5a5a1232 | 208 | helix.LoopToBounds(px,py,pz); |
209 | // printf("%s loop to bounds \n",fName.Data() ); | |
210 | } | |
211 | ||
01024c63 | 212 | } else { |
213 | ||
214 | // Neutral particle or no field | |
5a5a1232 | 215 | |
216 | MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points); | |
217 | ||
218 | if(!fPathMarks.empty()){ | |
219 | for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) { | |
220 | Reve::PathMark* pm = *i; | |
221 | ||
222 | if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){ | |
223 | if(TMath::Abs(pm->V.z) > RS.fMaxZ | |
224 | || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR ) | |
225 | goto line_bounds; | |
226 | line.GotoVertex(pm->V.x, pm->V.y, pm->V.z); | |
227 | fP.x -= pm->P.x; | |
228 | fP.y -= pm->P.y; | |
229 | fP.z -= pm->P.z; | |
230 | } | |
231 | ||
232 | if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){ | |
233 | if(TMath::Abs(pm->V.z) > RS.fMaxZ | |
234 | || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR ) | |
235 | goto line_bounds; | |
236 | line.GotoVertex(pm->V.x, pm->V.y, pm->V.z); | |
237 | decay = true; | |
238 | break; | |
239 | } | |
240 | } | |
241 | } | |
242 | ||
243 | line_bounds: | |
48dc973d | 244 | if(!decay || RS.fFitDecay == kFALSE) |
5a5a1232 | 245 | line.GotoBounds(px,py,pz); |
246 | ||
247 | } | |
248 | make_polyline: | |
b855ed81 | 249 | { |
250 | Int_t size = TMath::Min(4096, (Int_t) track_points.size()); | |
251 | // printf("track '%s' N = %u\n", GetName(), track_points.size()); | |
252 | Reset(size); | |
253 | for(Int_t i=0; i<size; ++i) | |
254 | { | |
255 | MCVertex& v = track_points[i]; | |
256 | SetNextPoint(v.x, v.y, v.z); | |
257 | } | |
258 | } | |
2fbbf445 | 259 | |
260 | if(recurse) { | |
a8a51cc7 | 261 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) |
262 | { | |
263 | Track* t = dynamic_cast<Track*>(*i); | |
264 | if(t) t->MakeTrack(recurse); | |
2fbbf445 | 265 | } |
266 | } | |
5a5a1232 | 267 | } |
268 | ||
ba008f46 | 269 | /**************************************************************************/ |
a8a51cc7 | 270 | |
ba008f46 | 271 | namespace { |
a8a51cc7 | 272 | |
273 | struct cmp_pathmark | |
274 | { | |
ba008f46 | 275 | bool operator()(PathMark* const & a, PathMark* const & b) |
276 | { return a->time < b->time; } | |
277 | }; | |
a8a51cc7 | 278 | |
ba008f46 | 279 | } |
280 | ||
281 | void Track::SortPathMarksByTime() | |
282 | { | |
b855ed81 | 283 | std::sort(fPathMarks.begin(), fPathMarks.end(), cmp_pathmark()); |
ba008f46 | 284 | } |
285 | ||
5a5a1232 | 286 | /**************************************************************************/ |
287 | ||
48dc973d | 288 | void Track::ImportHits() |
289 | { | |
290 | Reve::LoadMacro("hits_from_label.C"); | |
2fbbf445 | 291 | gROOT->ProcessLine(Form("hits_from_label(%d, (Reve::RenderElement*)%p);", |
292 | fLabel, this)); | |
48dc973d | 293 | } |
294 | ||
295 | void Track::ImportClusters() | |
296 | { | |
297 | Reve::LoadMacro("clusters_from_label.C"); | |
2fbbf445 | 298 | gROOT->ProcessLine(Form("clusters_from_label(%d, (Reve::RenderElement*)%p);", |
299 | fLabel, this)); | |
48dc973d | 300 | } |
301 | ||
fa446a68 | 302 | void Track::ImportClustersFromIndex() |
303 | { | |
7cbaaebd | 304 | static const Exc_t eH("Track::ImportClustersFromIndex "); |
305 | ||
306 | if (fIndex < 0) | |
307 | throw(eH + "index not set."); | |
308 | ||
fa446a68 | 309 | Reve::LoadMacro("clusters_from_index.C"); |
2fbbf445 | 310 | gROOT->ProcessLine(Form("clusters_from_index(%d, (Reve::RenderElement*)%p);", |
311 | fIndex, this)); | |
fa446a68 | 312 | } |
313 | ||
b8879e69 | 314 | /**************************************************************************/ |
315 | ||
316 | void Track::ImportKine() | |
317 | { | |
318 | static const Exc_t eH("Track::ImportKine "); | |
319 | ||
320 | if (fLabel < 0) | |
321 | throw(eH + "label not set."); | |
322 | ||
323 | Reve::LoadMacro("kine_tracks.C"); | |
2fbbf445 | 324 | gROOT->ProcessLine(Form("kine_track(%d, kFALSE, kTRUE, (Reve::RenderElement*)%p);", |
325 | fLabel, this)); | |
326 | ||
b8879e69 | 327 | } |
328 | ||
329 | void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters) | |
a525aa60 | 330 | { |
b8879e69 | 331 | static const Exc_t eH("Track::ImportKineWithArgs "); |
a525aa60 | 332 | |
333 | if (fLabel < 0) | |
334 | throw(eH + "label not set."); | |
335 | ||
b8879e69 | 336 | Reve::LoadMacro("kine_tracks.C"); |
2fbbf445 | 337 | gROOT->ProcessLine(Form("kine_track(%d, %d, %d, (Reve::RenderElement*)%p);", |
338 | fLabel, importMother, importDaugters, this)); | |
a525aa60 | 339 | } |
340 | ||
341 | /**************************************************************************/ | |
342 | ||
b1f08706 | 343 | void Track::PrintKineStack() |
344 | { | |
345 | Reve::LoadMacro("print_kine_from_label.C"); | |
346 | gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel)); | |
347 | } | |
348 | ||
a525aa60 | 349 | |
350 | void Track::PrintPathMarks() | |
351 | { | |
352 | static const Exc_t eH("Track::PrintPathMarks "); | |
353 | ||
354 | if (fLabel < 0) | |
355 | throw(eH + "label not set."); | |
356 | ||
b855ed81 | 357 | printf("Track '%s', number of path marks %d, label %d\n", |
358 | GetName(), fPathMarks.size(), fLabel); | |
a525aa60 | 359 | |
360 | PathMark* pm; | |
361 | for(vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); i++) | |
362 | { | |
363 | pm = *i; | |
b855ed81 | 364 | printf(" %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g \n", |
a525aa60 | 365 | pm->type_name(), |
366 | pm->P.x, pm->P.y, pm->P.z, | |
367 | pm->V.x, pm->V.y, pm->V.z, | |
368 | pm->time); | |
369 | } | |
370 | } | |
371 | ||
9c39ede9 | 372 | /**************************************************************************/ |
373 | ||
374 | void Track::CtrlClicked(Reve::Track* track) | |
375 | { | |
376 | Emit("CtrlClicked(Reve::Track*)", (Long_t)track); | |
377 | } | |
378 | ||
48dc973d | 379 | |
380 | /**************************************************************************/ | |
381 | /**************************************************************************/ | |
382 | ||
5a5a1232 | 383 | //______________________________________________________________________ |
384 | // TrackRnrStyle | |
385 | // | |
386 | ||
387 | ClassImp(Reve::TrackRnrStyle) | |
388 | ||
48dc973d | 389 | Float_t TrackRnrStyle::fgDefMagField = 5; |
390 | const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3; | |
5a5a1232 | 391 | TrackRnrStyle TrackRnrStyle::fgDefStyle; |
392 | ||
265ecb21 | 393 | TrackRnrStyle::TrackRnrStyle() : |
394 | TObject(), | |
5a5a1232 | 395 | |
265ecb21 | 396 | fColor(1), |
2074deef | 397 | fWidth(1), |
ec019a35 | 398 | fStyle(1), |
265ecb21 | 399 | fMagField(fgDefMagField), |
5a5a1232 | 400 | |
265ecb21 | 401 | fMaxR (350), |
402 | fMaxZ (450), | |
5a5a1232 | 403 | |
265ecb21 | 404 | fMaxOrbs (0.5), |
405 | fMinAng (45), | |
406 | fDelta (0.1), | |
5a5a1232 | 407 | |
22df2a83 | 408 | fMinPt (0.1), |
409 | fMaxPt (10), | |
410 | ||
4f5ee1c6 | 411 | fMinP (0.1), |
412 | fMaxP (100), | |
413 | ||
7cbaaebd | 414 | fFitDaughters (kTRUE), |
415 | fFitReferences (kTRUE), | |
416 | fFitDecay (kTRUE), | |
5a5a1232 | 417 | |
7cbaaebd | 418 | fRnrDaughters (kTRUE), |
419 | fRnrReferences (kTRUE), | |
420 | fRnrDecay (kTRUE) | |
421 | {} | |
5a5a1232 | 422 | /**************************************************************************/ |
423 | /**************************************************************************/ | |
424 | ||
425 | //______________________________________________________________________ | |
426 | // TrackList | |
427 | // | |
428 | ||
429 | ClassImp(Reve::TrackList) | |
430 | ||
431 | void TrackList::Init() | |
432 | { | |
139b93bd | 433 | fMarkerStyle = 2; |
a4fc27a6 | 434 | fMarkerColor = 4; |
139b93bd | 435 | fMarkerSize = 0.6; |
5a5a1232 | 436 | |
a8600b56 | 437 | if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle; |
438 | SetMainColorPtr(&fRnrStyle->fColor); | |
5a5a1232 | 439 | } |
440 | ||
a8600b56 | 441 | TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) : |
2fbbf445 | 442 | RenderElement(), |
265ecb21 | 443 | TPolyMarker3D(n_tracks), |
444 | ||
445 | fTitle(), | |
446 | ||
7cbaaebd | 447 | fRnrStyle (rs), |
448 | fRnrTracks (kTRUE), | |
449 | fEditPathMarks (kFALSE) | |
5a5a1232 | 450 | { |
451 | Init(); | |
452 | } | |
453 | ||
a8600b56 | 454 | TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) : |
2fbbf445 | 455 | RenderElement(), |
265ecb21 | 456 | TPolyMarker3D(n_tracks), |
a8600b56 | 457 | |
265ecb21 | 458 | fTitle(), |
459 | ||
139b93bd | 460 | fRnrStyle (rs), |
461 | fRnrTracks (kTRUE), | |
462 | fEditPathMarks (kFALSE) | |
5a5a1232 | 463 | { |
464 | Init(); | |
465 | SetName(name); | |
466 | } | |
467 | ||
468 | void TrackList::Reset(Int_t n_tracks) | |
469 | { | |
470 | delete [] fP; fP = 0; | |
471 | fN = n_tracks; | |
472 | if(fN) fP = new Float_t [3*fN]; | |
473 | memset(fP, 0, 3*fN*sizeof(Float_t)); | |
474 | fLastPoint = -1; | |
475 | } | |
476 | ||
477 | /**************************************************************************/ | |
478 | ||
479 | void TrackList::Paint(Option_t* option) | |
480 | { | |
2fbbf445 | 481 | if(fRnrSelf) { |
5a5a1232 | 482 | if(fRnrMarkers) { |
483 | TPolyMarker3D::Paint(option); | |
484 | } | |
2fbbf445 | 485 | if(fRnrTracks && fRnrChildren) { |
9c39ede9 | 486 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
2fbbf445 | 487 | if((*i)->GetRnrSelf()) |
5a5a1232 | 488 | (*i)->GetObject()->Paint(option); |
489 | } | |
490 | } | |
491 | } | |
492 | } | |
493 | ||
494 | /**************************************************************************/ | |
495 | ||
496 | void TrackList::AddElement(RenderElement* el) | |
497 | { | |
498 | static const Exc_t eH("TrackList::AddElement "); | |
499 | if (dynamic_cast<Track*>(el) == 0) | |
500 | throw(eH + "new element not a Track."); | |
2fbbf445 | 501 | RenderElement::AddElement(el); |
5a5a1232 | 502 | } |
503 | ||
504 | /**************************************************************************/ | |
505 | ||
a8a51cc7 | 506 | void TrackList::MakeTracks(Bool_t recurse) |
5a5a1232 | 507 | { |
a8a51cc7 | 508 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) |
509 | { | |
510 | ((Track*)(*i))->MakeTrack(recurse); | |
5a5a1232 | 511 | } |
512 | gReve->Redraw3D(); | |
513 | } | |
514 | ||
515 | ||
516 | void TrackList::MakeMarkers() | |
517 | { | |
7d42b6c2 | 518 | Reset(fChildren.size()); |
9c39ede9 | 519 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
5a5a1232 | 520 | Track& t = *((Track*)(*i)); |
4f5ee1c6 | 521 | if(t.GetRnrSelf() && t.GetN() > 0) |
5a5a1232 | 522 | SetNextPoint(t.fV.x, t.fV.y, t.fV.z); |
523 | } | |
524 | gReve->Redraw3D(); | |
525 | } | |
526 | ||
527 | /**************************************************************************/ | |
528 | /*************************************************************************/ | |
529 | ||
2074deef | 530 | void TrackList::SetWidth(Width_t w) |
531 | { | |
532 | Width_t oldw = fRnrStyle->fWidth; | |
533 | fRnrStyle->fWidth = w; | |
9c39ede9 | 534 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
2074deef | 535 | Track& t = *((Track*)(*i)); |
536 | if (t.GetLineWidth() == oldw) | |
537 | t.SetLineWidth(w); | |
538 | } | |
539 | } | |
540 | ||
ec019a35 | 541 | void TrackList::SetStyle(Style_t s) |
542 | { | |
543 | Style_t olds = fRnrStyle->fStyle; | |
544 | fRnrStyle->fStyle = s; | |
545 | for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { | |
546 | Track& t = *((Track*)(*i)); | |
547 | if (t.GetLineStyle() == olds) | |
548 | t.SetLineStyle(s); | |
549 | } | |
550 | } | |
551 | ||
5a5a1232 | 552 | void TrackList::SetMaxR(Float_t x) |
553 | { | |
a8600b56 | 554 | fRnrStyle->fMaxR = x; |
5a5a1232 | 555 | MakeTracks(); |
556 | MakeMarkers(); | |
557 | } | |
558 | ||
559 | void TrackList::SetMaxZ(Float_t x) | |
560 | { | |
a8600b56 | 561 | fRnrStyle->fMaxZ = x; |
5a5a1232 | 562 | MakeTracks(); |
563 | MakeMarkers(); | |
564 | } | |
565 | ||
566 | void TrackList::SetMaxOrbs(Float_t x) | |
567 | { | |
a8600b56 | 568 | fRnrStyle->fMaxOrbs = x; |
5a5a1232 | 569 | MakeTracks(); |
570 | } | |
571 | ||
572 | void TrackList::SetMinAng(Float_t x) | |
573 | { | |
a8600b56 | 574 | fRnrStyle->fMinAng = x; |
5a5a1232 | 575 | MakeTracks(); |
576 | } | |
577 | ||
578 | void TrackList::SetDelta(Float_t x) | |
579 | { | |
a8600b56 | 580 | fRnrStyle->fDelta = x; |
5a5a1232 | 581 | MakeTracks(); |
582 | } | |
583 | ||
584 | void TrackList::SetFitDaughters(Bool_t x) | |
585 | { | |
a8600b56 | 586 | fRnrStyle->fFitDaughters = x; |
5a5a1232 | 587 | MakeTracks(); |
588 | } | |
589 | ||
7cbaaebd | 590 | void TrackList::SetFitReferences(Bool_t x) |
591 | { | |
592 | fRnrStyle->fFitReferences = x; | |
593 | MakeTracks(); | |
594 | } | |
595 | ||
5a5a1232 | 596 | void TrackList::SetFitDecay(Bool_t x) |
597 | { | |
a8600b56 | 598 | fRnrStyle->fFitDecay = x; |
5a5a1232 | 599 | MakeTracks(); |
600 | } | |
601 | ||
7cbaaebd | 602 | void TrackList::SetRnrDecay(Bool_t rnr) |
603 | { | |
604 | fRnrStyle->fRnrDecay = rnr; | |
605 | MakeTracks(); | |
606 | } | |
607 | ||
608 | void TrackList::SetRnrDaughters(Bool_t rnr) | |
609 | { | |
610 | fRnrStyle->fRnrDaughters = rnr; | |
611 | MakeTracks(); | |
612 | } | |
613 | ||
614 | void TrackList::SetRnrReferences(Bool_t rnr) | |
615 | { | |
616 | fRnrStyle->fRnrReferences = rnr; | |
617 | MakeTracks(); | |
618 | } | |
619 | ||
620 | void TrackList::SetRnrMarkers(Bool_t rnr) | |
621 | { | |
622 | fRnrMarkers = rnr; | |
623 | gReve->Redraw3D(); | |
624 | } | |
625 | ||
626 | void TrackList::SetRnrTracks(Bool_t rnr) | |
627 | { | |
7cbaaebd | 628 | fRnrTracks = rnr; |
629 | gReve->Redraw3D(); | |
630 | } | |
631 | ||
5a5a1232 | 632 | /**************************************************************************/ |
633 | /**************************************************************************/ | |
634 | ||
635 | void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt) | |
636 | { | |
22df2a83 | 637 | fRnrStyle->fMinPt = min_pt; |
638 | fRnrStyle->fMaxPt = max_pt; | |
639 | ||
5a5a1232 | 640 | Float_t minptsq = min_pt*min_pt; |
641 | Float_t maxptsq = max_pt*max_pt; | |
642 | Float_t ptsq; | |
643 | ||
9c39ede9 | 644 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
5a5a1232 | 645 | ptsq = ((Track*)(*i))->fP.Perp2(); |
a8a51cc7 | 646 | Bool_t on = ptsq >= minptsq && ptsq <= maxptsq; |
647 | (*i)->SetRnrSelf(on); | |
648 | (*i)->SetRnrChildren(on); | |
5a5a1232 | 649 | } |
650 | } | |
651 | ||
4f5ee1c6 | 652 | void TrackList::SelectByP(Float_t min_p, Float_t max_p) |
653 | { | |
654 | fRnrStyle->fMinP = min_p; | |
655 | fRnrStyle->fMaxP = max_p; | |
656 | ||
657 | Float_t minpsq = min_p*min_p; | |
658 | Float_t maxpsq = max_p*max_p; | |
659 | Float_t psq; | |
660 | ||
661 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { | |
e7c2ba6b | 662 | psq = ((Track*)(*i))->fP.Mag(); |
663 | psq *= psq; | |
4f5ee1c6 | 664 | (*i)->SetRnrSelf(psq >= minpsq && psq <= maxpsq); |
665 | } | |
666 | } | |
667 | ||
5a5a1232 | 668 | /**************************************************************************/ |
669 | ||
b99aed53 | 670 | void TrackList::ImportHits() |
5a5a1232 | 671 | { |
9c39ede9 | 672 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
b99aed53 | 673 | ((Track*)(*i))->ImportHits(); |
674 | } | |
5a5a1232 | 675 | } |
676 | ||
b99aed53 | 677 | void TrackList::ImportClusters() |
5a5a1232 | 678 | { |
9c39ede9 | 679 | for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) { |
b99aed53 | 680 | ((Track*)(*i))->ImportClusters(); |
681 | } | |
5a5a1232 | 682 | } |
9c39ede9 | 683 | |
684 | /**************************************************************************/ | |
685 | /**************************************************************************/ | |
686 | /**************************************************************************/ | |
687 | ||
688 | #include "RGEditor.h" | |
689 | ||
690 | //______________________________________________________________________ | |
691 | // TrackCounter | |
692 | // | |
693 | ||
694 | ClassImp(TrackCounter) | |
695 | ||
b1f08706 | 696 | TrackCounter* TrackCounter::fgInstance = 0; |
697 | ||
9c39ede9 | 698 | TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) : |
699 | RenderElement(), | |
700 | TNamed(name, title), | |
701 | ||
702 | fBadLineStyle (6), | |
703 | fClickAction (CA_ToggleTrack), | |
704 | fAllTracks (0), | |
705 | fGoodTracks (0), | |
706 | fTrackLists () | |
707 | { | |
b1f08706 | 708 | if (fgInstance == 0) fgInstance = this; |
9c39ede9 | 709 | TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)", |
710 | "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)"); | |
711 | } | |
712 | ||
713 | TrackCounter::~TrackCounter() | |
714 | { | |
715 | TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)"); | |
b1f08706 | 716 | if (fgInstance == this) fgInstance = 0; |
9c39ede9 | 717 | } |
718 | ||
719 | /**************************************************************************/ | |
720 | ||
721 | void TrackCounter::Reset() | |
722 | { | |
723 | printf("TrackCounter::Reset()\n"); | |
724 | fAllTracks = 0; | |
725 | fGoodTracks = 0; | |
726 | TIter next(&fTrackLists); | |
727 | TrackList* tlist; | |
728 | while ((tlist = dynamic_cast<TrackList*>(next()))) | |
729 | tlist->RemoveParent(this); | |
730 | fTrackLists.Clear(); | |
731 | } | |
732 | ||
733 | void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks) | |
734 | { | |
735 | // printf("TrackCounter::RegisterTracks '%s', %s\n", | |
736 | // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad"); | |
737 | ||
738 | tlist->AddParent(this); | |
739 | fTrackLists.Add(tlist); | |
740 | ||
741 | List_i i = tlist->BeginChildren(); | |
742 | while (i != tlist->EndChildren()) | |
743 | { | |
744 | Track* t = dynamic_cast<Track*>(*i); | |
745 | if (t != 0) | |
746 | { | |
747 | if (goodTracks) | |
748 | { | |
749 | ++fGoodTracks; | |
750 | } else { | |
751 | t->SetLineStyle(fBadLineStyle); | |
752 | } | |
753 | ++fAllTracks; | |
754 | } | |
755 | ++i; | |
756 | } | |
757 | } | |
758 | ||
759 | void TrackCounter::DoTrackAction(Track* track) | |
760 | { | |
761 | // !!!! No check done if ok. | |
762 | // !!!! Should also override RemoveElementLocal | |
7af62191 | 763 | // !!!! But then ... should also sotre local information if track is ok. |
9c39ede9 | 764 | |
765 | switch (fClickAction) | |
766 | { | |
767 | ||
768 | case CA_PrintTrackInfo: | |
769 | { | |
770 | printf("Track '%s'\n", track->GetObject()->GetName()); | |
771 | Vector &v = track->fV, &p = track->fP; | |
772 | printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n", | |
773 | v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi()); | |
774 | printf(" <other information should be printed ... full AliESDtrack>\n"); | |
775 | break; | |
776 | } | |
777 | ||
778 | case CA_ToggleTrack: | |
779 | { | |
780 | if (track->GetLineStyle() == 1) | |
781 | { | |
782 | track->SetLineStyle(fBadLineStyle); | |
783 | --fGoodTracks; | |
784 | } else { | |
785 | track->SetLineStyle(1); | |
786 | ++fGoodTracks; | |
787 | } | |
788 | gReve->Redraw3D(); | |
789 | ||
790 | printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n", | |
791 | fAllTracks, fGoodTracks, fAllTracks-fGoodTracks); | |
792 | ||
793 | if (gReve->GetEditor()->GetModel() == GetObject()) | |
794 | gReve->EditRenderElement(this); | |
795 | ||
796 | break; | |
797 | } | |
798 | ||
799 | } // end switch fClickAction | |
800 | } | |
7af62191 | 801 | |
802 | /**************************************************************************/ | |
803 | ||
804 | void TrackCounter::OutputEventTracks(FILE* out) | |
805 | { | |
806 | if (out == 0) | |
807 | { | |
808 | out = stdout; | |
809 | fprintf(out, "TrackCounter::FinalizeEvent()\n"); | |
810 | } | |
811 | ||
812 | fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks); | |
813 | ||
814 | TIter tlists(&fTrackLists); | |
815 | TrackList* tlist; | |
816 | Int_t cnt = 0; | |
817 | while ((tlist = (TrackList*) tlists()) != 0) | |
818 | { | |
819 | List_i i = tlist->BeginChildren(); | |
820 | while (i != tlist->EndChildren()) | |
821 | { | |
822 | Track* t = dynamic_cast<Track*>(*i); | |
823 | if (t != 0 && t->GetLineStyle() == 1) | |
824 | { | |
825 | ++cnt; | |
826 | fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n", | |
827 | cnt, t->fCharge, t->fP.Perp(), t->fP.Eta()); | |
828 | } | |
829 | ++i; | |
830 | } | |
7af62191 | 831 | } |
832 | } |