2 #include "VSDSelector.h"
3 #include "RGTopFrame.h"
5 #include <Reve/Track.h>
6 #include <Reve/PointSet.h>
9 #include <Reve/TTreeTools.h>
11 #include <TEventList.h>
13 #include <TGXYLayout.h>
20 VSDSelector::VSDSelector(TGListTree* lt, TGCompositeFrame *tFrame) :
25 mParticleSelection(0),
33 TGGroupFrame *gframe = new TGGroupFrame(tFrame, "Options", kVerticalFrame);
34 TGLayoutHints* lh0 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5);
35 gframe->SetTitlePos(TGGroupFrame::kRight); // right aligned
36 tFrame->AddFrame(gframe, lh0);
39 TGXYLayout* xyl = new TGXYLayout(gframe);
40 gframe->SetLayoutManager(xyl);
56 TGLabel* label = new TGLabel(gframe, "ParticleSelection");
57 label->Resize(labelw, wH);
58 label->SetTextJustify(kTextLeft | kTextCenterY);
59 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
60 gframe->AddFrame(label,lh);
63 mParticleSelection = new TGTextEntry(gframe, "fMother[0] == -1 && Pt() > 1");
64 mParticleSelection->Resize(entryw, wH);
65 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
66 gframe->AddFrame(mParticleSelection,lh);
69 TGTextButton* but = new TGTextButton(gframe, "Select");
70 but->Resize(butw, wH);
71 but->SetTextJustify(kTextCenterX | kTextCenterY);
72 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
73 gframe->AddFrame(but,lh);
74 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectParticles()");
78 fRecursiveSelect = new TGCheckButton(gframe, "Recursive");
79 fRecursiveSelect->Resize(rbw, wH);
80 lh = new TGXYLayoutHints(x, y, rbw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
81 gframe->AddFrame(fRecursiveSelect,lh);
88 TGLabel* label = new TGLabel(gframe, "HitSelection");
89 label->Resize(labelw, wH);
90 label->SetTextJustify(kTextLeft | kTextCenterY);
91 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
92 gframe->AddFrame(label,lh);
95 mHitSelection = new TGTextEntry(gframe, "det_id == 0");
96 mHitSelection->Resize(entryw, wH);
97 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
98 gframe->AddFrame(mHitSelection,lh);
101 TGTextButton* but = new TGTextButton(gframe, "Select");
102 but->Resize(butw, wH);
103 but->SetTextJustify(kTextCenterX | kTextCenterY);
104 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
105 gframe->AddFrame(but,lh);
106 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectHits()");
113 { // particle selection
114 TGLabel* label = new TGLabel(gframe, "ClusterSelection");
115 label->Resize(labelw, wH);
116 label->SetTextJustify(kTextLeft | kTextCenterY);
117 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
118 gframe->AddFrame(label,lh);
121 mClusterSelection = new TGTextEntry(gframe, "C.V.R() > 70");
122 mClusterSelection->Resize(entryw, wH);
123 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
124 gframe->AddFrame(mClusterSelection,lh);
127 TGTextButton* but = new TGTextButton(gframe, "Select");
128 but->Resize(butw, wH);
129 but->SetTextJustify(kTextCenterX | kTextCenterY);
130 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
131 gframe->AddFrame(but,lh);
132 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectClusters()");
136 { // reconstructed tracks selection
137 TGLabel* label = new TGLabel(gframe, "RecSelection");
138 label->Resize(labelw, wH);
139 label->SetTextJustify(kTextLeft | kTextCenterY);
140 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
141 gframe->AddFrame(label,lh);
144 mRecSelection = new TGTextEntry(gframe, "Pt() > 1");
145 mRecSelection->Resize(entryw, wH);
146 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
147 gframe->AddFrame(mRecSelection,lh);
150 TGTextButton* but = new TGTextButton(gframe, "Select");
151 but->Resize(butw, wH);
152 but->SetTextJustify(kTextCenterX | kTextCenterY);
153 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
154 gframe->AddFrame(but,lh);
155 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectRecTracks()");
158 gframe->Resize(60, 30); // resize to default size
159 gframe->MapSubwindows();
161 tFrame->MapSubwindows();
165 /**************************************************************************/
167 void VSDSelector::LoadVSD(const Text_t* vsd_file_name,
168 const Text_t* dir_name)
170 VSD::LoadVSD(vsd_file_name, dir_name);
171 fListTree->AddItem(0, dir_name);
174 /**************************************************************************/
176 /**************************************************************************/
178 void VSDSelector::SelectParticles(const Text_t* selection)
180 static const Exc_t eH("VSDSelector::SelectParticles ");
183 throw (eH + "kinematics not available.");
186 selection = mParticleSelection->GetText();
189 TGListTreeItem* parent = fListTree->FindItemByPathname("Event0");
190 if(parent == 0) return;
194 Int_t n = evl.Select(mTreeK, selection);
195 // printf("%d entries in selection '%s'.\n", n, selection);
198 throw (eH + "no entries found for selection in kinematics.");
201 TrackList* cont = new TrackList();
202 TrackRnrStyle* rs = new TrackRnrStyle();
203 cont->SetRnrStyle(rs);
205 TGListTreeItem *holder = fListTree->AddItem(parent, Form("MCTracks %s [%d]",selection,n));
206 holder->SetUserData(cont);
207 // printf("%d entries in selection '%s'.\n", n, selection);
210 Reve::PadHolder pHolder(true, gReve->GetCC());
211 for(Int_t i=0; i<n; i++) {
212 Int_t label = evl.GetEntry(i);
213 mTreeK->GetEntry(label);
214 Track* track = new Track(mpK, cont->GetRnrStyle());
216 TGListTreeItem* di = fListTree->AddItem
217 (holder, Form("%s daughters:%d", mK.GetName(), mK.GetNDaughters()), track);
218 di->SetUserData(track);
219 cont->AddElement(track);
220 // printf("select daugters %s selection %s\n",mpK->GetName(),Form("fMother[0] == %d", track->GetLabel()));
221 if(fRecursiveSelect->IsOn()) {
222 if(mK.GetNDaughters())
223 ImportDaughtersRec(di, cont, mK.GetFirstDaughter(), mK.GetLastDaughter());
224 // add decay point to path marks
226 Reve::PathMark* pm = new Reve::PathMark(Reve::PathMark::Decay);
227 pm->V.x = mK.V_decay.x;
228 pm->V.y = mK.V_decay.y;
229 pm->V.z = mK.V_decay.z;
230 track->AddPathMark(pm);
236 NotifyBrowser(parent);
240 /**************************************************************************/
242 void VSDSelector::ImportDaughtersRec(TGListTreeItem* parent, TrackList* cont,
243 Int_t first, Int_t last)
245 Track* mother = (Track*)parent->GetUserData();
247 for(Int_t i=first; i<=last; i++) {
249 Track* track = new Track(mpK, cont->GetRnrStyle());
251 TGListTreeItem* di = fListTree->AddItem
252 (parent, Form("%s daughters:%d", mK.GetName(), mK.GetNDaughters()), track);
253 di->SetUserData(track);
254 cont->AddElement(track);
255 if(mK.GetNDaughters())
256 ImportDaughtersRec(di, cont, mK.GetFirstDaughter(), mK.GetLastDaughter());
258 // add daughter mark to mother
259 Reve::PathMark* dam = new Reve::PathMark(Reve::PathMark::Daughter);
263 mother->AddPathMark(dam);
266 Reve::PathMark* decm = new Reve::PathMark(Reve::PathMark::Decay);
267 decm->V.x = mK.V_decay.x;
268 decm->V.y = mK.V_decay.y;
269 decm->V.z = mK.V_decay.z;
270 track->AddPathMark(decm);
276 /**************************************************************************/
278 void VSDSelector::SelectHits()
280 static const Exc_t eH("VSDSelector::SelectHits ");
283 throw (eH + "hits not available.");
285 const Text_t* selection;
287 selection = mHitSelection->GetText();
292 Int_t n = evl.Select(mTreeH, selection);
293 // printf("ImportHitsWithSelection %d entries for selection %s\n", n, selection);
296 throw(eH + "no hits matching selection.");
298 PointSet* container = new PointSet
299 (Form("Hits %s", selection), n);
300 for(Int_t i=0; i<n; i++) {
301 const Int_t entry = evl.GetEntry(i);
302 mTreeH->GetEntry(entry);
303 container->SetPoint(i, mH.V.x, mH.V.y, mH.V.z);
306 container->SetTitle(Form("N=%d", container->GetN()));
307 container->SetMarkerColor(2);
308 container->SetMarkerStyle(20);
309 container->SetMarkerSize(2);
310 gReve->AddRenderElement(container);
311 gReve->DrawRenderElement(container);
314 /**************************************************************************/
316 void VSDSelector::SelectClusters()
318 static const Exc_t eH("VSDSelector::SelectClusters ");
321 throw (eH + "clusters not available.");
323 const Text_t* selection;
324 if (mClusterSelection)
325 selection = mClusterSelection->GetText();
330 Int_t n = evl.Select(mTreeC, selection);
331 printf(" cluster Selection %d entries for selection %s\n", n, selection);
334 throw(eH + "no clusters matching selection.");
336 PointSet* container = new PointSet
337 (Form("Clusters %s", selection), n);
338 for(Int_t i=0; i<n; i++) {
339 const Int_t entry = evl.GetEntry(i);
340 mTreeC->GetEntry(entry);
341 container->SetPoint(i, mC.V.x, mC.V.y, mC.V.z);
344 container->SetTitle(Form("N=%d", container->GetN()));
345 container->SetMarkerColor(9);
346 container->SetMarkerStyle(20);
347 container->SetMarkerSize(2);
348 gReve->AddRenderElement(container);
349 gReve->DrawRenderElement(container);
352 /**************************************************************************/
354 void VSDSelector::SelectRecTracks()
356 static const Exc_t eH("VSDSelector::SelectRecTracks ");
359 throw (eH + "reconstructed tracks not available.");
361 const Text_t* selection;
363 selection = mRecSelection->GetText();
365 selection = "Pt() > 1";
368 Int_t n = evl.Select(mTreeR, selection);
369 // printf("%d entries in selection %s \n", n, selection);
372 throw (eH + "No entries found in ESD data.");
375 Reve::PadHolder pHolder(true, gReve->GetCC());
377 TGListTreeItem* parent = fListTree->FindItemByPathname("Event0");
378 TrackList* cont = new TrackList();
379 TrackRnrStyle* rs = new TrackRnrStyle();
380 cont->SetRnrStyle(rs);
382 TGListTreeItem *holder = fListTree->AddItem(parent, Form("RecTracks %s [%d]",selection, n));
383 holder->SetUserData(cont);
384 for (Int_t i=0; i<n; i++) {
385 Int_t label = evl.GetEntry(i);
386 mTreeR->GetEntry(label);
387 Track* track = new Track(mpR, cont->GetRnrStyle());
392 fListTree->AddItem(holder, "RecTrack", track);
393 di->SetUserData(track);
394 cont->AddElement(track);
398 NotifyBrowser(parent);
402 /**************************************************************************/
404 void VSDSelector::NotifyBrowser(TGListTreeItem* parent)
407 args[0] = (Long_t)parent;
410 fListTree->Emit("Clicked(TGListTreeItem*, Int_t)", args);
411 fListTree->OpenItem(parent);