4 #include "MCHelixLine.hi"
6 #include <TPolyLine3D.h>
7 #include <TPolyMarker3D.h>
11 #include <Reve/RGTopFrame.h>
18 //______________________________________________________________________
41 Track::Track(Reve::MCTrack* t, 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 t->ResetPdgCode(); pdgp = t->GetPDG();
64 fCharge = (Int_t) TMath::Nint(pdgp->Charge()/3);
67 Track::Track(Reve::RecTrack* t, TrackRnrStyle* rs) :
83 fLineColor = fRnrStyle->GetColor();
84 fMainColorPtr = &fLineColor;
89 for (vpPathMark_i i=fPathMarks.begin(); i!=fPathMarks.end(); ++i)
93 void Track::Reset(Int_t n_points)
95 delete [] TPolyLine3D::fP; TPolyLine3D::fP = 0;
97 if(fN) TPolyLine3D::fP = new Float_t [3*fN];
98 memset(TPolyLine3D::fP, 0, 3*fN*sizeof(Float_t));
102 /**************************************************************************/
104 void Track::MakeTrack()
107 TrackRnrStyle& RS((fRnrStyle != 0) ? *fRnrStyle : TrackRnrStyle::fgDefStyle);
109 Float_t px = fP.x, py = fP.y, pz = fP.z;
117 std::vector<MCVertex> track_points;
118 Bool_t decay = kFALSE;
120 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
123 if (fCharge != 0 && TMath::Abs(RS.fMagField) > 1e-5) {
125 // Charged particle in magnetic field
127 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
129 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
130 helix.Init(TMath::Sqrt(px*px+py*py), pz);
132 if(!fPathMarks.empty()){
133 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
134 Reve::PathMark* pm = *i;
136 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
137 if(TMath::Abs(pm->V.z) > RS.fMaxZ
138 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
141 //printf("%s fit daughter \n", fName.Data());
142 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
147 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
149 if(TMath::Abs(pm->V.z) > RS.fMaxZ
150 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
152 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
160 if(!decay || RS.fFitDecay == kFALSE){
161 helix.LoopToBounds(px,py,pz);
162 // printf("%s loop to bounds \n",fName.Data() );
167 // Neutral particle or no field
169 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
171 if(!fPathMarks.empty()){
172 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
173 Reve::PathMark* pm = *i;
175 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
176 if(TMath::Abs(pm->V.z) > RS.fMaxZ
177 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
179 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
185 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
186 if(TMath::Abs(pm->V.z) > RS.fMaxZ
187 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
189 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
197 if(!decay || RS.fFitDecay == kFALSE)
198 line.GotoBounds(px,py,pz);
202 Reset(track_points.size());
203 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
204 SetNextPoint(i->x, i->y, i->z);
207 /**************************************************************************/
209 void Track::ImportHits()
211 Reve::LoadMacro("hits_from_label.C");
212 gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
215 void Track::ImportClusters()
217 Reve::LoadMacro("clusters_from_label.C");
218 gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
222 /**************************************************************************/
223 /**************************************************************************/
225 //______________________________________________________________________
229 ClassImp(Reve::TrackRnrStyle)
231 Float_t TrackRnrStyle::fgDefMagField = 5;
232 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
233 TrackRnrStyle TrackRnrStyle::fgDefStyle;
235 TrackRnrStyle::TrackRnrStyle() :
239 fMagField(fgDefMagField),
248 fFitDaughters(kTRUE),
252 /**************************************************************************/
253 /**************************************************************************/
255 //______________________________________________________________________
259 ClassImp(Reve::TrackList)
261 void TrackList::Init()
265 // fMarker->SetMarkerSize(0.05);
267 mRnrStyle = new TrackRnrStyle;
268 SetMainColorPtr(&mRnrStyle->fColor);
271 TrackList::TrackList(Int_t n_tracks) :
272 RenderElementListBase(),
273 TPolyMarker3D(n_tracks),
284 TrackList::TrackList(const Text_t* name, Int_t n_tracks) :
285 RenderElementListBase(),
286 TPolyMarker3D(n_tracks),
298 void TrackList::Reset(Int_t n_tracks)
300 delete [] fP; fP = 0;
302 if(fN) fP = new Float_t [3*fN];
303 memset(fP, 0, 3*fN*sizeof(Float_t));
307 /**************************************************************************/
309 void TrackList::Paint(Option_t* option)
313 TPolyMarker3D::Paint(option);
316 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
317 if((*i)->GetRnrElement())
318 (*i)->GetObject()->Paint(option);
324 /**************************************************************************/
326 void TrackList::AddElement(RenderElement* el)
328 static const Exc_t eH("TrackList::AddElement ");
329 if (dynamic_cast<Track*>(el) == 0)
330 throw(eH + "new element not a Track.");
331 RenderElementListBase::AddElement(el);
334 /**************************************************************************/
336 void TrackList::SetRnrMarkers(Bool_t rnr)
342 void TrackList::SetRnrTracks(Bool_t rnr)
349 /**************************************************************************/
351 void TrackList::MakeTracks()
353 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
354 ((Track*)(*i))->MakeTrack();
360 void TrackList::MakeMarkers()
362 Reset(fChildren.size());
363 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
364 Track& t = *((Track*)(*i));
366 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
371 /**************************************************************************/
372 /*************************************************************************/
374 void TrackList::SetMaxR(Float_t x)
376 mRnrStyle->fMaxR = x;
381 void TrackList::SetMaxZ(Float_t x)
383 mRnrStyle->fMaxZ = x;
388 void TrackList::SetMaxOrbs(Float_t x)
390 mRnrStyle->fMaxOrbs = x;
394 void TrackList::SetMinAng(Float_t x)
396 mRnrStyle->fMinAng = x;
400 void TrackList::SetDelta(Float_t x)
402 mRnrStyle->fDelta = x;
406 void TrackList::SetFitDaughters(Bool_t x)
408 mRnrStyle->fFitDaughters = x;
412 void TrackList::SetFitDecay(Bool_t x)
414 mRnrStyle->fFitDecay = x;
418 /**************************************************************************/
419 /**************************************************************************/
421 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
423 Float_t minptsq = min_pt*min_pt;
424 Float_t maxptsq = max_pt*max_pt;
427 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
428 ptsq = ((Track*)(*i))->fP.Perp2();
429 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
433 /**************************************************************************/
435 void TrackList::ImportHits()
437 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
438 ((Track*)(*i))->ImportHits();
442 void TrackList::ImportClusters()
444 for(lpRE_i i=fChildren.begin(); i!=fChildren.end(); ++i) {
445 ((Track*)(*i))->ImportClusters();