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) pdgp->Charge();
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;
94 if ((TMath::Abs(fV.z) > RS.fMaxZ) || (fV.x*fV.x + fV.y*fV.y > RS.fMaxR*RS.fMaxR))
97 if (fCharge) { // Charged particle
99 Float_t a = 0.2998*RS.fMagField*fCharge/300; // m->cm
101 MCHelix helix(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points, a); //m->cm
102 helix.Init(TMath::Sqrt(px*px+py*py), pz);
104 if(!fPathMarks.empty()){
105 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
106 Reve::PathMark* pm = *i;
108 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
109 if(TMath::Abs(pm->V.z) > RS.fMaxZ
110 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
113 //printf("%s fit daughter \n", fName.Data());
114 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
119 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
121 if(TMath::Abs(pm->V.z) > RS.fMaxZ
122 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
124 helix.LoopToVertex(fP.x, fP.y, fP.z, pm->V.x, pm->V.y, pm->V.z);
132 if(!decay || RS.fFitDecay == false){
133 helix.LoopToBounds(px,py,pz);
134 // printf("%s loop to bounds \n",fName.Data() );
137 } else { // Neutral particle
139 MCLine line(fRnrStyle, &mc_v0, TMath::C()*fBeta, &track_points);
141 if(!fPathMarks.empty()){
142 for(std::vector<Reve::PathMark*>::iterator i=fPathMarks.begin(); i!=fPathMarks.end(); ++i) {
143 Reve::PathMark* pm = *i;
145 if(RS.fFitDaughters && pm->type == Reve::PathMark::Daughter){
146 if(TMath::Abs(pm->V.z) > RS.fMaxZ
147 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
149 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
155 if(RS.fFitDecay && pm->type == Reve::PathMark::Decay){
156 if(TMath::Abs(pm->V.z) > RS.fMaxZ
157 || TMath::Sqrt(pm->V.x*pm->V.x + pm->V.y*pm->V.y) > RS.fMaxR )
159 line.GotoVertex(pm->V.x, pm->V.y, pm->V.z);
167 if(!decay || RS.fFitDecay == false)
168 line.GotoBounds(px,py,pz);
172 Reset(track_points.size());
173 for(std::vector<MCVertex>::iterator i=track_points.begin(); i!=track_points.end(); ++i)
174 SetNextPoint(i->x, i->y, i->z);
177 /**************************************************************************/
179 //______________________________________________________________________
183 ClassImp(Reve::TrackRnrStyle)
185 Float_t TrackRnrStyle::fgDefMagField = 0.5;
186 TrackRnrStyle TrackRnrStyle::fgDefStyle;
188 void TrackRnrStyle::Init()
190 fMagField = fgDefMagField;
198 fFitDaughters = true;
201 fDelta = 0.1; //calculate step size depending on helix radius
204 /**************************************************************************/
205 /**************************************************************************/
207 //______________________________________________________________________
211 ClassImp(Reve::TrackList)
213 void TrackList::Init()
217 // fMarker->SetMarkerSize(0.05);
222 mRnrStyle = new TrackRnrStyle;
223 SetMainColorPtr(&mRnrStyle->fColor);
226 TrackList::TrackList(Int_t n_tracks) :
227 TPolyMarker3D(n_tracks),
228 RenderElementListBase()
233 TrackList::TrackList(const Text_t* name, Int_t n_tracks) :
234 TPolyMarker3D(n_tracks),
235 RenderElementListBase()
241 void TrackList::Reset(Int_t n_tracks)
243 delete [] fP; fP = 0;
245 if(fN) fP = new Float_t [3*fN];
246 memset(fP, 0, 3*fN*sizeof(Float_t));
250 /**************************************************************************/
252 void TrackList::Paint(Option_t* option)
256 TPolyMarker3D::Paint(option);
259 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
260 if((*i)->GetRnrElement())
261 (*i)->GetObject()->Paint(option);
267 /**************************************************************************/
269 void TrackList::AddElement(RenderElement* el)
271 static const Exc_t eH("TrackList::AddElement ");
272 if (dynamic_cast<Track*>(el) == 0)
273 throw(eH + "new element not a Track.");
274 RenderElementListBase::AddElement(el);
277 /**************************************************************************/
279 void TrackList::SetRnrMarkers(Bool_t rnr)
285 void TrackList::SetRnrTracks(Bool_t rnr)
292 /**************************************************************************/
294 void TrackList::MakeTracks()
296 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
297 ((Track*)(*i))->MakeTrack();
303 void TrackList::MakeMarkers()
306 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
307 Track& t = *((Track*)(*i));
309 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
314 /**************************************************************************/
315 /*************************************************************************/
317 void TrackList::SetMaxR(Float_t x)
319 mRnrStyle->fMaxR = x;
324 void TrackList::SetMaxZ(Float_t x)
326 mRnrStyle->fMaxZ = x;
331 void TrackList::SetMaxOrbs(Float_t x)
333 mRnrStyle->fMaxOrbs = x;
337 void TrackList::SetMinAng(Float_t x)
339 mRnrStyle->fMinAng = x;
343 void TrackList::SetDelta(Float_t x)
345 mRnrStyle->fDelta = x;
349 void TrackList::SetFitDaughters(Bool_t x)
351 mRnrStyle->fFitDaughters = x;
355 void TrackList::SetFitDecay(Bool_t x)
357 mRnrStyle->fFitDecay = x;
361 /**************************************************************************/
362 /**************************************************************************/
364 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
366 Float_t minptsq = min_pt*min_pt;
367 Float_t maxptsq = max_pt*max_pt;
370 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
371 ptsq = ((Track*)(*i))->fP.Perp2();
372 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
376 /**************************************************************************/
379 #include <TGDoubleSlider.h>
380 #include <TGXYLayout.h>
382 void TrackList::MakePtScrollbar()
384 TGMainFrame* mf = new TGMainFrame(gClient->GetRoot(), 320, 60);
386 TGDoubleHSlider* hs = new TGDoubleHSlider(mf);
387 hs->SetRange(0.2, 10);
388 hs->SetPosition(0.2, 10);
390 mf->AddFrame(hs, new TGLayoutHints(kLHintsCenterX, 10, 10, 10, 10));
392 hs->Connect("PositionChanged()", "Reve::TrackList",
393 this, "HandlePtScrollEvent()");
395 mf->SetWindowName("Pt Selector");
397 mf->Resize(mf->GetDefaultSize()); // this is used here to init layout algorithm
401 void TrackList::HandlePtScrollEvent()
403 TGDoubleHSlider* hs = (TGDoubleHSlider*)gTQSender;
405 Float_t min = hs->GetMinPosition(), max = hs->GetMaxPosition();
406 printf("hslidor min=%f max=%f\n", min, max);
407 SelectByPt(min, max);