4 #include "MCHelixLine.hi"
7 #include <TPolyLine3D.h>
8 #include <TPolyMarker3D.h>
12 #include <Reve/RGTopFrame.h>
19 //______________________________________________________________________
39 Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs):
42 fV(t->Vx(), t->Vy(), t->Vz()),
43 fP(t->Px(), t->Py(), t->Pz()),
44 fBeta(t->P()/t->Energy()),
52 fLineColor = fRnrStyle->GetColor();
53 fMainColorPtr = &fLineColor;
55 TParticlePDG* pdgp = t->GetPDG();
57 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
59 SetName(t->GetName());
62 Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs):
65 fV(t->Vx(), t->Vy(), t->Vz()),
66 fP(t->Px(), t->Py(), t->Pz()),
67 fBeta(t->P()/t->Energy()),
75 fLineColor = fRnrStyle->GetColor();
76 fMainColorPtr = &fLineColor;
78 TParticlePDG* pdgp = t->GetPDG();
80 t->ResetPdgCode(); pdgp = t->GetPDG();
82 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
84 SetName(t->GetName());
87 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
100 fLineColor = fRnrStyle->GetColor();
101 fMainColorPtr = &fLineColor;
103 SetName(t->GetName());
108 for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
113 void Track::Reset(Int_t n_points)
115 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
117 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
118 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
123 /**************************************************************************/
125 void Track::MakeTrack( Bool_t recurse)
127 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
129 Float_t px = fP.x, py = fP.y, pz = fP.z;
137 std::vector<MCVertex> track_points;
138 Bool_t decay = kFALSE;
140 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
143 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
145 // Charged particle in magnetic field
147 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
149 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
150 helix.Init(TMath::Sqrt(px*px+py*py), pz);
152 if(!fPathMarks.empty())
154 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
156 Reve::PathMark* pm = *i;
158 if (RS.fFitReferences && pm->type == Reve::PathMark::Reference)
160 if(TMath::Abs(pm->V.z) > RS.fMaxZ
161 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
164 // printf("%s fit reference \n", fName.Data());
165 helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z);
170 else if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter)
172 if(TMath::Abs(pm->V.z) > RS.fMaxZ
173 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
176 // printf("%s fit daughter \n", fName.Data());
177 helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z);
182 else if(RS.fFitDecay && pm->type == Reve::PathMark::Decay)
184 if(TMath::Abs(pm->V.z) > RS.fMaxZ
185 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
187 helix.LoopToVertex(px, py, pz, pm->V.x, pm->V.y, pm->V.z);
195 if(!decay || RS.fFitDecay == kFALSE){
196 helix.LoopToBounds(px,py,pz);
197 // printf("%s loop to bounds \n",fName.Data() );
202 // Neutral particle or no field
204 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
206 if(!fPathMarks.empty()){
207 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
208 Reve::PathMark* pm = *i;
210 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
211 if(TMath::Abs(pm->V.z) > RS.fMaxZ
212 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
214 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
220 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
221 if(TMath::Abs(pm->V.z) > RS.fMaxZ
222 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
224 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
232 if(!decay || RS.fFitDecay == kFALSE)
233 line.GotoBounds(px,py,pz);
237 Reset(track_points.size());
238 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
239 SetNextPoint(i->x, i->y, i->z);
243 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
244 t = dynamic_cast<Track*>(*i);
245 if(t)t->MakeTrack(recurse);
250 /**************************************************************************/
252 void Track::ImportHits()
254 Reve::LoadMacro("hits_from_label.C");
255 gROOT->ProcessLine(Form("hits_from_label(%d, (Reve::RenderElement*)%p);",
259 void Track::ImportClusters()
261 Reve::LoadMacro("clusters_from_label.C");
262 gROOT->ProcessLine(Form("clusters_from_label(%d, (Reve::RenderElement*)%p);",
266 void Track::ImportClustersFromIndex()
268 static const Exc_t eH("Track::ImportClustersFromIndex ");
271 throw(eH + "index not set.");
273 Reve::LoadMacro("clusters_from_index.C");
274 gROOT->ProcessLine(Form("clusters_from_index(%d, (Reve::RenderElement*)%p);",
278 /**************************************************************************/
280 void Track::ImportKine()
282 static const Exc_t eH("Track::ImportKine ");
285 throw(eH + "label not set.");
287 Reve::LoadMacro("kine_tracks.C");
288 gROOT->ProcessLine(Form("kine_track(%d, kFALSE, kTRUE, (Reve::RenderElement*)%p);",
293 void Track::ImportKineWithArgs(Bool_t importMother, Bool_t importDaugters)
295 static const Exc_t eH("Track::ImportKineWithArgs ");
298 throw(eH + "label not set.");
300 Reve::LoadMacro("kine_tracks.C");
301 gROOT->ProcessLine(Form("kine_track(%d, %d, %d, (Reve::RenderElement*)%p);",
302 fLabel, importMother, importDaugters, this));
306 /**************************************************************************/
308 void Track::PrintKineStack()
310 Reve::LoadMacro("print_kine_from_label.C");
311 gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel));
315 void Track::PrintPathMarks()
317 static const Exc_t eH("Track::PrintPathMarks ");
320 throw(eH + "label not set.");
322 printf("Number of path marks %d label %d\n",
323 fPathMarks.size(), fLabel);
326 for(vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); i++)
329 printf("Reve::PathMark: %-9s p: %8f %8f %8f Vertex: %8e %8e %8e %g \n",
331 pm->P.x, pm->P.y, pm->P.z,
332 pm->V.x, pm->V.y, pm->V.z,
337 /**************************************************************************/
339 void Track::CtrlClicked(Reve::Track* track)
341 Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
345 /**************************************************************************/
346 /**************************************************************************/
348 //______________________________________________________________________
352 ClassImp(Reve::TrackRnrStyle)
354 Float_t TrackRnrStyle::fgDefMagField = 5;
355 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
356 TrackRnrStyle TrackRnrStyle::fgDefStyle;
358 TrackRnrStyle::TrackRnrStyle() :
363 fMagField(fgDefMagField),
375 fFitDaughters (kTRUE),
376 fFitReferences (kTRUE),
379 fRnrDaughters (kTRUE),
380 fRnrReferences (kTRUE),
383 /**************************************************************************/
384 /**************************************************************************/
386 //______________________________________________________________________
390 ClassImp(Reve::TrackList)
392 void TrackList::Init()
398 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
399 SetMainColorPtr(&fRnrStyle->fColor);
402 TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
404 TPolyMarker3D(n_tracks),
410 fEditPathMarks (kFALSE)
415 TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
417 TPolyMarker3D(n_tracks),
428 void TrackList::Reset(Int_t n_tracks)
430 delete [] fP; fP = 0;
432 if(fN) fP = new Float_t [3*fN];
433 memset(fP, 0, 3*fN*sizeof(Float_t));
437 /**************************************************************************/
439 void TrackList::Paint(Option_t* option)
443 TPolyMarker3D::Paint(option);
445 if(fRnrTracks && fRnrChildren) {
446 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
447 if((*i)->GetRnrSelf())
448 (*i)->GetObject()->Paint(option);
454 /**************************************************************************/
456 void TrackList::AddElement(RenderElement* el)
458 static const Exc_t eH("TrackList::AddElement ");
459 if (dynamic_cast<Track*>(el) == 0)
460 throw(eH + "new element not a Track.");
461 RenderElement::AddElement(el);
464 /**************************************************************************/
466 void TrackList::MakeTracks()
468 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
469 ((Track*)(*i))->MakeTrack();
475 void TrackList::MakeMarkers()
477 Reset(fChildren.size());
478 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
479 Track& t = *((Track*)(*i));
481 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
486 /**************************************************************************/
487 /*************************************************************************/
489 void TrackList::SetWidth(Width_t w)
491 Width_t oldw = fRnrStyle->fWidth;
492 fRnrStyle->fWidth = w;
493 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
494 Track& t = *((Track*)(*i));
495 if (t.GetLineWidth() == oldw)
500 void TrackList::SetMaxR(Float_t x)
502 fRnrStyle->fMaxR = x;
507 void TrackList::SetMaxZ(Float_t x)
509 fRnrStyle->fMaxZ = x;
514 void TrackList::SetMaxOrbs(Float_t x)
516 fRnrStyle->fMaxOrbs = x;
520 void TrackList::SetMinAng(Float_t x)
522 fRnrStyle->fMinAng = x;
526 void TrackList::SetDelta(Float_t x)
528 fRnrStyle->fDelta = x;
532 void TrackList::SetFitDaughters(Bool_t x)
534 fRnrStyle->fFitDaughters = x;
538 void TrackList::SetFitReferences(Bool_t x)
540 fRnrStyle->fFitReferences = x;
544 void TrackList::SetFitDecay(Bool_t x)
546 fRnrStyle->fFitDecay = x;
550 void TrackList::SetRnrDecay(Bool_t rnr)
552 fRnrStyle->fRnrDecay = rnr;
556 void TrackList::SetRnrDaughters(Bool_t rnr)
558 fRnrStyle->fRnrDaughters = rnr;
562 void TrackList::SetRnrReferences(Bool_t rnr)
564 fRnrStyle->fRnrReferences = rnr;
568 void TrackList::SetRnrMarkers(Bool_t rnr)
574 void TrackList::SetRnrTracks(Bool_t rnr)
581 /**************************************************************************/
582 /**************************************************************************/
584 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
586 fRnrStyle->fMinPt = min_pt;
587 fRnrStyle->fMaxPt = max_pt;
589 Float_t minptsq = min_pt*min_pt;
590 Float_t maxptsq = max_pt*max_pt;
593 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
594 ptsq = ((Track*)(*i))->fP.Perp2();
595 (*i)->SetRnrSelf(ptsq >= minptsq && ptsq <= maxptsq);
599 /**************************************************************************/
601 void TrackList::ImportHits()
603 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
604 ((Track*)(*i))->ImportHits();
608 void TrackList::ImportClusters()
610 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
611 ((Track*)(*i))->ImportClusters();
615 /**************************************************************************/
616 /**************************************************************************/
617 /**************************************************************************/
619 #include "RGEditor.h"
621 //______________________________________________________________________
625 ClassImp(TrackCounter)
627 TrackCounter* TrackCounter::fgInstance = 0;
629 TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
634 fClickAction (CA_ToggleTrack),
639 if (fgInstance == 0) fgInstance = this;
640 TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
641 "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
644 TrackCounter::~TrackCounter()
646 TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
647 if (fgInstance == this) fgInstance = 0;
650 /**************************************************************************/
652 void TrackCounter::Reset()
654 printf("TrackCounter::Reset()\n");
657 TIter next(&fTrackLists);
659 while ((tlist = dynamic_cast<TrackList*>(next())))
660 tlist->RemoveParent(this);
664 void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
666 // printf("TrackCounter::RegisterTracks '%s', %s\n",
667 // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
669 tlist->AddParent(this);
670 fTrackLists.Add(tlist);
672 List_i i = tlist->BeginChildren();
673 while (i != tlist->EndChildren())
675 Track* t = dynamic_cast<Track*>(*i);
682 t->SetLineStyle(fBadLineStyle);
690 void TrackCounter::DoTrackAction(Track* track)
692 // !!!! No check done if ok.
693 // !!!! Should also override RemoveElementLocal
694 // !!!! But then ... should also sotre local information if track is ok.
696 switch (fClickAction)
699 case CA_PrintTrackInfo:
701 printf("Track '%s'\n", track->GetObject()->GetName());
702 Vector &v = track->fV, &p = track->fP;
703 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
704 v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
705 printf(" <other information should be printed ... full AliESDtrack>\n");
711 if (track->GetLineStyle() == 1)
713 track->SetLineStyle(fBadLineStyle);
716 track->SetLineStyle(1);
721 printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
722 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
724 if (gReve->GetEditor()->GetModel() == GetObject())
725 gReve->EditRenderElement(this);
730 } // end switch fClickAction
733 /**************************************************************************/
735 void TrackCounter::OutputEventTracks(FILE* out)
740 fprintf(out, "TrackCounter::FinalizeEvent()\n");
743 fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks);
745 TIter tlists(&fTrackLists);
748 while ((tlist = (TrackList*) tlists()) != 0)
750 List_i i = tlist->BeginChildren();
751 while (i != tlist->EndChildren())
753 Track* t = dynamic_cast<Track*>(*i);
754 if (t != 0 && t->GetLineStyle() == 1)
757 fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n",
758 cnt, t->fCharge, t->fP.Perp(), t->fP.Eta());