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