4 #include "MCHelixLine.hi"
6 #include <TPolyLine3D.h>
7 #include <TPolyMarker3D.h>
11 #include <Reve/RGTopFrame.h>
18 //______________________________________________________________________
37 Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs):
40 fV(t->Vx(), t->Vy(), t->Vz()),
41 fP(t->Px(), t->Py(), t->Pz()),
42 fBeta(t->P()/t->Energy()),
49 fLineColor = fRnrStyle->GetColor();
50 fMainColorPtr = &fLineColor;
52 TParticlePDG* pdgp = t->GetPDG();
54 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
56 SetName(t->GetName());
59 Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs):
62 fV(t->Vx(), t->Vy(), t->Vz()),
63 fP(t->Px(), t->Py(), t->Pz()),
64 fBeta(t->P()/t->Energy()),
72 fLineColor = fRnrStyle->GetColor();
73 fMainColorPtr = &fLineColor;
75 TParticlePDG* pdgp = t->GetPDG();
77 t->ResetPdgCode(); pdgp = t->GetPDG();
79 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
81 SetName(t->GetName());
84 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
97 fLineColor = fRnrStyle->GetColor();
98 fMainColorPtr = &fLineColor;
100 SetName(t->GetName());
105 for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
110 void Track::Reset(Int_t n_points)
112 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
114 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
115 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
120 /**************************************************************************/
122 void Track::MakeTrack()
125 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
127 Float_t px = fP.x, py = fP.y, pz = fP.z;
135 std::vector<MCVertex> track_points;
136 Bool_t decay = kFALSE;
138 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
141 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
143 // Charged particle in magnetic field
145 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
147 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
148 helix.Init(TMath::Sqrt(px*px+py*py), pz);
150 if(!fPathMarks.empty()){
151 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
152 Reve::PathMark* pm = *i;
154 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
155 if(TMath::Abs(pm->V.z) > RS.fMaxZ
156 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
159 //printf("%s fit daughter \n", fName.Data());
160 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
165 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
167 if(TMath::Abs(pm->V.z) > RS.fMaxZ
168 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
170 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
178 if(!decay || RS.fFitDecay == kFALSE){
179 helix.LoopToBounds(px,py,pz);
180 // printf("%s loop to bounds \n",fName.Data() );
185 // Neutral particle or no field
187 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
189 if(!fPathMarks.empty()){
190 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
191 Reve::PathMark* pm = *i;
193 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
194 if(TMath::Abs(pm->V.z) > RS.fMaxZ
195 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
197 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
203 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
204 if(TMath::Abs(pm->V.z) > RS.fMaxZ
205 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
207 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
215 if(!decay || RS.fFitDecay == kFALSE)
216 line.GotoBounds(px,py,pz);
220 Reset(track_points.size());
221 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
222 SetNextPoint(i->x, i->y, i->z);
225 /**************************************************************************/
227 void Track::ImportHits()
229 Reve::LoadMacro("hits_from_label.C");
230 gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
233 void Track::ImportClusters()
235 Reve::LoadMacro("clusters_from_label.C");
236 gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
239 void Track::ImportClustersFromIndex()
241 Reve::LoadMacro("clusters_from_index.C");
242 gROOT->ProcessLine(Form("clusters_from_index(%d);", fIndex));
245 void Track::PrintKineStack()
247 Reve::LoadMacro("print_kine_from_label.C");
248 gROOT->ProcessLine(Form("print_kine_from_label(%d);", fLabel));
251 /**************************************************************************/
253 void Track::CtrlClicked(Reve::Track* track)
255 Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
259 /**************************************************************************/
260 /**************************************************************************/
262 //______________________________________________________________________
266 ClassImp(Reve::TrackRnrStyle)
268 Float_t TrackRnrStyle::fgDefMagField = 5;
269 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
270 TrackRnrStyle TrackRnrStyle::fgDefStyle;
272 TrackRnrStyle::TrackRnrStyle() :
277 fMagField(fgDefMagField),
286 fFitDaughters(kTRUE),
290 /**************************************************************************/
291 /**************************************************************************/
293 //______________________________________________________________________
297 ClassImp(Reve::TrackList)
299 void TrackList::Init()
303 // fMarker->SetMarkerSize(0.05);
305 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
306 SetMainColorPtr(&fRnrStyle->fColor);
309 TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
310 RenderElementListBase(),
311 TPolyMarker3D(n_tracks),
322 TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
323 RenderElementListBase(),
324 TPolyMarker3D(n_tracks),
336 void TrackList::Reset(Int_t n_tracks)
338 delete [] fP; fP = 0;
340 if(fN) fP = new Float_t [3*fN];
341 memset(fP, 0, 3*fN*sizeof(Float_t));
345 /**************************************************************************/
347 void TrackList::Paint(Option_t* option)
351 TPolyMarker3D::Paint(option);
354 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
355 if((*i)->GetRnrElement())
356 (*i)->GetObject()->Paint(option);
362 /**************************************************************************/
364 void TrackList::AddElement(RenderElement* el)
366 static const Exc_t eH("TrackList::AddElement ");
367 if (dynamic_cast<Track*>(el) == 0)
368 throw(eH + "new element not a Track.");
369 RenderElementListBase::AddElement(el);
372 /**************************************************************************/
374 void TrackList::SetRnrMarkers(Bool_t rnr)
380 void TrackList::SetRnrTracks(Bool_t rnr)
387 /**************************************************************************/
389 void TrackList::MakeTracks()
391 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
392 ((Track*)(*i))->MakeTrack();
398 void TrackList::MakeMarkers()
400 Reset(fChildren.size());
401 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
402 Track& t = *((Track*)(*i));
404 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
409 /**************************************************************************/
410 /*************************************************************************/
412 void TrackList::SetWidth(Width_t w)
414 Width_t oldw = fRnrStyle->fWidth;
415 fRnrStyle->fWidth = w;
416 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
417 Track& t = *((Track*)(*i));
418 if (t.GetLineWidth() == oldw)
423 void TrackList::SetMaxR(Float_t x)
425 fRnrStyle->fMaxR = x;
430 void TrackList::SetMaxZ(Float_t x)
432 fRnrStyle->fMaxZ = x;
437 void TrackList::SetMaxOrbs(Float_t x)
439 fRnrStyle->fMaxOrbs = x;
443 void TrackList::SetMinAng(Float_t x)
445 fRnrStyle->fMinAng = x;
449 void TrackList::SetDelta(Float_t x)
451 fRnrStyle->fDelta = x;
455 void TrackList::SetFitDaughters(Bool_t x)
457 fRnrStyle->fFitDaughters = x;
461 void TrackList::SetFitDecay(Bool_t x)
463 fRnrStyle->fFitDecay = x;
467 /**************************************************************************/
468 /**************************************************************************/
470 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
472 Float_t minptsq = min_pt*min_pt;
473 Float_t maxptsq = max_pt*max_pt;
476 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
477 ptsq = ((Track*)(*i))->fP.Perp2();
478 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
482 /**************************************************************************/
484 void TrackList::ImportHits()
486 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
487 ((Track*)(*i))->ImportHits();
491 void TrackList::ImportClusters()
493 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
494 ((Track*)(*i))->ImportClusters();
498 /**************************************************************************/
499 /**************************************************************************/
500 /**************************************************************************/
502 #include "RGEditor.h"
504 //______________________________________________________________________
508 ClassImp(TrackCounter)
510 TrackCounter* TrackCounter::fgInstance = 0;
512 TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
517 fClickAction (CA_ToggleTrack),
522 if (fgInstance == 0) fgInstance = this;
523 TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
524 "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
527 TrackCounter::~TrackCounter()
529 TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
530 if (fgInstance == this) fgInstance = 0;
533 /**************************************************************************/
535 void TrackCounter::Reset()
537 printf("TrackCounter::Reset()\n");
540 TIter next(&fTrackLists);
542 while ((tlist = dynamic_cast<TrackList*>(next())))
543 tlist->RemoveParent(this);
547 void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
549 // printf("TrackCounter::RegisterTracks '%s', %s\n",
550 // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
552 tlist->AddParent(this);
553 fTrackLists.Add(tlist);
555 List_i i = tlist->BeginChildren();
556 while (i != tlist->EndChildren())
558 Track* t = dynamic_cast<Track*>(*i);
565 t->SetLineStyle(fBadLineStyle);
573 void TrackCounter::DoTrackAction(Track* track)
575 // !!!! No check done if ok.
576 // !!!! Should also override RemoveElementLocal
577 // !!!! But then ... should also sotre local information if track is ok.
579 switch (fClickAction)
582 case CA_PrintTrackInfo:
584 printf("Track '%s'\n", track->GetObject()->GetName());
585 Vector &v = track->fV, &p = track->fP;
586 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
587 v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
588 printf(" <other information should be printed ... full AliESDtrack>\n");
594 if (track->GetLineStyle() == 1)
596 track->SetLineStyle(fBadLineStyle);
599 track->SetLineStyle(1);
604 printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
605 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
607 if (gReve->GetEditor()->GetModel() == GetObject())
608 gReve->EditRenderElement(this);
613 } // end switch fClickAction
616 /**************************************************************************/
618 void TrackCounter::OutputEventTracks(FILE* out)
623 fprintf(out, "TrackCounter::FinalizeEvent()\n");
626 fprintf(out, "Event = %d Ntracks = %d\n", fEventId, fGoodTracks);
628 TIter tlists(&fTrackLists);
631 while ((tlist = (TrackList*) tlists()) != 0)
633 List_i i = tlist->BeginChildren();
634 while (i != tlist->EndChildren())
636 Track* t = dynamic_cast<Track*>(*i);
637 if (t != 0 && t->GetLineStyle() == 1)
640 fprintf(out, " %2d: chg=%+2d pt=%8.5f eta=%+8.5f\n",
641 cnt, t->fCharge, t->fP.Perp(), t->fP.Eta());