4 #include "MCHelixLine.hi"
6 #include <TPolyLine3D.h>
7 #include <TPolyMarker3D.h>
11 #include <Reve/RGTopFrame.h>
18 //______________________________________________________________________
41 Track::Track(TParticle* t, Int_t label, TrackRnrStyle* rs):
45 fV(t->Vx(), t->Vy(), t->Vz()),
46 fP(t->Px(), t->Py(), t->Pz()),
47 fBeta(t->P()/t->Energy()),
57 fLineColor = fRnrStyle->GetColor();
58 fMainColorPtr = &fLineColor;
60 TParticlePDG* pdgp = t->GetPDG();
62 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
65 Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs):
69 fV(t->Vx(), t->Vy(), t->Vz()),
70 fP(t->Px(), t->Py(), t->Pz()),
71 fBeta(t->P()/t->Energy()),
81 fLineColor = fRnrStyle->GetColor();
82 fMainColorPtr = &fLineColor;
84 TParticlePDG* pdgp = t->GetPDG();
86 t->ResetPdgCode(); pdgp = t->GetPDG();
88 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
91 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
107 fLineColor = fRnrStyle->GetColor();
108 fMainColorPtr = &fLineColor;
113 for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
117 void Track::Reset(Int_t n_points)
119 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
121 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
122 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
126 /**************************************************************************/
128 void Track::MakeTrack()
131 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
133 Float_t px = fP.x, py = fP.y, pz = fP.z;
141 std::vector<MCVertex> track_points;
142 Bool_t decay = kFALSE;
144 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
147 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
149 // Charged particle in magnetic field
151 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
153 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
154 helix.Init(TMath::Sqrt(px*px+py*py), pz);
156 if(!fPathMarks.empty()){
157 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
158 Reve::PathMark* pm = *i;
160 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
161 if(TMath::Abs(pm->V.z) > RS.fMaxZ
162 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
165 //printf("%s fit daughter \n", fName.Data());
166 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
171 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
173 if(TMath::Abs(pm->V.z) > RS.fMaxZ
174 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
176 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
184 if(!decay || RS.fFitDecay == kFALSE){
185 helix.LoopToBounds(px,py,pz);
186 // printf("%s loop to bounds \n",fName.Data() );
191 // Neutral particle or no field
193 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
195 if(!fPathMarks.empty()){
196 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
197 Reve::PathMark* pm = *i;
199 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
200 if(TMath::Abs(pm->V.z) > RS.fMaxZ
201 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
203 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
209 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
210 if(TMath::Abs(pm->V.z) > RS.fMaxZ
211 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
213 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
221 if(!decay || RS.fFitDecay == kFALSE)
222 line.GotoBounds(px,py,pz);
226 Reset(track_points.size());
227 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
228 SetNextPoint(i->x, i->y, i->z);
231 /**************************************************************************/
233 void Track::ImportHits()
235 Reve::LoadMacro("hits_from_label.C");
236 gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
239 void Track::ImportClusters()
241 Reve::LoadMacro("clusters_from_label.C");
242 gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
246 /**************************************************************************/
247 /**************************************************************************/
249 //______________________________________________________________________
253 ClassImp(Reve::TrackRnrStyle)
255 Float_t TrackRnrStyle::fgDefMagField = 5;
256 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
257 TrackRnrStyle TrackRnrStyle::fgDefStyle;
259 TrackRnrStyle::TrackRnrStyle() :
264 fMagField(fgDefMagField),
273 fFitDaughters(kTRUE),
277 /**************************************************************************/
278 /**************************************************************************/
280 //______________________________________________________________________
284 ClassImp(Reve::TrackList)
286 void TrackList::Init()
290 // fMarker->SetMarkerSize(0.05);
292 if (fRnrStyle== 0) fRnrStyle = new TrackRnrStyle;
293 SetMainColorPtr(&fRnrStyle->fColor);
296 TrackList::TrackList(Int_t n_tracks, TrackRnrStyle* rs) :
297 RenderElementListBase(),
298 TPolyMarker3D(n_tracks),
309 TrackList::TrackList(const Text_t* name, Int_t n_tracks, TrackRnrStyle* rs) :
310 RenderElementListBase(),
311 TPolyMarker3D(n_tracks),
323 void TrackList::Reset(Int_t n_tracks)
325 delete [] fP; fP = 0;
327 if(fN) fP = new Float_t [3*fN];
328 memset(fP, 0, 3*fN*sizeof(Float_t));
332 /**************************************************************************/
334 void TrackList::Paint(Option_t* option)
338 TPolyMarker3D::Paint(option);
341 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
342 if((*i)->GetRnrElement())
343 (*i)->GetObject()->Paint(option);
349 /**************************************************************************/
351 void TrackList::AddElement(RenderElement* el)
353 static const Exc_t eH("TrackList::AddElement ");
354 if (dynamic_cast<Track*>(el) == 0)
355 throw(eH + "new element not a Track.");
356 RenderElementListBase::AddElement(el);
359 /**************************************************************************/
361 void TrackList::SetRnrMarkers(Bool_t rnr)
367 void TrackList::SetRnrTracks(Bool_t rnr)
374 /**************************************************************************/
376 void TrackList::MakeTracks()
378 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
379 ((Track*)(*i))->MakeTrack();
385 void TrackList::MakeMarkers()
387 Reset(fChildren.size());
388 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
389 Track& t = *((Track*)(*i));
391 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
396 /**************************************************************************/
397 /*************************************************************************/
399 void TrackList::SetWidth(Width_t w)
401 Width_t oldw = fRnrStyle->fWidth;
402 fRnrStyle->fWidth = w;
403 for (lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
404 Track& t = *((Track*)(*i));
405 if (t.GetLineWidth() == oldw)
410 void TrackList::SetMaxR(Float_t x)
412 fRnrStyle->fMaxR = x;
417 void TrackList::SetMaxZ(Float_t x)
419 fRnrStyle->fMaxZ = x;
424 void TrackList::SetMaxOrbs(Float_t x)
426 fRnrStyle->fMaxOrbs = x;
430 void TrackList::SetMinAng(Float_t x)
432 fRnrStyle->fMinAng = x;
436 void TrackList::SetDelta(Float_t x)
438 fRnrStyle->fDelta = x;
442 void TrackList::SetFitDaughters(Bool_t x)
444 fRnrStyle->fFitDaughters = x;
448 void TrackList::SetFitDecay(Bool_t x)
450 fRnrStyle->fFitDecay = x;
454 /**************************************************************************/
455 /**************************************************************************/
457 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
459 Float_t minptsq = min_pt*min_pt;
460 Float_t maxptsq = max_pt*max_pt;
463 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
464 ptsq = ((Track*)(*i))->fP.Perp2();
465 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
469 /**************************************************************************/
471 void TrackList::ImportHits()
473 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
474 ((Track*)(*i))->ImportHits();
478 void TrackList::ImportClusters()
480 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
481 ((Track*)(*i))->ImportClusters();