2 #include "VSDSelector.h"
4 #include "ReveManager.h"
6 #include <Reve/Track.h>
7 #include <Reve/PointSet.h>
10 #include <Reve/TTreeTools.h>
12 #include <TEventList.h>
14 #include <TGXYLayout.h>
21 VSDSelector::VSDSelector(TGCompositeFrame *tFrame) :
24 mParticleSelection(0),
32 TGGroupFrame *gframe = new TGGroupFrame(tFrame, "Options", kVerticalFrame);
33 TGLayoutHints* lh0 = new TGLayoutHints(kLHintsTop | kLHintsLeft | kLHintsExpandX | kLHintsExpandY , 5, 5, 5, 5);
34 gframe->SetTitlePos(TGGroupFrame::kRight); // right aligned
35 tFrame->AddFrame(gframe, lh0);
37 TGXYLayout* xyl = new TGXYLayout(gframe);
38 gframe->SetLayoutManager(xyl);
52 TGLabel* label = new TGLabel(gframe, "ParticleSelection");
53 label->Resize(labelw, wH);
54 label->SetTextJustify(kTextLeft | kTextCenterY);
55 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
56 gframe->AddFrame(label,lh);
59 mParticleSelection = new TGTextEntry(gframe, "fMother[0] == -1 && Pt() > 1");
60 mParticleSelection->Resize(entryw, wH);
61 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
62 gframe->AddFrame(mParticleSelection,lh);
65 TGTextButton* but = new TGTextButton(gframe, "Select");
66 but->Resize(butw, wH);
67 but->SetTextJustify(kTextCenterX | kTextCenterY);
68 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
69 gframe->AddFrame(but,lh);
70 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectParticles()");
74 fRecursiveSelect = new TGCheckButton(gframe, "Recursive");
75 fRecursiveSelect->Resize(rbw, wH);
76 lh = new TGXYLayoutHints(x, y, rbw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
77 gframe->AddFrame(fRecursiveSelect,lh);
84 TGLabel* label = new TGLabel(gframe, "HitSelection");
85 label->Resize(labelw, wH);
86 label->SetTextJustify(kTextLeft | kTextCenterY);
87 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
88 gframe->AddFrame(label,lh);
91 mHitSelection = new TGTextEntry(gframe, "det_id == 0");
92 mHitSelection->Resize(entryw, wH);
93 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
94 gframe->AddFrame(mHitSelection,lh);
97 TGTextButton* but = new TGTextButton(gframe, "Select");
98 but->Resize(butw, wH);
99 but->SetTextJustify(kTextCenterX | kTextCenterY);
100 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
101 gframe->AddFrame(but,lh);
102 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectHits()");
109 { // particle selection
110 TGLabel* label = new TGLabel(gframe, "ClusterSelection");
111 label->Resize(labelw, wH);
112 label->SetTextJustify(kTextLeft | kTextCenterY);
113 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
114 gframe->AddFrame(label,lh);
117 mClusterSelection = new TGTextEntry(gframe, "C.V.R() > 70");
118 mClusterSelection->Resize(entryw, wH);
119 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
120 gframe->AddFrame(mClusterSelection,lh);
123 TGTextButton* but = new TGTextButton(gframe, "Select");
124 but->Resize(butw, wH);
125 but->SetTextJustify(kTextCenterX | kTextCenterY);
126 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
127 gframe->AddFrame(but,lh);
128 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectClusters()");
134 { // reconstructed tracks selection
135 TGLabel* label = new TGLabel(gframe, "RecSelection");
136 label->Resize(labelw, wH);
137 label->SetTextJustify(kTextLeft | kTextCenterY);
138 lh = new TGXYLayoutHints(x, y, labelw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
139 gframe->AddFrame(label,lh);
142 mRecSelection = new TGTextEntry(gframe, "Pt() > 1");
143 mRecSelection->Resize(entryw, wH);
144 lh = new TGXYLayoutHints(x, y, entryw, wH,0); lh->SetPadLeft(2); lh->SetPadRight(2);
145 gframe->AddFrame(mRecSelection,lh);
148 TGTextButton* but = new TGTextButton(gframe, "Select");
149 but->Resize(butw, wH);
150 but->SetTextJustify(kTextCenterX | kTextCenterY);
151 lh = new TGXYLayoutHints(x, y, butw, wH,0); lh->SetPadLeft(4); lh->SetPadRight(2);
152 gframe->AddFrame(but,lh);
153 but->Connect("Pressed()", "Reve::VSDSelector", this, "SelectRecTracks()");
156 gframe->Resize(60, 30); // resize to default size
157 gframe->MapSubwindows();
159 tFrame->MapSubwindows();
163 /**************************************************************************/
165 void VSDSelector::LoadVSD(const Text_t* vsd_file_name,
166 const Text_t* dir_name)
168 VSD::LoadVSD(vsd_file_name, dir_name);
169 // !!!! Should create VSDEvent ... but it is not done yet.
170 EventBase* ev = new EventBase(vsd_file_name, 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 Int_t n = evl.Select(mTreeK, selection);
190 // printf("%d entries in selection '%s'.\n", n, selection);
193 throw (eH + "no entries found for selection in kinematics.");
195 TrackList* cont = new TrackList();
196 cont->SetMainColor(4);
198 gReve->AddRenderElement(cont);
201 for(Int_t i=0; i<n; i++) {
202 Int_t label = evl.GetEntry(i);
203 mTreeK->GetEntry(label);
204 Track* track = new Track(mpK, cont->GetRnrStyle());
205 track->SetName(Form("%s daughters:%d", mK.GetName(), mK.GetNDaughters()));
206 gReve->AddRenderElement(track, cont);
208 // printf("select daugters %s selection %s\n",mpK->GetName(),Form("fMother[0] == %d", track->GetLabel()));
209 if(fRecursiveSelect->IsOn()) {
210 if(mK.GetNDaughters())
211 ImportDaughtersRec(track, cont, mK.GetFirstDaughter(), mK.GetLastDaughter());
212 // add decay point to path marks
214 Reve::PathMark* pm = new Reve::PathMark(Reve::PathMark::Decay);
215 pm->V.x = mK.V_decay.x;
216 pm->V.y = mK.V_decay.y;
217 pm->V.z = mK.V_decay.z;
218 track->AddPathMark(pm);
226 void VSDSelector::ImportDaughtersRec(RenderElement* parent, TrackList* cont,
227 Int_t first, Int_t last)
229 Track* mother = dynamic_cast<Track*>(parent);
231 for(Int_t i=first; i<=last; i++) {
233 Track* track = new Track(mpK, cont->GetRnrStyle());
234 track->SetName(Form("%s daughters:%d", mK.GetName(), mK.GetNDaughters()));
235 gReve->AddRenderElement(track, parent);
236 cont->AddElement(track); // ?? is this ok ??
237 if(mK.GetNDaughters())
238 ImportDaughtersRec(track, cont, mK.GetFirstDaughter(), mK.GetLastDaughter());
240 // add daughter mark to mother
241 Reve::PathMark* dam = new Reve::PathMark(Reve::PathMark::Daughter);
245 mother->AddPathMark(dam);
248 Reve::PathMark* decm = new Reve::PathMark(Reve::PathMark::Decay);
249 decm->V.x = mK.V_decay.x;
250 decm->V.y = mK.V_decay.y;
251 decm->V.z = mK.V_decay.z;
252 track->AddPathMark(decm);
259 /**************************************************************************/
260 /**************************************************************************/
262 void VSDSelector::SelectHits()
264 static const Exc_t eH("VSDSelector::SelectHits ");
267 throw (eH + "hits not available.");
269 const Text_t* selection;
271 selection = mHitSelection->GetText();
276 Int_t n = evl.Select(mTreeH, selection);
277 // printf("ImportHitsWithSelection %d entries for selection %s\n", n, selection);
280 throw(eH + "no hits matching selection.");
282 PointSet* container = new PointSet
283 (Form("Hits %s", selection), n);
284 for(Int_t i=0; i<n; i++) {
285 const Int_t entry = evl.GetEntry(i);
286 mTreeH->GetEntry(entry);
287 container->SetPoint(i, mH.V.x, mH.V.y, mH.V.z);
290 container->SetTitle(Form("N=%d", container->GetN()));
291 container->SetMarkerColor(2);
292 container->SetMarkerStyle(20);
293 container->SetMarkerSize(0.5);
294 gReve->AddRenderElement(container);
298 /**************************************************************************/
300 void VSDSelector::SelectClusters()
302 static const Exc_t eH("VSDSelector::SelectClusters ");
305 throw (eH + "clusters not available.");
307 const Text_t* selection;
308 if (mClusterSelection)
309 selection = mClusterSelection->GetText();
314 Int_t n = evl.Select(mTreeC, selection);
315 printf(" cluster Selection %d entries for selection %s\n", n, selection);
318 throw(eH + "no clusters matching selection.");
320 PointSet* container = new PointSet
321 (Form("Clusters %s", selection), n);
322 for(Int_t i=0; i<n; i++) {
323 const Int_t entry = evl.GetEntry(i);
324 mTreeC->GetEntry(entry);
325 container->SetPoint(i, mC.V.x, mC.V.y, mC.V.z);
328 container->SetTitle(Form("N=%d", container->GetN()));
329 container->SetMarkerColor(9);
330 container->SetMarkerStyle(20);
331 container->SetMarkerSize(0.5);
332 gReve->AddRenderElement(container);
336 /**************************************************************************/
338 void VSDSelector::SelectRecTracks()
340 static const Exc_t eH("VSDSelector::SelectRecTracks ");
343 throw (eH + "reconstructed tracks not available.");
345 const Text_t* selection;
347 selection = mRecSelection->GetText();
349 selection = "Pt() > 1";
352 Int_t n = evl.Select(mTreeR, selection);
353 // printf("%d entries in selection %s \n", n, selection);
356 throw (eH + "No entries found in ESD data.");
359 TrackList* cont = new TrackList(Form("RecTracks %s [%d]",selection, n));
360 cont->SetMainColor(6);
362 gReve->AddRenderElement(cont);
364 for (Int_t i=0; i<n; i++) {
365 Int_t label = evl.GetEntry(i);
366 mTreeR->GetEntry(label);
367 Track* track = new Track(mpR, cont->GetRnrStyle());
370 gReve->AddRenderElement(track, cont);