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) { // Charged particle
99 Float_t a = RS.fgkB2C * RS.fMagField * fCharge;
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 == kFALSE){
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 == kFALSE)
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 void Track::ImportHits()
181 Reve::LoadMacro("hits_from_label.C");
182 gROOT->ProcessLine(Form("hits_from_label(%d);", fLabel));
185 void Track::ImportClusters()
187 Reve::LoadMacro("clusters_from_label.C");
188 gROOT->ProcessLine(Form("clusters_from_label(%d);", fLabel));
192 /**************************************************************************/
193 /**************************************************************************/
195 //______________________________________________________________________
199 ClassImp(Reve::TrackRnrStyle)
201 Float_t TrackRnrStyle::fgDefMagField = 5;
202 const Float_t TrackRnrStyle::fgkB2C = 0.299792458e-3;
203 TrackRnrStyle TrackRnrStyle::fgDefStyle;
205 void TrackRnrStyle::Init()
207 fMagField = fgDefMagField;
215 fFitDaughters = kTRUE;
218 fDelta = 0.1; //calculate step size depending on helix radius
221 /**************************************************************************/
222 /**************************************************************************/
224 //______________________________________________________________________
228 ClassImp(Reve::TrackList)
230 void TrackList::Init()
234 // fMarker->SetMarkerSize(0.05);
239 mRnrStyle = new TrackRnrStyle;
240 SetMainColorPtr(&mRnrStyle->fColor);
243 TrackList::TrackList(Int_t n_tracks) :
244 TPolyMarker3D(n_tracks),
245 RenderElementListBase()
250 TrackList::TrackList(const Text_t* name, Int_t n_tracks) :
251 TPolyMarker3D(n_tracks),
252 RenderElementListBase()
258 void TrackList::Reset(Int_t n_tracks)
260 delete [] fP; fP = 0;
262 if(fN) fP = new Float_t [3*fN];
263 memset(fP, 0, 3*fN*sizeof(Float_t));
267 /**************************************************************************/
269 void TrackList::Paint(Option_t* option)
273 TPolyMarker3D::Paint(option);
276 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
277 if((*i)->GetRnrElement())
278 (*i)->GetObject()->Paint(option);
284 /**************************************************************************/
286 void TrackList::AddElement(RenderElement* el)
288 static const Exc_t eH("TrackList::AddElement ");
289 if (dynamic_cast<Track*>(el) == 0)
290 throw(eH + "new element not a Track.");
291 RenderElementListBase::AddElement(el);
294 /**************************************************************************/
296 void TrackList::SetRnrMarkers(Bool_t rnr)
302 void TrackList::SetRnrTracks(Bool_t rnr)
309 /**************************************************************************/
311 void TrackList::MakeTracks()
313 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
314 ((Track*)(*i))->MakeTrack();
320 void TrackList::MakeMarkers()
323 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
324 Track& t = *((Track*)(*i));
326 SetNextPoint(t.fV.x, t.fV.y, t.fV.z);
331 /**************************************************************************/
332 /*************************************************************************/
334 void TrackList::SetMaxR(Float_t x)
336 mRnrStyle->fMaxR = x;
341 void TrackList::SetMaxZ(Float_t x)
343 mRnrStyle->fMaxZ = x;
348 void TrackList::SetMaxOrbs(Float_t x)
350 mRnrStyle->fMaxOrbs = x;
354 void TrackList::SetMinAng(Float_t x)
356 mRnrStyle->fMinAng = x;
360 void TrackList::SetDelta(Float_t x)
362 mRnrStyle->fDelta = x;
366 void TrackList::SetFitDaughters(Bool_t x)
368 mRnrStyle->fFitDaughters = x;
372 void TrackList::SetFitDecay(Bool_t x)
374 mRnrStyle->fFitDecay = x;
378 /**************************************************************************/
379 /**************************************************************************/
381 void TrackList::SelectByPt(Float_t min_pt, Float_t max_pt)
383 Float_t minptsq = min_pt*min_pt;
384 Float_t maxptsq = max_pt*max_pt;
387 for(lpRE_i i=fList.begin(); i!=fList.end(); ++i) {
388 ptsq = ((Track*)(*i))->fP.Perp2();
389 (*i)->SetRnrElement(ptsq >= minptsq && ptsq <= maxptsq);
393 /**************************************************************************/
396 #include <TGDoubleSlider.h>
397 #include <TGXYLayout.h>
399 void TrackList::MakePtScrollbar()
401 TGMainFrame* mf = new TGMainFrame(gClient->GetRoot(), 320, 60);
403 TGDoubleHSlider* hs = new TGDoubleHSlider(mf);
404 hs->SetRange(0.2, 10);
405 hs->SetPosition(0.2, 10);
407 mf->AddFrame(hs, new TGLayoutHints(kLHintsCenterX, 10, 10, 10, 10));
409 hs->Connect("PositionChanged()", "Reve::TrackList",
410 this, "HandlePtScrollEvent()");
412 mf->SetWindowName("Pt Selector");
414 mf->Resize(mf->GetDefaultSize()); // this is used here to init layout algorithm
418 void TrackList::HandlePtScrollEvent()
420 TGDoubleHSlider* hs = (TGDoubleHSlider*)gTQSender;
422 Float_t min = hs->GetMinPosition(), max = hs->GetMaxPosition();
423 printf("hslidor min=%f max=%f\n", min, max);
424 SelectByPt(min, max);