4 #include "MCHelixLine.hi"
6 #include <TPolyLine3D.h>
7 #include <TPolyMarker3D.h>
11 #include <Reve/RGTopFrame.h>
18 //______________________________________________________________________
29 Track::Track(Reve::MCTrack* t, TrackRnrStyle* rs)
34 fLineColor = fRnrStyle->GetColor();
35 fMainColorPtr = &fLineColor;
37 fV.Set(t->Vx(), t->Vy(), t->Vz());
38 fP.Set(t->Px(), t->Py(), t->Pz());
39 fBeta = t->P()/t->Energy();
41 TParticlePDG* pdgp = t->GetPDG();
43 t->ResetPdgCode(); pdgp = t->GetPDG();
46 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
50 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs)
54 fLineColor = fRnrStyle->GetColor();
55 fMainColorPtr = &fLineColor;
67 void Track::Reset(Int_t n_points)
69 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
71 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
72 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
76 /**************************************************************************/
78 void Track::MakeTrack()
81 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
83 Float_t px = fP.x, py = fP.y, pz = fP.z;
91 std::vector<MCVertex> track_points;
92 Bool_t decay = kFALSE;
94 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
97 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
99 // Charged particle in magnetic field
101 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
103 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
104 helix.Init(TMath::Sqrt(px*px+py*py), pz);
106 if(!fPathMarks.empty()){
107 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
108 Reve::PathMark* pm = *i;
110 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
111 if(TMath::Abs(pm->V.z) > RS.fMaxZ
112 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
115 //printf("%s fit daughter \n", fName.Data());
116 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
121 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
123 if(TMath::Abs(pm->V.z) > RS.fMaxZ
124 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
126 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
134 if(!decay || RS.fFitDecay == kFALSE){
135 helix.LoopToBounds(px,py,pz);
136 // printf("%s loop to bounds \n",fName.Data() );
141 // Neutral particle or no field
143 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
145 if(!fPathMarks.empty()){
146 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
147 Reve::PathMark* pm = *i;
149 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
150 if(TMath::Abs(pm->V.z) > RS.fMaxZ
151 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
153 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
159 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
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 )
163 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
171 if(!decay || RS.fFitDecay == kFALSE)
172 line.GotoBounds(px,py,pz);
176 Reset(track_points.size());
177 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
178 SetNextPoint(i->x, i->y, i->z);
181 /**************************************************************************/
183 void Track::ImportHits()
185 Reve::LoadMacro("hits_from_label.C");
186 gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
189 void Track::ImportClusters()
191 Reve::LoadMacro("clusters_from_label.C");
192 gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
196 /**************************************************************************/
197 /**************************************************************************/
199 //______________________________________________________________________
203 ClassImp(Reve::TrackRnrStyle)
205 Float_t TrackRnrStyle::fgDefMagField = 5;
206 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
207 TrackRnrStyle TrackRnrStyle::fgDefStyle;
209 void TrackRnrStyle::Init()
211 fMagField = fgDefMagField;
219 fFitDaughters = kTRUE;
222 fDelta = 0.1; //calculate step size depending on helix radius
225 /**************************************************************************/
226 /**************************************************************************/
228 //______________________________________________________________________
232 ClassImp(Reve::TrackList)
234 void TrackList::Init()
238 // fMarker->SetMarkerSize(0.05);
243 mRnrStyle = new TrackRnrStyle;
244 SetMainColorPtr(&mRnrStyle->fColor);
247 TrackList::TrackList(Int_t n_tracks) :
248 RenderElementListBase(),
249 TPolyMarker3D(n_tracks)
254 TrackList::TrackList(const Text_t* name, Int_t n_tracks) :
255 RenderElementListBase(),
256 TPolyMarker3D(n_tracks)
262 void TrackList::Reset(Int_t n_tracks)
264 delete [] fP; fP = 0;
266 if(fN) fP = new Float_t [3*fN];
267 memset(fP, 0, 3*fN*sizeof(Float_t));
271 /**************************************************************************/
273 void TrackList::Paint(Option_t* option)
277 TPolyMarker3D::Paint(option);
280 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
281 if((*i)->GetRnrElement())
282 (*i)->GetObject()->Paint(option);
288 /**************************************************************************/
290 void TrackList::AddElement(RenderElement* el)
292 static const Exc_t eH("TrackList::AddElement ");
293 if (dynamic_cast<Track*>(el) == 0)
294 throw(eH + "new element not a Track.");
295 RenderElementListBase::AddElement(el);
298 /**************************************************************************/
300 void TrackList::SetRnrMarkers(Bool_t rnr)
306 void TrackList::SetRnrTracks(Bool_t rnr)
313 /**************************************************************************/
315 void TrackList::MakeTracks()
317 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
318 ((Track*)(*i))->MakeTrack();
324 void TrackList::MakeMarkers()
326 Reset(fChildren.size());
327 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
328 Track& t = *((Track*)(*i));
330 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
335 /**************************************************************************/
336 /*************************************************************************/
338 void TrackList::SetMaxR(Float_t x)
340 mRnrStyle->fMaxR = x;
345 void TrackList::SetMaxZ(Float_t x)
347 mRnrStyle->fMaxZ = x;
352 void TrackList::SetMaxOrbs(Float_t x)
354 mRnrStyle->fMaxOrbs = x;
358 void TrackList::SetMinAng(Float_t x)
360 mRnrStyle->fMinAng = x;
364 void TrackList::SetDelta(Float_t x)
366 mRnrStyle->fDelta = x;
370 void TrackList::SetFitDaughters(Bool_t x)
372 mRnrStyle->fFitDaughters = x;
376 void TrackList::SetFitDecay(Bool_t x)
378 mRnrStyle->fFitDecay = x;
382 /**************************************************************************/
383 /**************************************************************************/
385 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
387 Float_t minptsq = min_pt*min_pt;
388 Float_t maxptsq = max_pt*max_pt;
391 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
392 ptsq = ((Track*)(*i))->fP.Perp2();
393 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
397 /**************************************************************************/
399 void TrackList::ImportHits()
401 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
402 ((Track*)(*i))->ImportHits();
406 void TrackList::ImportClusters()
408 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
409 ((Track*)(*i))->ImportClusters();