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()),
71 fLineColor = fRnrStyle->GetColor();
72 fMainColorPtr = &fLineColor;
74 TParticlePDG* pdgp = t->GetPDG();
76 t->ResetPdgCode(); pdgp = t->GetPDG();
78 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
80 SetName(t->GetName());
83 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
95 fLineColor = fRnrStyle->GetColor();
96 fMainColorPtr = &fLineColor;
98 SetName(t->GetName());
103 for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
108 void Track::Reset(Int_t n_points)
110 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
112 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
113 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
118 /**************************************************************************/
120 void Track::MakeTrack()
123 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
125 Float_t px = fP.x, py = fP.y, pz = fP.z;
133 std::vector<MCVertex> track_points;
134 Bool_t decay = kFALSE;
136 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
139 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
141 // Charged particle in magnetic field
143 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
145 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
146 helix.Init(TMath::Sqrt(px*px+py*py), pz);
148 if(!fPathMarks.empty()){
149 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
150 Reve::PathMark* pm = *i;
152 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
153 if(TMath::Abs(pm->V.z) > RS.fMaxZ
154 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
157 //printf("%s fit daughter \n", fName.Data());
158 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
163 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
165 if(TMath::Abs(pm->V.z) > RS.fMaxZ
166 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
168 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
176 if(!decay || RS.fFitDecay == kFALSE){
177 helix.LoopToBounds(px,py,pz);
178 // printf("%s loop to bounds \n",fName.Data() );
183 // Neutral particle or no field
185 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
187 if(!fPathMarks.empty()){
188 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
189 Reve::PathMark* pm = *i;
191 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
192 if(TMath::Abs(pm->V.z) > RS.fMaxZ
193 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
195 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
201 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
202 if(TMath::Abs(pm->V.z) > RS.fMaxZ
203 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
205 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
213 if(!decay || RS.fFitDecay == kFALSE)
214 line.GotoBounds(px,py,pz);
218 Reset(track_points.size());
219 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
220 SetNextPoint(i->x, i->y, i->z);
223 /**************************************************************************/
225 void Track::ImportHits()
227 Reve::LoadMacro("hits_from_label.C");
228 gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
231 void Track::ImportClusters()
233 Reve::LoadMacro("clusters_from_label.C");
234 gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
237 /**************************************************************************/
239 void Track::CtrlClicked(Reve::Track* track)
241 Emit("CtrlClicked(Reve::Track*)", (Long_t)track);
245 /**************************************************************************/
246 /**************************************************************************/
248 //______________________________________________________________________
252 ClassImp(Reve::TrackRnrStyle)
254 Float_t TrackRnrStyle::fgDefMagField = 5;
255 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
256 TrackRnrStyle TrackRnrStyle::fgDefStyle;
258 TrackRnrStyle::TrackRnrStyle() :
263 fMagField(fgDefMagField),
272 fFitDaughters(kTRUE),
276 /**************************************************************************/
277 /**************************************************************************/
279 //______________________________________________________________________
283 ClassImp(Reve::TrackList)
285 void TrackList::Init()
289 // fMarker->SetMarkerSize(0.05);
291 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
292 SetMainColorPtr(&fRnrStyle->fColor);
295 TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
296 RenderElementListBase(),
297 TPolyMarker3D(n_tracks),
308 TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
309 RenderElementListBase(),
310 TPolyMarker3D(n_tracks),
322 void TrackList::Reset(Int_t n_tracks)
324 delete [] fP; fP = 0;
326 if(fN) fP = new Float_t [3*fN];
327 memset(fP, 0, 3*fN*sizeof(Float_t));
331 /**************************************************************************/
333 void TrackList::Paint(Option_t* option)
337 TPolyMarker3D::Paint(option);
340 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
341 if((*i)->GetRnrElement())
342 (*i)->GetObject()->Paint(option);
348 /**************************************************************************/
350 void TrackList::AddElement(RenderElement* el)
352 static const Exc_t eH("TrackList::AddElement ");
353 if (dynamic_cast<Track*>(el) == 0)
354 throw(eH + "new element not a Track.");
355 RenderElementListBase::AddElement(el);
358 /**************************************************************************/
360 void TrackList::SetRnrMarkers(Bool_t rnr)
366 void TrackList::SetRnrTracks(Bool_t rnr)
373 /**************************************************************************/
375 void TrackList::MakeTracks()
377 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
378 ((Track*)(*i))->MakeTrack();
384 void TrackList::MakeMarkers()
386 Reset(fChildren.size());
387 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
388 Track& t = *((Track*)(*i));
390 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
395 /**************************************************************************/
396 /*************************************************************************/
398 void TrackList::SetWidth(Width_t w)
400 Width_t oldw = fRnrStyle->fWidth;
401 fRnrStyle->fWidth = w;
402 for (List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
403 Track& t = *((Track*)(*i));
404 if (t.GetLineWidth() == oldw)
409 void TrackList::SetMaxR(Float_t x)
411 fRnrStyle->fMaxR = x;
416 void TrackList::SetMaxZ(Float_t x)
418 fRnrStyle->fMaxZ = x;
423 void TrackList::SetMaxOrbs(Float_t x)
425 fRnrStyle->fMaxOrbs = x;
429 void TrackList::SetMinAng(Float_t x)
431 fRnrStyle->fMinAng = x;
435 void TrackList::SetDelta(Float_t x)
437 fRnrStyle->fDelta = x;
441 void TrackList::SetFitDaughters(Bool_t x)
443 fRnrStyle->fFitDaughters = x;
447 void TrackList::SetFitDecay(Bool_t x)
449 fRnrStyle->fFitDecay = x;
453 /**************************************************************************/
454 /**************************************************************************/
456 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
458 Float_t minptsq = min_pt*min_pt;
459 Float_t maxptsq = max_pt*max_pt;
462 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
463 ptsq = ((Track*)(*i))->fP.Perp2();
464 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
468 /**************************************************************************/
470 void TrackList::ImportHits()
472 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
473 ((Track*)(*i))->ImportHits();
477 void TrackList::ImportClusters()
479 for(List_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
480 ((Track*)(*i))->ImportClusters();
484 /**************************************************************************/
485 /**************************************************************************/
486 /**************************************************************************/
488 #include "RGEditor.h"
490 //______________________________________________________________________
494 ClassImp(TrackCounter)
496 TrackCounter::TrackCounter(const Text_t* name, const Text_t* title) :
501 fClickAction (CA_ToggleTrack),
506 TQObject::Connect("Reve::Track", "CtrlClicked(Reve::Track*)",
507 "Reve::TrackCounter", this, "DoTrackAction(Reve::Track*)");
510 TrackCounter::~TrackCounter()
512 TQObject::Disconnect("Reve::Track", "DoTrackAction(Reve::Track*)");
515 /**************************************************************************/
517 void TrackCounter::Reset()
519 printf("TrackCounter::Reset()\n");
522 TIter next(&fTrackLists);
524 while ((tlist = dynamic_cast<TrackList*>(next())))
525 tlist->RemoveParent(this);
529 void TrackCounter::RegisterTracks(TrackList* tlist, Bool_t goodTracks)
531 // printf("TrackCounter::RegisterTracks '%s', %s\n",
532 // tlist->GetObject()->GetName(), goodTracks ? "good" : "bad");
534 tlist->AddParent(this);
535 fTrackLists.Add(tlist);
537 List_i i = tlist->BeginChildren();
538 while (i != tlist->EndChildren())
540 Track* t = dynamic_cast<Track*>(*i);
547 t->SetLineStyle(fBadLineStyle);
555 void TrackCounter::DoTrackAction(Track* track)
557 // !!!! No check done if ok.
558 // !!!! Should also override RemoveElementLocal
559 // !!!! But then ... should also sore local information if track is ok.
561 switch (fClickAction)
564 case CA_PrintTrackInfo:
566 printf("Track '%s'\n", track->GetObject()->GetName());
567 Vector &v = track->fV, &p = track->fP;
568 printf(" Vx=%f, Vy=%f, Vz=%f; Pt=%f, Pz=%f, phi=%f)\n",
569 v.x, v.y, v.z, p.Perp(), p.z, TMath::RadToDeg()*p.Phi());
570 printf(" <other information should be printed ... full AliESDtrack>\n");
576 if (track->GetLineStyle() == 1)
578 track->SetLineStyle(fBadLineStyle);
581 track->SetLineStyle(1);
586 printf("TrackCounter::CountTrack All=%d, Good=%d, Bad=%d\n",
587 fAllTracks, fGoodTracks, fAllTracks-fGoodTracks);
589 if (gReve->GetEditor()->GetModel() == GetObject())
590 gReve->EditRenderElement(this);
595 } // end switch fClickAction